Added decent spacing to all scripts thanks to Rubocop

This commit is contained in:
Maruno17
2021-12-18 15:25:40 +00:00
parent f7b76ae62e
commit d17fc40a47
207 changed files with 18577 additions and 18587 deletions

View File

@@ -15,7 +15,7 @@ module PBDebug
end
def self.flush
if $DEBUG && $INTERNAL && @@log.length>0
if $DEBUG && $INTERNAL && @@log.length > 0
File.open("Data/debuglog.txt", "a+b") { |f| f.write(@@log.to_s) }
end
@@log.clear

View File

@@ -13,7 +13,7 @@ class EventScriptError < Exception
end
end
def pbGetExceptionMessage(e,_script = "")
def pbGetExceptionMessage(e, _script = "")
return e.event_message.dup if e.is_a?(EventScriptError) # Message with map/event ID generated elsewhere
emessage = e.message.dup
emessage.force_encoding(Encoding::UTF_8)

View File

@@ -79,7 +79,7 @@ def safeExists?(f)
return FileTest.exist?(f) if f[/\A[\x20-\x7E]*\z/]
ret = false
begin
File.open(f,"rb") { ret = true }
File.open(f, "rb") { ret = true }
rescue Errno::ENOENT, Errno::EINVAL, Errno::EACCES
ret = false
end
@@ -89,13 +89,13 @@ end
# Similar to "Dir.glob", but designed to work around a problem with accessing
# files if a path contains accent marks.
# "dir" is the directory path, "wildcard" is the filename pattern to match.
def safeGlob(dir,wildcard)
def safeGlob(dir, wildcard)
ret = []
afterChdir = false
begin
Dir.chdir(dir) {
afterChdir = true
Dir.glob(wildcard) { |f| ret.push(dir+"/"+f) }
Dir.glob(wildcard) { |f| ret.push(dir + "/" + f) }
}
rescue Errno::ENOENT
raise if afterChdir
@@ -118,18 +118,18 @@ end
# archives. Returns nil if the path can't be found.
def pbResolveBitmap(x)
return nil if !x
noext = x.gsub(/\.(bmp|png|gif|jpg|jpeg)$/,"")
noext = x.gsub(/\.(bmp|png|gif|jpg|jpeg)$/, "")
filename = nil
# RTP.eachPathFor(x) { |path|
# filename = pbTryString(path) if !filename
# filename = pbTryString(path+".gif") if !filename
# filename = pbTryString(path + ".gif") if !filename
# }
RTP.eachPathFor(noext) { |path|
filename = pbTryString(path+".png") if !filename
filename = pbTryString(path+".gif") if !filename
# filename = pbTryString(path+".jpg") if !filename
# filename = pbTryString(path+".jpeg") if !filename
# filename = pbTryString(path+".bmp") if !filename
filename = pbTryString(path + ".png") if !filename
filename = pbTryString(path + ".gif") if !filename
# filename = pbTryString(path + ".jpg") if !filename
# filename = pbTryString(path + ".jpeg") if !filename
# filename = pbTryString(path + ".bmp") if !filename
}
return filename
end
@@ -180,31 +180,31 @@ end
module RTP
@rtpPaths = nil
def self.exists?(filename,extensions = [])
def self.exists?(filename, extensions = [])
return false if nil_or_empty?(filename)
eachPathFor(filename) { |path|
return true if safeExists?(path)
for ext in extensions
return true if safeExists?(path+ext)
return true if safeExists?(path + ext)
end
}
return false
end
def self.getImagePath(filename)
return self.getPath(filename,["",".png",".gif"]) # ".jpg", ".jpeg", ".bmp"
return self.getPath(filename, ["", ".png", ".gif"]) # ".jpg", ".jpeg", ".bmp"
end
def self.getAudioPath(filename)
return self.getPath(filename,["",".wav",".wma",".mid",".ogg",".midi"]) # ".mp3"
return self.getPath(filename, ["", ".wav", ".wma", ".mid", ".ogg", ".midi"]) # ".mp3"
end
def self.getPath(filename,extensions = [])
def self.getPath(filename, extensions = [])
return filename if nil_or_empty?(filename)
eachPathFor(filename) { |path|
return path if safeExists?(path)
for ext in extensions
file = path+ext
file = path + ext
return file if safeExists?(file)
end
}
@@ -220,10 +220,10 @@ module RTP
else
# relative path
RTP.eachPath { |path|
if path=="./"
if path == "./"
yield filename
else
yield path+filename
yield path + filename
end
}
end
@@ -237,7 +237,7 @@ module RTP
def self.eachPath
# XXX: Use "." instead of Dir.pwd because of problems retrieving files if
# the current directory contains an accent mark
yield ".".gsub(/[\/\\]/,"/").gsub(/[\/\\]$/,"")+"/"
yield ".".gsub(/[\/\\]/, "/").gsub(/[\/\\]$/, "") + "/"
end
private
@@ -264,11 +264,11 @@ module FileTest
Audio_ext = ['.mid', '.midi', '.ogg', '.wav', '.wma'] # '.mp3'
def self.audio_exist?(filename)
return RTP.exists?(filename,Audio_ext)
return RTP.exists?(filename, Audio_ext)
end
def self.image_exist?(filename)
return RTP.exists?(filename,Image_ext)
return RTP.exists?(filename, Image_ext)
end
end
@@ -281,7 +281,7 @@ end
# and matching mount points added through System.mount
def pbRgssExists?(filename)
if safeExists?("./Game.rgssad")
return pbGetFileChar(filename)!=nil
return pbGetFileChar(filename) != nil
else
filename = canonicalize(filename)
return safeExists?(filename)
@@ -293,14 +293,14 @@ end
# NOTE: load_data checks anything added in MKXP's RTP setting,
# and matching mount points added through System.mount
def pbRgssOpen(file,mode = nil)
def pbRgssOpen(file, mode = nil)
# File.open("debug.txt","ab") { |fw| fw.write([file,mode,Time.now.to_f].inspect+"\r\n") }
if !safeExists?("./Game.rgssad")
if block_given?
File.open(file,mode) { |f| yield f }
File.open(file, mode) { |f| yield f }
return nil
else
return File.open(file,mode)
return File.open(file, mode)
end
end
file = canonicalize(file)
@@ -338,7 +338,7 @@ end
def pbTryString(x)
ret = pbGetFileChar(x)
return (ret!=nil && ret!="") ? x : nil
return (ret != nil && ret != "") ? x : nil
end
# Gets the contents of a file. Doesn't check RTP, but does check
@@ -351,7 +351,7 @@ def pbGetFileString(file)
if !safeExists?("./Game.rgssad")
return nil if !safeExists?(file)
begin
File.open(file,"rb") { |f| return f.read } # read all data
File.open(file, "rb") { |f| return f.read } # read all data
rescue Errno::ENOENT, Errno::EINVAL, Errno::EACCES
return nil
end
@@ -396,10 +396,10 @@ class StringInput
@lineno = 0
end
attr_reader :lineno,:string
attr_reader :lineno, :string
def inspect
return "#<#{self.class}:#{@closed ? 'closed' : 'open'},src=#{@string[0,30].inspect}>"
return "#<#{self.class}:#{@closed ? 'closed' : 'open'},src=#{@string[0, 30].inspect}>"
end
def close

View File

@@ -7,7 +7,7 @@ def pbPostData(url, postdata, filename = nil, depth = 0)
if url[/^http:\/\/([^\/]+)(.*)$/]
host = $1
path = $2
path = "/" if path.length==0
path = "/" if path.length == 0
userAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.14) Gecko/2009082707 Firefox/3.0.14"
body = postdata.map { |key, value|
keyString = key.to_s
@@ -63,7 +63,7 @@ end
def pbDownloadToFile(url, file)
begin
pbDownloadData(url,file)
pbDownloadData(url, file)
rescue
end
end
@@ -79,7 +79,7 @@ end
def pbPostToFile(url, postdata, file)
begin
pbPostData(url, postdata,file)
pbPostData(url, postdata, file)
rescue
end
end

View File

@@ -89,7 +89,7 @@ end
#===============================================================================
class Array
def ^(other) # xor of two arrays
return (self|other) - (self&other)
return (self | other) - (self & other)
end
def swap(val1, val2)

View File

@@ -1,20 +1,20 @@
def pbAddScriptTexts(items,script)
def pbAddScriptTexts(items, script)
script.scan(/(?:_I)\s*\(\s*\"((?:[^\\\"]*\\\"?)*[^\"]*)\"/) { |s|
string=s[0]
string.gsub!(/\\\"/,"\"")
string.gsub!(/\\\\/,"\\")
string = s[0]
string.gsub!(/\\\"/, "\"")
string.gsub!(/\\\\/, "\\")
items.push(string)
}
end
def pbAddRgssScriptTexts(items,script)
def pbAddRgssScriptTexts(items, script)
script.scan(/(?:_INTL|_ISPRINTF)\s*\(\s*\"((?:[^\\\"]*\\\"?)*[^\"]*)\"/) { |s|
string=s[0]
string.gsub!(/\\r/,"\r")
string.gsub!(/\\n/,"\n")
string.gsub!(/\\1/,"\1")
string.gsub!(/\\\"/,"\"")
string.gsub!(/\\\\/,"\\")
string = s[0]
string.gsub!(/\\r/, "\r")
string.gsub!(/\\n/, "\n")
string.gsub!(/\\1/, "\1")
string.gsub!(/\\\"/, "\"")
string.gsub!(/\\\\/, "\\")
items.push(string)
}
end
@@ -23,14 +23,14 @@ def pbSetTextMessages
Graphics.update
begin
t = Time.now.to_i
texts=[]
texts = []
for script in $RGSS_SCRIPTS
if Time.now.to_i - t >= 5
t = Time.now.to_i
Graphics.update
end
scr=Zlib::Inflate.inflate(script[2])
pbAddRgssScriptTexts(texts,scr)
scr = Zlib::Inflate.inflate(script[2])
pbAddRgssScriptTexts(texts, scr)
end
if safeExists?("Data/PluginScripts.rxdata")
plugin_scripts = load_data("Data/PluginScripts.rxdata")
@@ -41,62 +41,62 @@ def pbSetTextMessages
Graphics.update
end
scr = Zlib::Inflate.inflate(script[1]).force_encoding(Encoding::UTF_8)
pbAddRgssScriptTexts(texts,scr)
pbAddRgssScriptTexts(texts, scr)
end
end
end
# Must add messages because this code is used by both game system and Editor
MessageTypes.addMessagesAsHash(MessageTypes::ScriptTexts,texts)
MessageTypes.addMessagesAsHash(MessageTypes::ScriptTexts, texts)
commonevents = load_data("Data/CommonEvents.rxdata")
items=[]
choices=[]
items = []
choices = []
for event in commonevents.compact
if Time.now.to_i - t >= 5
t = Time.now.to_i
Graphics.update
end
begin
neednewline=false
lastitem=""
neednewline = false
lastitem = ""
for j in 0...event.list.size
list = event.list[j]
if neednewline && list.code!=401
if lastitem!=""
lastitem.gsub!(/([^\.\!\?])\s\s+/) { |m| $1+" " }
if neednewline && list.code != 401
if lastitem != ""
lastitem.gsub!(/([^\.\!\?])\s\s+/) { |m| $1 + " " }
items.push(lastitem)
lastitem=""
lastitem = ""
end
neednewline=false
neednewline = false
end
if list.code == 101
lastitem+="#{list.parameters[0]}"
neednewline=true
lastitem += "#{list.parameters[0]}"
neednewline = true
elsif list.code == 102
for k in 0...list.parameters[0].length
choices.push(list.parameters[0][k])
end
neednewline=false
neednewline = false
elsif list.code == 401
lastitem+=" " if lastitem!=""
lastitem+="#{list.parameters[0]}"
neednewline=true
lastitem += " " if lastitem != ""
lastitem += "#{list.parameters[0]}"
neednewline = true
elsif list.code == 355 || list.code == 655
pbAddScriptTexts(items,list.parameters[0])
elsif list.code == 111 && list.parameters[0]==12
pbAddScriptTexts(items,list.parameters[1])
pbAddScriptTexts(items, list.parameters[0])
elsif list.code == 111 && list.parameters[0] == 12
pbAddScriptTexts(items, list.parameters[1])
elsif list.code == 209
route=list.parameters[1]
route = list.parameters[1]
for k in 0...route.list.size
if route.list[k].code == 45
pbAddScriptTexts(items,route.list[k].parameters[0])
pbAddScriptTexts(items, route.list[k].parameters[0])
end
end
end
end
if neednewline
if lastitem!=""
if lastitem != ""
items.push(lastitem)
lastitem=""
lastitem = ""
end
end
end
@@ -105,21 +105,21 @@ def pbSetTextMessages
t = Time.now.to_i
Graphics.update
end
items|=[]
choices|=[]
items |= []
choices |= []
items.concat(choices)
MessageTypes.setMapMessagesAsHash(0,items)
MessageTypes.setMapMessagesAsHash(0, items)
mapinfos = pbLoadMapInfos
for id in mapinfos.keys
if Time.now.to_i - t >= 5
t = Time.now.to_i
Graphics.update
end
filename=sprintf("Data/Map%03d.rxdata",id)
filename = sprintf("Data/Map%03d.rxdata", id)
next if !pbRgssExists?(filename)
map = load_data(filename)
items=[]
choices=[]
items = []
choices = []
for event in map.events.values
if Time.now.to_i - t >= 5
t = Time.now.to_i
@@ -127,47 +127,47 @@ def pbSetTextMessages
end
begin
for i in 0...event.pages.size
neednewline=false
lastitem=""
neednewline = false
lastitem = ""
for j in 0...event.pages[i].list.size
list = event.pages[i].list[j]
if neednewline && list.code!=401
if lastitem!=""
lastitem.gsub!(/([^\.\!\?])\s\s+/) { |m| $1+" " }
if neednewline && list.code != 401
if lastitem != ""
lastitem.gsub!(/([^\.\!\?])\s\s+/) { |m| $1 + " " }
items.push(lastitem)
lastitem=""
lastitem = ""
end
neednewline=false
neednewline = false
end
if list.code == 101
lastitem+="#{list.parameters[0]}"
neednewline=true
lastitem += "#{list.parameters[0]}"
neednewline = true
elsif list.code == 102
for k in 0...list.parameters[0].length
choices.push(list.parameters[0][k])
end
neednewline=false
neednewline = false
elsif list.code == 401
lastitem+=" " if lastitem!=""
lastitem+="#{list.parameters[0]}"
neednewline=true
elsif list.code == 355 || list.code==655
pbAddScriptTexts(items,list.parameters[0])
elsif list.code == 111 && list.parameters[0]==12
pbAddScriptTexts(items,list.parameters[1])
elsif list.code==209
route=list.parameters[1]
lastitem += " " if lastitem != ""
lastitem += "#{list.parameters[0]}"
neednewline = true
elsif list.code == 355 || list.code == 655
pbAddScriptTexts(items, list.parameters[0])
elsif list.code == 111 && list.parameters[0] == 12
pbAddScriptTexts(items, list.parameters[1])
elsif list.code == 209
route = list.parameters[1]
for k in 0...route.list.size
if route.list[k].code==45
pbAddScriptTexts(items,route.list[k].parameters[0])
if route.list[k].code == 45
pbAddScriptTexts(items, route.list[k].parameters[0])
end
end
end
end
if neednewline
if lastitem!=""
if lastitem != ""
items.push(lastitem)
lastitem=""
lastitem = ""
end
end
end
@@ -177,10 +177,10 @@ def pbSetTextMessages
t = Time.now.to_i
Graphics.update
end
items|=[]
choices|=[]
items |= []
choices |= []
items.concat(choices)
MessageTypes.setMapMessagesAsHash(id,items)
MessageTypes.setMapMessagesAsHash(id, items)
if Time.now.to_i - t >= 5
t = Time.now.to_i
Graphics.update
@@ -192,92 +192,92 @@ def pbSetTextMessages
end
def pbEachIntlSection(file)
lineno=1
re=/^\s*\[\s*([^\]]+)\s*\]\s*$/
havesection=false
sectionname=nil
lastsection=[]
lineno = 1
re = /^\s*\[\s*([^\]]+)\s*\]\s*$/
havesection = false
sectionname = nil
lastsection = []
file.each_line { |line|
if lineno==1 && line[0].ord==0xEF && line[1].ord==0xBB && line[2].ord==0xBF
line=line[3,line.length-3]
if lineno == 1 && line[0].ord == 0xEF && line[1].ord == 0xBB && line[2].ord == 0xBF
line = line[3, line.length - 3]
end
if !line[/^\#/] && !line[/^\s*$/]
if line[re]
if havesection
yield lastsection,sectionname
yield lastsection, sectionname
end
lastsection.clear
sectionname=$~[1]
havesection=true
sectionname = $~[1]
havesection = true
else
if sectionname==nil
raise _INTL("Expected a section at the beginning of the file (line {1})",lineno)
if sectionname == nil
raise _INTL("Expected a section at the beginning of the file (line {1})", lineno)
end
lastsection.push(line.gsub(/\s+$/,""))
lastsection.push(line.gsub(/\s+$/, ""))
end
end
lineno+=1
if lineno%500==0
lineno += 1
if lineno % 500 == 0
Graphics.update
end
}
if havesection
yield lastsection,sectionname
yield lastsection, sectionname
end
end
def pbGetText(infile)
begin
file=File.open(infile,"rb")
file = File.open(infile, "rb")
rescue
raise _INTL("Can't find {1}",infile)
raise _INTL("Can't find {1}", infile)
end
intldat=[]
intldat = []
begin
pbEachIntlSection(file) { |section,name|
next if section.length==0
pbEachIntlSection(file) { |section, name|
next if section.length == 0
if !name[/^([Mm][Aa][Pp])?(\d+)$/]
raise _INTL("Invalid section name {1}",name)
raise _INTL("Invalid section name {1}", name)
end
ismap=$~[1] && $~[1]!=""
id=$~[2].to_i
itemlength=0
ismap = $~[1] && $~[1] != ""
id = $~[2].to_i
itemlength = 0
if section[0][/^\d+$/]
intlhash=[]
itemlength=3
intlhash = []
itemlength = 3
if ismap
raise _INTL("Section {1} can't be an ordered list (section was recognized as an ordered list because its first line is a number)",name)
raise _INTL("Section {1} can't be an ordered list (section was recognized as an ordered list because its first line is a number)", name)
end
if section.length%3!=0
raise _INTL("Section {1}'s line count is not divisible by 3 (section was recognized as an ordered list because its first line is a number)",name)
if section.length % 3 != 0
raise _INTL("Section {1}'s line count is not divisible by 3 (section was recognized as an ordered list because its first line is a number)", name)
end
else
intlhash=OrderedHash.new
itemlength=2
if section.length%2!=0
raise _INTL("Section {1} has an odd number of entries (section was recognized as a hash because its first line is not a number)",name)
intlhash = OrderedHash.new
itemlength = 2
if section.length % 2 != 0
raise _INTL("Section {1} has an odd number of entries (section was recognized as a hash because its first line is not a number)", name)
end
end
i=0
i = 0
loop do
break unless i < section.length
if itemlength==3
if itemlength == 3
if !section[i][/^\d+$/]
raise _INTL("Expected a number in section {1}, got {2} instead",name,section[i])
raise _INTL("Expected a number in section {1}, got {2} instead", name, section[i])
end
key=section[i].to_i
i+=1
key = section[i].to_i
i += 1
else
key=MessageTypes.denormalizeValue(section[i])
key = MessageTypes.denormalizeValue(section[i])
end
intlhash[key]=MessageTypes.denormalizeValue(section[i+1])
i+=2
intlhash[key] = MessageTypes.denormalizeValue(section[i + 1])
i += 2
end
if ismap
intldat[0]=[] if !intldat[0]
intldat[0][id]=intlhash
intldat[0] = [] if !intldat[0]
intldat[0][id] = intlhash
else
intldat[id]=intlhash
intldat[id] = intlhash
end
}
ensure
@@ -287,10 +287,10 @@ def pbGetText(infile)
end
def pbCompileText
outfile=File.open("intl.dat","wb")
outfile = File.open("intl.dat", "wb")
begin
intldat=pbGetText("intl.txt")
Marshal.dump(intldat,outfile)
intldat = pbGetText("intl.txt")
Marshal.dump(intldat, outfile)
rescue
raise
ensure
@@ -302,7 +302,7 @@ end
class OrderedHash < Hash
def initialize
@keys=[]
@keys = []
super
end
@@ -311,54 +311,54 @@ class OrderedHash < Hash
end
def inspect
str="{"
str = "{"
for i in 0...@keys.length
str+=", " if i>0
str+=@keys[i].inspect+"=>"+self[@keys[i]].inspect
str += ", " if i > 0
str += @keys[i].inspect + "=>" + self[@keys[i]].inspect
end
str+="}"
str += "}"
return str
end
alias :to_s :inspect
def []=(key,value)
oldvalue=self[key]
def []=(key, value)
oldvalue = self[key]
if !oldvalue && value
@keys.push(key)
elsif !value
@keys|=[]
@keys-=[key]
@keys |= []
@keys -= [key]
end
return super(key,value)
return super(key, value)
end
def self._load(string)
ret=self.new
keysvalues=Marshal.load(string)
keys=keysvalues[0]
values=keysvalues[1]
ret = self.new
keysvalues = Marshal.load(string)
keys = keysvalues[0]
values = keysvalues[1]
for i in 0...keys.length
ret[keys[i]]=values[i]
ret[keys[i]] = values[i]
end
return ret
end
def _dump(_depth = 100)
values=[]
values = []
for key in @keys
values.push(self[key])
end
return Marshal.dump([@keys,values])
return Marshal.dump([@keys, values])
end
end
class Messages
def initialize(filename = nil,delayLoad = false)
@messages=nil
@filename=filename
def initialize(filename = nil, delayLoad = false)
@messages = nil
@filename = filename
if @filename && !delayLoad
loadMessageFile(@filename)
end
@@ -367,7 +367,7 @@ class Messages
def delayedLoad
if @filename && !@messages
loadMessageFile(@filename)
@filename=nil
@filename = nil
end
end
@@ -384,13 +384,13 @@ class Messages
def self.normalizeValue(value)
if value[/[\r\n\t\x01]|^[\[\]]/]
ret=value.clone
ret.gsub!(/\r/,"<<r>>")
ret.gsub!(/\n/,"<<n>>")
ret.gsub!(/\t/,"<<t>>")
ret.gsub!(/\[/,"<<[>>")
ret.gsub!(/\]/,"<<]>>")
ret.gsub!(/\x01/,"<<1>>")
ret = value.clone
ret.gsub!(/\r/, "<<r>>")
ret.gsub!(/\n/, "<<n>>")
ret.gsub!(/\t/, "<<t>>")
ret.gsub!(/\[/, "<<[>>")
ret.gsub!(/\]/, "<<]>>")
ret.gsub!(/\x01/, "<<1>>")
return ret
end
return value
@@ -398,45 +398,45 @@ class Messages
def self.denormalizeValue(value)
if value[/<<[rnt1\[\]]>>/]
ret=value.clone
ret.gsub!(/<<1>>/,"\1")
ret.gsub!(/<<r>>/,"\r")
ret.gsub!(/<<n>>/,"\n")
ret.gsub!(/<<\[>>/,"[")
ret.gsub!(/<<\]>>/,"]")
ret.gsub!(/<<t>>/,"\t")
ret = value.clone
ret.gsub!(/<<1>>/, "\1")
ret.gsub!(/<<r>>/, "\r")
ret.gsub!(/<<n>>/, "\n")
ret.gsub!(/<<\[>>/, "[")
ret.gsub!(/<<\]>>/, "]")
ret.gsub!(/<<t>>/, "\t")
return ret
end
return value
end
def self.writeObject(f,msgs,secname,origMessages = nil)
def self.writeObject(f, msgs, secname, origMessages = nil)
return if !msgs
if msgs.is_a?(Array)
f.write("[#{secname}]\r\n")
for j in 0...msgs.length
next if nil_or_empty?(msgs[j])
value=Messages.normalizeValue(msgs[j])
origValue=""
value = Messages.normalizeValue(msgs[j])
origValue = ""
if origMessages
origValue=Messages.normalizeValue(origMessages.get(secname,j))
origValue = Messages.normalizeValue(origMessages.get(secname, j))
else
origValue=Messages.normalizeValue(MessageTypes.get(secname,j))
origValue = Messages.normalizeValue(MessageTypes.get(secname, j))
end
f.write("#{j}\r\n")
f.write(origValue+"\r\n")
f.write(value+"\r\n")
f.write(origValue + "\r\n")
f.write(value + "\r\n")
end
elsif msgs.is_a?(OrderedHash)
f.write("[#{secname}]\r\n")
keys=msgs.keys
keys = msgs.keys
for key in keys
next if nil_or_empty?(msgs[key])
value=Messages.normalizeValue(msgs[key])
valkey=Messages.normalizeValue(key)
value = Messages.normalizeValue(msgs[key])
valkey = Messages.normalizeValue(key)
# key is already serialized
f.write(valkey+"\r\n")
f.write(value+"\r\n")
f.write(valkey + "\r\n")
f.write(value + "\r\n")
end
end
end
@@ -447,8 +447,8 @@ class Messages
def extract(outfile)
# return if !@messages
origMessages=Messages.new("Data/messages.dat")
File.open(outfile,"wb") { |f|
origMessages = Messages.new("Data/messages.dat")
File.open(outfile, "wb") { |f|
f.write(0xef.chr)
f.write(0xbb.chr)
f.write(0xbf.chr)
@@ -456,103 +456,103 @@ class Messages
f.write("# translate every second line of this file.\r\n")
if origMessages.messages[0]
for i in 0...origMessages.messages[0].length
msgs=origMessages.messages[0][i]
Messages.writeObject(f,msgs,"Map#{i}",origMessages)
msgs = origMessages.messages[0][i]
Messages.writeObject(f, msgs, "Map#{i}", origMessages)
end
end
for i in 1...origMessages.messages.length
msgs=origMessages.messages[i]
Messages.writeObject(f,msgs,i,origMessages)
msgs = origMessages.messages[i]
Messages.writeObject(f, msgs, i, origMessages)
end
}
end
def setMessages(type,array)
@messages=[] if !@messages
arr=[]
def setMessages(type, array)
@messages = [] if !@messages
arr = []
for i in 0...array.length
arr[i]=(array[i]) ? array[i] : ""
arr[i] = (array[i]) ? array[i] : ""
end
@messages[type]=arr
@messages[type] = arr
end
def addMessages(type,array)
@messages=[] if !@messages
arr=(@messages[type]) ? @messages[type] : []
def addMessages(type, array)
@messages = [] if !@messages
arr = (@messages[type]) ? @messages[type] : []
for i in 0...array.length
arr[i]=(array[i]) ? array[i] : (arr[i]) ? arr[i] : ""
arr[i] = (array[i]) ? array[i] : (arr[i]) ? arr[i] : ""
end
@messages[type]=arr
@messages[type] = arr
end
def self.createHash(_type,array)
arr=OrderedHash.new
def self.createHash(_type, array)
arr = OrderedHash.new
for i in 0...array.length
if array[i]
key=Messages.stringToKey(array[i])
arr[key]=array[i]
key = Messages.stringToKey(array[i])
arr[key] = array[i]
end
end
return arr
end
def self.addToHash(_type,array,hash)
hash=OrderedHash.new if !hash
def self.addToHash(_type, array, hash)
hash = OrderedHash.new if !hash
for i in 0...array.length
if array[i]
key=Messages.stringToKey(array[i])
hash[key]=array[i]
key = Messages.stringToKey(array[i])
hash[key] = array[i]
end
end
return hash
end
def setMapMessagesAsHash(type,array)
@messages=[] if !@messages
@messages[0]=[] if !@messages[0]
@messages[0][type]=Messages.createHash(type,array)
def setMapMessagesAsHash(type, array)
@messages = [] if !@messages
@messages[0] = [] if !@messages[0]
@messages[0][type] = Messages.createHash(type, array)
end
def addMapMessagesAsHash(type,array)
@messages=[] if !@messages
@messages[0]=[] if !@messages[0]
@messages[0][type]=Messages.addToHash(type,array,@messages[0][type])
def addMapMessagesAsHash(type, array)
@messages = [] if !@messages
@messages[0] = [] if !@messages[0]
@messages[0][type] = Messages.addToHash(type, array, @messages[0][type])
end
def setMessagesAsHash(type,array)
@messages=[] if !@messages
@messages[type]=Messages.createHash(type,array)
def setMessagesAsHash(type, array)
@messages = [] if !@messages
@messages[type] = Messages.createHash(type, array)
end
def addMessagesAsHash(type,array)
@messages=[] if !@messages
@messages[type]=Messages.addToHash(type,array,@messages[type])
def addMessagesAsHash(type, array)
@messages = [] if !@messages
@messages[type] = Messages.addToHash(type, array, @messages[type])
end
def saveMessages(filename = nil)
filename="Data/messages.dat" if !filename
File.open(filename,"wb") { |f| Marshal.dump(@messages,f) }
filename = "Data/messages.dat" if !filename
File.open(filename, "wb") { |f| Marshal.dump(@messages, f) }
end
def loadMessageFile(filename)
begin
pbRgssOpen(filename,"rb") { |f| @messages=Marshal.load(f) }
pbRgssOpen(filename, "rb") { |f| @messages = Marshal.load(f) }
if !@messages.is_a?(Array)
@messages=nil
@messages = nil
raise "Corrupted data"
end
return @messages
rescue
@messages=nil
@messages = nil
return nil
end
end
def set(type,id,value)
def set(type, id, value)
delayedLoad
return if !@messages
return if !@messages[type]
@messages[type][id]=value
@messages[type][id] = value
end
def getCount(type)
@@ -562,7 +562,7 @@ class Messages
return @messages[type].length
end
def get(type,id)
def get(type, id)
delayedLoad
return "" if !@messages
return "" if !@messages[type]
@@ -570,21 +570,21 @@ class Messages
return @messages[type][id]
end
def getFromHash(type,key)
def getFromHash(type, key)
delayedLoad
return key if !@messages || !@messages[type] || !key
id=Messages.stringToKey(key)
id = Messages.stringToKey(key)
return key if !@messages[type][id]
return @messages[type][id]
end
def getFromMapHash(type,key)
def getFromMapHash(type, key)
delayedLoad
return key if !@messages
return key if !@messages[0]
return key if !@messages[0][type] && !@messages[0][0]
id=Messages.stringToKey(key)
if @messages[0][type] && @messages[0][type][id]
id = Messages.stringToKey(key)
if @messages[0][type] && @messages[0][type][id]
return @messages[0][type][id]
elsif @messages[0][0] && @messages[0][0][id]
return @messages[0][0][id]
@@ -625,7 +625,7 @@ module MessageTypes
RibbonDescriptions = 26
StorageCreator = 27
@@messages = Messages.new
@@messagesFallback = Messages.new("Data/messages.dat",true)
@@messagesFallback = Messages.new("Data/messages.dat", true)
def self.stringToKey(str)
return Messages.stringToKey(str)
@@ -639,7 +639,7 @@ module MessageTypes
Messages.denormalizeValue(value)
end
def self.writeObject(f,msgs,secname)
def self.writeObject(f, msgs, secname)
Messages.denormalizeValue(str)
end
@@ -647,32 +647,32 @@ module MessageTypes
@@messages.extract(outfile)
end
def self.setMessages(type,array)
@@messages.setMessages(type,array)
def self.setMessages(type, array)
@@messages.setMessages(type, array)
end
def self.addMessages(type,array)
@@messages.addMessages(type,array)
def self.addMessages(type, array)
@@messages.addMessages(type, array)
end
def self.createHash(type,array)
Messages.createHash(type,array)
def self.createHash(type, array)
Messages.createHash(type, array)
end
def self.addMapMessagesAsHash(type,array)
@@messages.addMapMessagesAsHash(type,array)
def self.addMapMessagesAsHash(type, array)
@@messages.addMapMessagesAsHash(type, array)
end
def self.setMapMessagesAsHash(type,array)
@@messages.setMapMessagesAsHash(type,array)
def self.setMapMessagesAsHash(type, array)
@@messages.setMapMessagesAsHash(type, array)
end
def self.addMessagesAsHash(type,array)
@@messages.addMessagesAsHash(type,array)
def self.addMessagesAsHash(type, array)
@@messages.addMessagesAsHash(type, array)
end
def self.setMessagesAsHash(type,array)
@@messages.setMessagesAsHash(type,array)
def self.setMessagesAsHash(type, array)
@@messages.setMessagesAsHash(type, array)
end
def self.saveMessages(filename = nil)
@@ -683,30 +683,30 @@ module MessageTypes
@@messages.loadMessageFile(filename)
end
def self.get(type,id)
ret=@@messages.get(type,id)
if ret==""
ret=@@messagesFallback.get(type,id)
def self.get(type, id)
ret = @@messages.get(type, id)
if ret == ""
ret = @@messagesFallback.get(type, id)
end
return ret
end
def self.getCount(type)
c1=@@messages.getCount(type)
c2=@@messagesFallback.getCount(type)
return c1>c2 ? c1 : c2
c1 = @@messages.getCount(type)
c2 = @@messagesFallback.getCount(type)
return c1 > c2 ? c1 : c2
end
def self.getOriginal(type,id)
return @@messagesFallback.get(type,id)
def self.getOriginal(type, id)
return @@messagesFallback.get(type, id)
end
def self.getFromHash(type,key)
@@messages.getFromHash(type,key)
def self.getFromHash(type, key)
@@messages.getFromHash(type, key)
end
def self.getFromMapHash(type,key)
@@messages.getFromMapHash(type,key)
def self.getFromMapHash(type, key)
@@messages.getFromMapHash(type, key)
end
end
@@ -720,25 +720,25 @@ def pbGetMessageCount(type)
return MessageTypes.getCount(type)
end
def pbGetMessage(type,id)
return MessageTypes.get(type,id)
def pbGetMessage(type, id)
return MessageTypes.get(type, id)
end
def pbGetMessageFromHash(type,id)
return MessageTypes.getFromHash(type,id)
def pbGetMessageFromHash(type, id)
return MessageTypes.getFromHash(type, id)
end
# Replaces first argument with a localized version and formats the other
# parameters by replacing {1}, {2}, etc. with those placeholders.
def _INTL(*arg)
begin
string=MessageTypes.getFromHash(MessageTypes::ScriptTexts,arg[0])
string = MessageTypes.getFromHash(MessageTypes::ScriptTexts, arg[0])
rescue
string=arg[0]
string = arg[0]
end
string=string.clone
string = string.clone
for i in 1...arg.length
string.gsub!(/\{#{i}\}/,"#{arg[i]}")
string.gsub!(/\{#{i}\}/, "#{arg[i]}")
end
return string
end
@@ -748,38 +748,38 @@ end
# This version acts more like sprintf, supports e.g. {1:d} or {2:s}
def _ISPRINTF(*arg)
begin
string=MessageTypes.getFromHash(MessageTypes::ScriptTexts,arg[0])
string = MessageTypes.getFromHash(MessageTypes::ScriptTexts, arg[0])
rescue
string=arg[0]
string = arg[0]
end
string=string.clone
string = string.clone
for i in 1...arg.length
string.gsub!(/\{#{i}\:([^\}]+?)\}/) { |m|
next sprintf("%"+$1,arg[i])
next sprintf("%" + $1, arg[i])
}
end
return string
end
def _I(str)
return _MAPINTL($game_map.map_id,str)
return _MAPINTL($game_map.map_id, str)
end
def _MAPINTL(mapid,*arg)
string=MessageTypes.getFromMapHash(mapid,arg[0])
string=string.clone
def _MAPINTL(mapid, *arg)
string = MessageTypes.getFromMapHash(mapid, arg[0])
string = string.clone
for i in 1...arg.length
string.gsub!(/\{#{i}\}/,"#{arg[i]}")
string.gsub!(/\{#{i}\}/, "#{arg[i]}")
end
return string
end
def _MAPISPRINTF(mapid,*arg)
string=MessageTypes.getFromMapHash(mapid,arg[0])
string=string.clone
def _MAPISPRINTF(mapid, *arg)
string = MessageTypes.getFromMapHash(mapid, arg[0])
string = string.clone
for i in 1...arg.length
string.gsub!(/\{#{i}\:([^\}]+?)\}/) { |m|
next sprintf("%"+$1,arg[i])
next sprintf("%" + $1, arg[i])
}
end
return string

View File

@@ -588,7 +588,7 @@ module PluginManager
optional = false
# clean the name to a simple string
if dname.is_a?(Array)
optional = [:optional,:optional_exact].include?(dname[0])
optional = [:optional, :optional_exact].include?(dname[0])
dname = dname[dname.length - 2]
end
# catch missing dependency
@@ -710,7 +710,7 @@ module PluginManager
# get rid of tabs
code.gsub!("\t", " ")
# construct filename
sname = scr[0].gsub("\\","/").split("/")[-1]
sname = scr[0].gsub("\\", "/").split("/")[-1]
fname = "[#{name}] #{sname}"
# try to run the code
begin

View File

@@ -199,16 +199,16 @@ class SpriteAnimation
sprite.visible = false if sprite != nil
next
end
sprite.x = sprite_x + cell_data[i, 1]
sprite.y = sprite_y + cell_data[i, 2]
sprite.x = sprite_x + cell_data[i, 1]
sprite.y = sprite_y + cell_data[i, 2]
next if quick_update
sprite.visible = true
sprite.visible = true
sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
case @_animation_height
when 0 then sprite.z = 1
when 1 then sprite.z = sprite.y+32+15
when 2 then sprite.z = sprite.y+32+32+17
else sprite.z = 2000
when 0 then sprite.z = 1
when 1 then sprite.z = sprite.y + 32 + 15
when 2 then sprite.z = sprite.y + 32 + 32 + 17
else sprite.z = 2000
end
sprite.ox = 96
sprite.oy = 96
@@ -299,9 +299,9 @@ module RPG
end
def whiten
self.blend_type = 0
self.blend_type = 0
self.color.set(255, 255, 255, 128)
self.opacity = 255
self.opacity = 255
@_whiten_duration = 16
@_appear_duration = 0
@_escape_duration = 0
@@ -345,10 +345,10 @@ module RPG
bitmap.font.name = "Arial Black"
bitmap.font.size = 32
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
bitmap.draw_text(-1, 12 - 1, 160, 36, damage_string, 1)
bitmap.draw_text(+1, 12 - 1, 160, 36, damage_string, 1)
bitmap.draw_text(-1, 12 + 1, 160, 36, damage_string, 1)
bitmap.draw_text(+1, 12 + 1, 160, 36, damage_string, 1)
if value.is_a?(Numeric) && value < 0
bitmap.font.color.set(176, 255, 144)
else
@@ -386,14 +386,14 @@ module RPG
def animation(animation, hit, height = 3)
anim = SpriteAnimation.new(self)
anim.animation(animation,hit,height)
pushAnimation(@animations,anim)
anim.animation(animation, hit, height)
pushAnimation(@animations, anim)
end
def loop_animation(animation)
anim = SpriteAnimation.new(self)
anim.loop_animation(animation)
pushAnimation(@loopAnimations,anim)
pushAnimation(@loopAnimations, anim)
end
def dispose_damage

View File

@@ -10,7 +10,7 @@ class Scene_Map
def spriteset(map_id = -1)
return @spritesets[map_id] if map_id > 0 && @spritesets[map_id]
for i in @spritesets.values
return i if i.map==$game_map
return i if i.map == $game_map
end
return @spritesets.values[0]
end
@@ -56,13 +56,13 @@ class Scene_Map
map = load_data(sprintf("Data/Map%03d.rxdata", mapid))
if playingBGM && map.autoplay_bgm
if (PBDayNight.isNight? rescue false)
pbBGMFade(0.8) if playingBGM.name!=map.bgm.name && playingBGM.name!=map.bgm.name+"_n"
pbBGMFade(0.8) if playingBGM.name != map.bgm.name && playingBGM.name != map.bgm.name + "_n"
else
pbBGMFade(0.8) if playingBGM.name!=map.bgm.name
pbBGMFade(0.8) if playingBGM.name != map.bgm.name
end
end
if playingBGS && map.autoplay_bgs
pbBGMFade(0.8) if playingBGS.name!=map.bgs.name
pbBGMFade(0.8) if playingBGS.name != map.bgs.name
end
Graphics.frame_reset
end
@@ -73,7 +73,7 @@ class Scene_Map
autofade($game_temp.player_new_map_id)
pbBridgeOff
@spritesetGlobal.playersprite.clearShadows
if $game_map.map_id!=$game_temp.player_new_map_id
if $game_map.map_id != $game_temp.player_new_map_id
$map_factory.setup($game_temp.player_new_map_id)
end
$game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y)

View File

@@ -1034,7 +1034,7 @@ class Interpreter
# Look for more script commands or a continuation of one, and add them to script
loop do
break if ![355, 655].include?(@list[@index + 1].code)
script += @list[@index+1].parameters[0] + "\n"
script += @list[@index + 1].parameters[0] + "\n"
@index += 1
end
# Run the script

View File

@@ -38,13 +38,13 @@ class Event
# proc { |sender,params| } where params is an array of the other parameters, and
# proc { |sender,arg0,arg1,...| }
def trigger(*arg)
arglist = arg[1,arg.length]
arglist = arg[1, arg.length]
for callback in @callbacks
if callback.arity>2 && arg.length==callback.arity
if callback.arity > 2 && arg.length == callback.arity
# Retrofitted for callbacks that take three or more arguments
callback.call(*arg)
else
callback.call(arg[0],arglist)
callback.call(arg[0], arglist)
end
end
end
@@ -84,7 +84,7 @@ class HandlerHash
mod = Object.const_get(@mod) rescue nil
return nil if !mod
for key in mod.constants
next if mod.const_get(key)!=sym
next if mod.const_get(key) != sym
ret = key.to_sym
@symbolCache[sym] = ret
break
@@ -92,15 +92,15 @@ class HandlerHash
return ret
end
def addIf(conditionProc,handler = nil,&handlerBlock)
if ![Proc,Hash].include?(handler.class) && !block_given?
def addIf(conditionProc, handler = nil, &handlerBlock)
if ![Proc, Hash].include?(handler.class) && !block_given?
raise ArgumentError, "addIf call for #{self.class.name} has no valid handler (#{handler.inspect} was given)"
end
@addIfs.push([conditionProc,handler || handlerBlock])
@addIfs.push([conditionProc, handler || handlerBlock])
end
def add(sym,handler = nil,&handlerBlock) # 'sym' can be an ID or symbol
if ![Proc,Hash].include?(handler.class) && !block_given?
def add(sym, handler = nil, &handlerBlock) # 'sym' can be an ID or symbol
if ![Proc, Hash].include?(handler.class) && !block_given?
raise ArgumentError, "#{self.class.name} for #{sym.inspect} has no valid handler (#{handler.inspect} was given)"
end
id = fromSymbol(sym)
@@ -109,11 +109,11 @@ class HandlerHash
@hash[symbol] = handler || handlerBlock if symbol
end
def copy(src,*dests)
def copy(src, *dests)
handler = self[src]
if handler
for dest in dests
self.add(dest,handler)
self.add(dest, handler)
end
end
end
@@ -132,9 +132,9 @@ class HandlerHash
return ret
end
def trigger(sym,*args)
def trigger(sym, *args)
handler = self[sym]
return (handler) ? handler.call(fromSymbol(sym),*args) : nil
return (handler) ? handler.call(fromSymbol(sym), *args) : nil
end
def clear
@@ -221,7 +221,7 @@ class HandlerHashBasic
end
def add(entry, handler = nil, &handlerBlock)
if ![Proc,Hash].include?(handler.class) && !block_given?
if ![Proc, Hash].include?(handler.class) && !block_given?
raise ArgumentError, "#{self.class.name} for #{entry.inspect} has no valid handler (#{handler.inspect} was given)"
end
return if !entry || entry.empty?

View File

@@ -136,8 +136,8 @@ end
#===============================================================================
#
#===============================================================================
def pbOnSpritesetCreate(spriteset,viewport)
Events.onSpritesetCreate.trigger(nil,spriteset,viewport)
def pbOnSpritesetCreate(spriteset, viewport)
Events.onSpritesetCreate.trigger(nil, spriteset, viewport)
end
#===============================================================================

View File

@@ -90,39 +90,39 @@ class Game_Screen
# * Frame Update
#-----------------------------------------------------------------------------
def update
if @fadeout_duration && @fadeout_duration>=1
if @fadeout_duration && @fadeout_duration >= 1
d = @fadeout_duration
@brightness = (@brightness*(d-1))/d
@brightness = (@brightness * (d - 1)) / d
@fadeout_duration -= 1
end
if @fadein_duration && @fadein_duration>=1
if @fadein_duration && @fadein_duration >= 1
d = @fadein_duration
@brightness = (@brightness*(d-1)+255)/d
@brightness = (@brightness * (d - 1) + 255) / d
@fadein_duration -= 1
end
if @tone_duration>=1
if @tone_duration >= 1
d = @tone_duration
@tone.red = (@tone.red*(d-1)+@tone_target.red)/d
@tone.green = (@tone.green*(d-1)+@tone_target.green)/d
@tone.blue = (@tone.blue*(d-1)+@tone_target.blue)/d
@tone.gray = (@tone.gray*(d-1)+@tone_target.gray)/d
@tone.red = (@tone.red * (d - 1) + @tone_target.red) / d
@tone.green = (@tone.green * (d - 1) + @tone_target.green) / d
@tone.blue = (@tone.blue * (d - 1) + @tone_target.blue) / d
@tone.gray = (@tone.gray * (d - 1) + @tone_target.gray) / d
@tone_duration -= 1
end
if @flash_duration>=1
if @flash_duration >= 1
d = @flash_duration
@flash_color.alpha = @flash_color.alpha*(d-1)/d
@flash_color.alpha = @flash_color.alpha * (d - 1) / d
@flash_duration -= 1
end
if @shake_duration>=1 || @shake!=0
delta = (@shake_power*@shake_speed*@shake_direction)/10.0
if @shake_duration<=1 && @shake*(@shake+delta)<0
if @shake_duration >= 1 || @shake != 0
delta = (@shake_power * @shake_speed * @shake_direction) / 10.0
if @shake_duration <= 1 && @shake * (@shake + delta) < 0
@shake = 0
else
@shake += delta
end
@shake_direction = -1 if @shake>@shake_power*2
@shake_direction = 1 if @shake<-@shake_power*2
@shake_duration -= 1 if @shake_duration>=1
@shake_direction = -1 if @shake > @shake_power * 2
@shake_direction = 1 if @shake < -@shake_power * 2
@shake_duration -= 1 if @shake_duration >= 1
end
if $game_temp.in_battle
for i in 51..100
@@ -139,17 +139,17 @@ end
#===============================================================================
#
#===============================================================================
def pbToneChangeAll(tone,duration)
$game_screen.start_tone_change(tone,duration*Graphics.frame_rate/20)
def pbToneChangeAll(tone, duration)
$game_screen.start_tone_change(tone, duration * Graphics.frame_rate / 20)
for picture in $game_screen.pictures
picture.start_tone_change(tone,duration*Graphics.frame_rate/20) if picture
picture.start_tone_change(tone, duration * Graphics.frame_rate / 20) if picture
end
end
def pbShake(power,speed,frames)
$game_screen.start_shake(power,speed,frames*Graphics.frame_rate/20)
def pbShake(power, speed, frames)
$game_screen.start_shake(power, speed, frames * Graphics.frame_rate / 20)
end
def pbFlash(color,frames)
$game_screen.start_flash(color,frames*Graphics.frame_rate/20)
def pbFlash(color, frames)
$game_screen.start_flash(color, frames * Graphics.frame_rate / 20)
end

View File

@@ -16,7 +16,7 @@ class Game_SelfSwitches
# key : key
#-----------------------------------------------------------------------------
def [](key)
return (@data[key]==true) ? true : false
return (@data[key] == true) ? true : false
end
#-----------------------------------------------------------------------------
# * Set Self Switch

View File

@@ -44,28 +44,28 @@ class Game_System
def bgm_play(bgm)
old_pos = @bgm_position
@bgm_position = 0
bgm_play_internal(bgm,0)
bgm_play_internal(bgm, 0)
@bgm_position = old_pos
end
def bgm_play_internal2(name,volume,pitch,position) # :nodoc:
def bgm_play_internal2(name, volume, pitch, position) # :nodoc:
vol = volume
vol *= $PokemonSystem.bgmvolume/100.0
vol *= $PokemonSystem.bgmvolume / 100.0
vol = vol.to_i
begin
Audio.bgm_play(name,vol,pitch,position)
Audio.bgm_play(name, vol, pitch, position)
rescue ArgumentError
Audio.bgm_play(name,vol,pitch)
Audio.bgm_play(name, vol, pitch)
end
end
def bgm_play_internal(bgm,position) # :nodoc:
def bgm_play_internal(bgm, position) # :nodoc:
@bgm_position = position if !@bgm_paused
@playing_bgm = (bgm==nil) ? nil : bgm.clone
if bgm!=nil && bgm.name!=""
if FileTest.audio_exist?("Audio/BGM/"+bgm.name)
bgm_play_internal2("Audio/BGM/"+bgm.name,
bgm.volume,bgm.pitch,@bgm_position) if !@defaultBGM
@playing_bgm = (bgm == nil) ? nil : bgm.clone
if bgm != nil && bgm.name != ""
if FileTest.audio_exist?("Audio/BGM/" + bgm.name)
bgm_play_internal2("Audio/BGM/" + bgm.name,
bgm.volume, bgm.pitch, @bgm_position) if !@defaultBGM
end
else
@bgm_position = position if !@bgm_paused
@@ -73,15 +73,15 @@ class Game_System
Audio.bgm_stop if !@defaultBGM
end
if @defaultBGM
bgm_play_internal2("Audio/BGM/"+@defaultBGM.name,
@defaultBGM.volume,@defaultBGM.pitch,@bgm_position)
bgm_play_internal2("Audio/BGM/" + @defaultBGM.name,
@defaultBGM.volume, @defaultBGM.pitch, @bgm_position)
end
Graphics.frame_reset
end
def bgm_pause(fadetime = 0.0) # :nodoc:
pos = Audio.bgm_pos rescue 0
self.bgm_fade(fadetime) if fadetime>0.0
self.bgm_fade(fadetime) if fadetime > 0.0
@bgm_position = pos
@bgm_paused = true
end
@@ -93,7 +93,7 @@ class Game_System
def bgm_resume(bgm) # :nodoc:
if @bgm_paused
self.bgm_play_internal(bgm,@bgm_position)
self.bgm_play_internal(bgm, @bgm_position)
@bgm_position = 0
@bgm_paused = false
end
@@ -108,7 +108,7 @@ class Game_System
def bgm_fade(time) # :nodoc:
@bgm_position = 0 if !@bgm_paused
@playing_bgm = nil
Audio.bgm_fade((time*1000).floor) if !@defaultBGM
Audio.bgm_fade((time * 1000).floor) if !@defaultBGM
end
def playing_bgm
@@ -130,9 +130,9 @@ class Game_System
return (@playing_bgm) ? @playing_bgm.clone : nil
end
def setDefaultBGM(bgm,volume = 80,pitch = 100)
bgm = RPG::AudioFile.new(bgm,volume,pitch) if bgm.is_a?(String)
if bgm!=nil && bgm.name!=""
def setDefaultBGM(bgm, volume = 80, pitch = 100)
bgm = RPG::AudioFile.new(bgm, volume, pitch) if bgm.is_a?(String)
if bgm != nil && bgm.name != ""
@defaultBGM = nil
self.bgm_play(bgm)
@defaultBGM = bgm.clone
@@ -146,12 +146,12 @@ class Game_System
def me_play(me)
me = RPG::AudioFile.new(me) if me.is_a?(String)
if me!=nil && me.name!=""
if FileTest.audio_exist?("Audio/ME/"+me.name)
if me != nil && me.name != ""
if FileTest.audio_exist?("Audio/ME/" + me.name)
vol = me.volume
vol *= $PokemonSystem.bgmvolume/100.0
vol *= $PokemonSystem.bgmvolume / 100.0
vol = vol.to_i
Audio.me_play("Audio/ME/"+me.name,vol,me.pitch)
Audio.me_play("Audio/ME/" + me.name, vol, me.pitch)
end
else
Audio.me_stop
@@ -162,13 +162,13 @@ class Game_System
################################################################################
def bgs_play(bgs)
@playing_bgs = (bgs==nil) ? nil : bgs.clone
if bgs!=nil && bgs.name!=""
if FileTest.audio_exist?("Audio/BGS/"+bgs.name)
@playing_bgs = (bgs == nil) ? nil : bgs.clone
if bgs != nil && bgs.name != ""
if FileTest.audio_exist?("Audio/BGS/" + bgs.name)
vol = bgs.volume
vol *= $PokemonSystem.sevolume/100.0
vol *= $PokemonSystem.sevolume / 100.0
vol = vol.to_i
Audio.bgs_play("Audio/BGS/"+bgs.name,vol,bgs.pitch)
Audio.bgs_play("Audio/BGS/" + bgs.name, vol, bgs.pitch)
end
else
@bgs_position = 0
@@ -179,7 +179,7 @@ class Game_System
end
def bgs_pause(fadetime = 0.0) # :nodoc:
if fadetime>0.0
if fadetime > 0.0
self.bgs_fade(fadetime)
else
self.bgs_stop
@@ -207,7 +207,7 @@ class Game_System
def bgs_fade(time)
@bgs_position = 0
@playing_bgs = nil
Audio.bgs_fade((time*1000).floor)
Audio.bgs_fade((time * 1000).floor)
end
def playing_bgs
@@ -230,11 +230,11 @@ class Game_System
def se_play(se)
se = RPG::AudioFile.new(se) if se.is_a?(String)
if se!=nil && se.name!="" && FileTest.audio_exist?("Audio/SE/"+se.name)
if se != nil && se.name != "" && FileTest.audio_exist?("Audio/SE/" + se.name)
vol = se.volume
vol *= $PokemonSystem.sevolume/100.0
vol *= $PokemonSystem.sevolume / 100.0
vol = vol.to_i
Audio.se_play("Audio/SE/"+se.name,vol,se.pitch)
Audio.se_play("Audio/SE/" + se.name, vol, se.pitch)
end
end
@@ -259,7 +259,7 @@ class Game_System
################################################################################
def windowskin_name
if @windowskin_name==nil
if @windowskin_name == nil
return $data_system.windowskin_name
else
return @windowskin_name
@@ -269,10 +269,10 @@ class Game_System
attr_writer :windowskin_name
def update
@timer -= 1 if @timer_working && @timer>0
if Input.trigger?(Input::SPECIAL) && pbCurrentEventCommentInput(1,"Cut Scene")
@timer -= 1 if @timer_working && @timer > 0
if Input.trigger?(Input::SPECIAL) && pbCurrentEventCommentInput(1, "Cut Scene")
event = @map_interpreter.get_self
@map_interpreter.pbSetSelfSwitch(event.id,"A",true)
@map_interpreter.pbSetSelfSwitch(event.id, "A", true)
@map_interpreter.command_end
event.start
end

View File

@@ -43,8 +43,8 @@ class Game_Map
end
def setup(map_id)
@map_id = map_id
@map = load_data(sprintf("Data/Map%03d.rxdata",map_id))
@map_id = map_id
@map = load_data(sprintf("Data/Map%03d.rxdata", map_id))
tileset = $data_tilesets[@map.tileset_id]
updateTileset
@fog_ox = 0
@@ -57,10 +57,10 @@ class Game_Map
self.display_x = 0
self.display_y = 0
@need_refresh = false
Events.onMapCreate.trigger(self,map_id,@map,tileset)
Events.onMapCreate.trigger(self, map_id, @map, tileset)
@events = {}
for i in @map.events.keys
@events[i] = Game_Event.new(@map_id, @map.events[i],self)
@events[i] = Game_Event.new(@map_id, @map.events[i], self)
end
@common_events = {}
for i in 1...$data_common_events.size
@@ -110,10 +110,10 @@ class Game_Map
#-----------------------------------------------------------------------------
def autoplayAsCue
if @map.autoplay_bgm
if PBDayNight.isNight? && FileTest.audio_exist?("Audio/BGM/"+ @map.bgm.name+ "_n")
pbCueBGM(@map.bgm.name+"_n",1.0,@map.bgm.volume,@map.bgm.pitch)
if PBDayNight.isNight? && FileTest.audio_exist?("Audio/BGM/" + @map.bgm.name + "_n")
pbCueBGM(@map.bgm.name + "_n", 1.0, @map.bgm.volume, @map.bgm.pitch)
else
pbCueBGM(@map.bgm,1.0)
pbCueBGM(@map.bgm, 1.0)
end
end
if @map.autoplay_bgs
@@ -126,8 +126,8 @@ class Game_Map
#-----------------------------------------------------------------------------
def autoplay
if @map.autoplay_bgm
if PBDayNight.isNight? && FileTest.audio_exist?("Audio/BGM/"+ @map.bgm.name+ "_n")
pbBGMPlay(@map.bgm.name+"_n",@map.bgm.volume,@map.bgm.pitch)
if PBDayNight.isNight? && FileTest.audio_exist?("Audio/BGM/" + @map.bgm.name + "_n")
pbBGMPlay(@map.bgm.name + "_n", @map.bgm.volume, @map.bgm.pitch)
else
pbBGMPlay(@map.bgm)
end
@@ -159,7 +159,7 @@ class Game_Map
return false if passage & 0x0f == 0x0f
return true if @priorities[event.tile_id] == 0
end
return playerPassable?(x, y, d, self_event) if self_event==$game_player
return playerPassable?(x, y, d, self_event) if self_event == $game_player
# All other events
newx = x
newy = y
@@ -270,7 +270,7 @@ class Game_Map
return true
end
def bush?(x,y)
def bush?(x, y)
for i in [2, 1, 0]
tile_id = data[x, y, i]
return false if GameData::TerrainTag.try_get(@terrain_tags[tile_id]).bridge &&
@@ -280,7 +280,7 @@ class Game_Map
return false
end
def deepBush?(x,y)
def deepBush?(x, y)
for i in [2, 1, 0]
tile_id = data[x, y, i]
terrain = GameData::TerrainTag.try_get(@terrain_tags[tile_id])
@@ -290,7 +290,7 @@ class Game_Map
return false
end
def counter?(x,y)
def counter?(x, y)
for i in [2, 1, 0]
tile_id = data[x, y, i]
passage = @passages[tile_id]
@@ -299,7 +299,7 @@ class Game_Map
return false
end
def terrain_tag(x,y,countBridge = false)
def terrain_tag(x, y, countBridge = false)
if valid?(x, y)
for i in [2, 1, 0]
tile_id = data[x, y, i]
@@ -313,7 +313,7 @@ class Game_Map
end
# Unused.
def check_event(x,y)
def check_event(x, y)
for event in self.events.values
return event.id if event.at_coordinate?(x, y)
end
@@ -323,7 +323,7 @@ class Game_Map
return if @display_x == value
@display_x = value
if metadata&.snap_edges
max_x = (self.width - Graphics.width*1.0/TILE_WIDTH) * REAL_RES_X
max_x = (self.width - Graphics.width * 1.0 / TILE_WIDTH) * REAL_RES_X
@display_x = [0, [@display_x, max_x].min].max
end
$map_factory.setMapsInRange if $map_factory
@@ -333,7 +333,7 @@ class Game_Map
return if @display_y == value
@display_y = value
if metadata&.snap_edges
max_y = (self.height - Graphics.height*1.0/TILE_HEIGHT) * REAL_RES_Y
max_y = (self.height - Graphics.height * 1.0 / TILE_HEIGHT) * REAL_RES_Y
@display_y = [0, [@display_y, max_y].min].max
end
$map_factory.setMapsInRange if $map_factory
@@ -357,7 +357,7 @@ class Game_Map
def start_scroll(direction, distance, speed)
@scroll_direction = direction
if direction==2 || direction==8 # down or up
if direction == 2 || direction == 8 # down or up
@scroll_rest = distance * REAL_RES_Y
else
@scroll_rest = distance * REAL_RES_X
@@ -369,7 +369,7 @@ class Game_Map
return @scroll_rest > 0
end
def start_fog_tone_change(tone,duration)
def start_fog_tone_change(tone, duration)
@fog_tone_target = tone.clone
@fog_tone_duration = duration
if @fog_tone_duration == 0
@@ -377,10 +377,10 @@ class Game_Map
end
end
def start_fog_opacity_change(opacity,duration)
@fog_opacity_target = opacity*1.0
def start_fog_opacity_change(opacity, duration)
@fog_opacity_target = opacity * 1.0
@fog_opacity_duration = duration
if @fog_opacity_duration==0
if @fog_opacity_duration == 0
@fog_opacity = @fog_opacity_target
end
end
@@ -412,9 +412,9 @@ class Game_Map
$map_factory.setCurrentMap
end
# If scrolling
if @scroll_rest>0
distance = (1<<@scroll_speed)*40.0/Graphics.frame_rate
distance = @scroll_rest if distance>@scroll_rest
if @scroll_rest > 0
distance = (1 << @scroll_speed) * 40.0 / Graphics.frame_rate
distance = @scroll_rest if distance > @scroll_rest
case @scroll_direction
when 2 then scroll_down(distance)
when 4 then scroll_left(distance)
@@ -432,9 +432,9 @@ class Game_Map
common_event.update
end
# Update fog
@fog_ox -= @fog_sx/8.0
@fog_oy -= @fog_sy/8.0
if @fog_tone_duration>=1
@fog_ox -= @fog_sx / 8.0
@fog_oy -= @fog_sy / 8.0
if @fog_tone_duration >= 1
d = @fog_tone_duration
target = @fog_tone_target
@fog_tone.red = (@fog_tone.red * (d - 1) + target.red) / d
@@ -454,8 +454,8 @@ end
#===============================================================================
#
#===============================================================================
def pbScrollMap(direction,distance,speed)
if speed==0
def pbScrollMap(direction, distance, speed)
if speed == 0
case direction
when 2 then $game_map.scroll_down(distance * Game_Map::REAL_RES_Y)
when 4 then $game_map.scroll_left(distance * Game_Map::REAL_RES_X)
@@ -471,7 +471,7 @@ def pbScrollMap(direction,distance,speed)
Input.update
break if !$game_map.scrolling?
pbUpdateSceneMap
break if $game_map.display_x==oldx && $game_map.display_y==oldy
break if $game_map.display_x == oldx && $game_map.display_y == oldy
oldx = $game_map.display_x
oldy = $game_map.display_y
end

View File

@@ -77,22 +77,22 @@ class Interpreter
# y : y coordinate to scroll to and center on
# speed : (optional) scroll speed (from 1-6, default being 4)
#-----------------------------------------------------------------------------
def autoscroll(x,y,speed = SCROLL_SPEED_DEFAULT)
def autoscroll(x, y, speed = SCROLL_SPEED_DEFAULT)
if $game_map.scrolling?
return false
elsif !$game_map.valid?(x,y)
elsif !$game_map.valid?(x, y)
print 'Map Autoscroll: given x,y is invalid'
return command_skip
elsif !(1..6).include?(speed)
print 'Map Autoscroll: invalid speed (1-6 only)'
return command_skip
end
center_x = (Graphics.width/2 - Game_Map::TILE_WIDTH/2) * 4 # X coordinate in the center of the screen
center_y = (Graphics.height/2 - Game_Map::TILE_HEIGHT/2) * 4 # Y coordinate in the center of the screen
max_x = ($game_map.width - Graphics.width*1.0/Game_Map::TILE_WIDTH) * 4 * Game_Map::TILE_WIDTH
max_y = ($game_map.height - Graphics.height*1.0/Game_Map::TILE_HEIGHT) * 4 * Game_Map::TILE_HEIGHT
count_x = ($game_map.display_x - [0,[x*Game_Map::REAL_RES_X-center_x,max_x].min].max)/Game_Map::REAL_RES_X
count_y = ($game_map.display_y - [0,[y*Game_Map::REAL_RES_Y-center_y,max_y].min].max)/Game_Map::REAL_RES_Y
center_x = (Graphics.width / 2 - Game_Map::TILE_WIDTH / 2) * 4 # X coordinate in the center of the screen
center_y = (Graphics.height / 2 - Game_Map::TILE_HEIGHT / 2) * 4 # Y coordinate in the center of the screen
max_x = ($game_map.width - Graphics.width * 1.0 / Game_Map::TILE_WIDTH) * 4 * Game_Map::TILE_WIDTH
max_y = ($game_map.height - Graphics.height * 1.0 / Game_Map::TILE_HEIGHT) * 4 * Game_Map::TILE_HEIGHT
count_x = ($game_map.display_x - [0, [x * Game_Map::REAL_RES_X - center_x, max_x].min].max) / Game_Map::REAL_RES_X
count_y = ($game_map.display_y - [0, [y * Game_Map::REAL_RES_Y - center_y, max_y].min].max) / Game_Map::REAL_RES_Y
if !@diag
@diag = true
dir = nil
@@ -109,7 +109,7 @@ class Interpreter
dir = 3
end
end
count = [count_x.abs,count_y.abs].min
count = [count_x.abs, count_y.abs].min
else
@diag = false
dir = nil
@@ -139,7 +139,7 @@ class Interpreter
# speed : (optional) scroll speed (from 1-6, default being 4)
#-----------------------------------------------------------------------------
def autoscroll_player(speed = SCROLL_SPEED_DEFAULT)
autoscroll($game_player.x,$game_player.y,speed)
autoscroll($game_player.x, $game_player.y, speed)
end
end
@@ -148,20 +148,20 @@ end
class Game_Map
def scroll_downright(distance)
@display_x = [@display_x + distance,
(self.width - Graphics.width*1.0/TILE_WIDTH) * REAL_RES_X].min
(self.width - Graphics.width * 1.0 / TILE_WIDTH) * REAL_RES_X].min
@display_y = [@display_y + distance,
(self.height - Graphics.height*1.0/TILE_HEIGHT) * REAL_RES_Y].min
(self.height - Graphics.height * 1.0 / TILE_HEIGHT) * REAL_RES_Y].min
end
def scroll_downleft(distance)
@display_x = [@display_x - distance, 0].max
@display_y = [@display_y + distance,
(self.height - Graphics.height*1.0/TILE_HEIGHT) * REAL_RES_Y].min
(self.height - Graphics.height * 1.0 / TILE_HEIGHT) * REAL_RES_Y].min
end
def scroll_upright(distance)
@display_x = [@display_x + distance,
(self.width - Graphics.width*1.0/TILE_WIDTH) * REAL_RES_X].min
(self.width - Graphics.width * 1.0 / TILE_WIDTH) * REAL_RES_X].min
@display_y = [@display_y - distance, 0].max
end
@@ -174,8 +174,8 @@ class Game_Map
# If scrolling
if @scroll_rest > 0
# Change from scroll speed to distance in map coordinates
distance = (1<<@scroll_speed)*40/Graphics.frame_rate
distance = @scroll_rest if distance>@scroll_rest
distance = (1 << @scroll_speed) * 40 / Graphics.frame_rate
distance = @scroll_rest if distance > @scroll_rest
# Execute scrolling
case @scroll_direction
when 1 then scroll_downleft(distance)

View File

@@ -19,7 +19,7 @@ class PokemonMapFactory
@maps[0] = Game_Map.new
@mapIndex = 0
oldID = ($game_map) ? $game_map.map_id : 0
setMapChanging(id,@maps[0]) if oldID!=0 && oldID!=@maps[0].map_id
setMapChanging(id, @maps[0]) if oldID != 0 && oldID != @maps[0].map_id
$game_map = @maps[0]
@maps[0].setup(id)
setMapsInRange
@@ -27,9 +27,9 @@ class PokemonMapFactory
end
def map
@mapIndex = 0 if !@mapIndex || @mapIndex<0
@mapIndex = 0 if !@mapIndex || @mapIndex < 0
return @maps[@mapIndex] if @maps[@mapIndex]
raise "No maps in save file... (mapIndex=#{@mapIndex})" if @maps.length==0
raise "No maps in save file... (mapIndex=#{@mapIndex})" if @maps.length == 0
if @maps[0]
echoln "Using next map, may be incorrect (mapIndex=#{@mapIndex}, length=#{@maps.length})"
return @maps[0]
@@ -39,21 +39,21 @@ class PokemonMapFactory
def hasMap?(id)
for map in @maps
return true if map.map_id==id
return true if map.map_id == id
end
return false
end
def getMapIndex(id)
for i in 0...@maps.length
return i if @maps[i].map_id==id
return i if @maps[i].map_id == id
end
return -1
end
def getMap(id,add = true)
def getMap(id, add = true)
for map in @maps
return map if map.map_id==id
return map if map.map_id == id
end
map = Game_Map.new
map.setup(id)
@@ -62,10 +62,10 @@ class PokemonMapFactory
end
def getMapNoAdd(id)
return getMap(id,false)
return getMap(id, false)
end
def getNewMap(playerX,playerY)
def getNewMap(playerX, playerY)
id = $game_map.map_id
conns = MapFactoryHelper.getMapConnections
if conns[id]
@@ -96,16 +96,16 @@ class PokemonMapFactory
# their transfer to that map.
def setCurrentMap
return if $game_player.moving?
return if $game_map.valid?($game_player.x,$game_player.y)
newmap = getNewMap($game_player.x,$game_player.y)
return if $game_map.valid?($game_player.x, $game_player.y)
newmap = getNewMap($game_player.x, $game_player.y)
return if !newmap
oldmap=$game_map.map_id
if oldmap!=0 && oldmap!=newmap[0].map_id
setMapChanging(newmap[0].map_id,newmap[0])
oldmap = $game_map.map_id
if oldmap != 0 && oldmap != newmap[0].map_id
setMapChanging(newmap[0].map_id, newmap[0])
end
$game_map = newmap[0]
@mapIndex = getMapIndex($game_map.map_id)
$game_player.moveto(newmap[1],newmap[2])
$game_player.moveto(newmap[1], newmap[2])
$game_map.update
pbAutoplayOnTransition
$game_map.refresh
@@ -144,17 +144,17 @@ class PokemonMapFactory
@fixup = false
end
def setMapChanging(newID,newMap)
Events.onMapChanging.trigger(self,newID,newMap)
def setMapChanging(newID, newMap)
Events.onMapChanging.trigger(self, newID, newMap)
end
def setMapChanged(prevMap)
Events.onMapChange.trigger(self,prevMap)
Events.onMapChange.trigger(self, prevMap)
@mapChanged = true
end
def setSceneStarted(scene)
Events.onMapSceneChange.trigger(self,scene,@mapChanged)
Events.onMapSceneChange.trigger(self, scene, @mapChanged)
@mapChanged = false
end
@@ -194,42 +194,42 @@ class PokemonMapFactory
end
# Only used by dependent events
def isPassableStrict?(mapID,x,y,thisEvent = nil)
def isPassableStrict?(mapID, x, y, thisEvent = nil)
thisEvent = $game_player if !thisEvent
map = getMapNoAdd(mapID)
return false if !map
return false if !map.valid?(x,y)
return false if !map.valid?(x, y)
return true if thisEvent.through
if thisEvent==$game_player
if thisEvent == $game_player
if !($DEBUG && Input.press?(Input::CTRL))
return false if !map.passableStrict?(x,y,0,thisEvent)
return false if !map.passableStrict?(x, y, 0, thisEvent)
end
else
return false if !map.passableStrict?(x,y,0,thisEvent)
return false if !map.passableStrict?(x, y, 0, thisEvent)
end
for event in map.events.values
next if event == thisEvent || !event.at_coordinate?(x, y)
return false if !event.through && event.character_name!=""
return false if !event.through && event.character_name != ""
end
return true
end
def getTerrainTag(mapid,x,y,countBridge = false)
def getTerrainTag(mapid, x, y, countBridge = false)
map = getMapNoAdd(mapid)
return map.terrain_tag(x,y,countBridge)
return map.terrain_tag(x, y, countBridge)
end
# NOTE: Assumes the event is 1x1 tile in size. Only returns one terrain tag.
def getFacingTerrainTag(dir = nil,event = nil)
tile = getFacingTile(dir,event)
def getFacingTerrainTag(dir = nil, event = nil)
tile = getFacingTile(dir, event)
return GameData::TerrainTag.get(:None) if !tile
return getTerrainTag(tile[0],tile[1],tile[2])
return getTerrainTag(tile[0], tile[1], tile[2])
end
def getTerrainTagFromCoords(mapid,x,y,countBridge = false)
tile = getRealTilePos(mapid,x,y)
def getTerrainTagFromCoords(mapid, x, y, countBridge = false)
tile = getRealTilePos(mapid, x, y)
return GameData::TerrainTag.get(:None) if !tile
return getTerrainTag(tile[0],tile[1],tile[2])
return getTerrainTag(tile[0], tile[1], tile[2])
end
def areConnected?(mapID1, mapID2)
@@ -268,38 +268,38 @@ class PokemonMapFactory
# Gets the distance from this event to another event. Example: If this event's
# coordinates are (2,5) and the other event's coordinates are (5,1), returns
# the array (3,-4), because (5-2=3) and (1-5=-4).
def getThisAndOtherEventRelativePos(thisEvent,otherEvent)
return [0,0] if !thisEvent || !otherEvent
def getThisAndOtherEventRelativePos(thisEvent, otherEvent)
return [0, 0] if !thisEvent || !otherEvent
return getRelativePos(
thisEvent.map.map_id,thisEvent.x,thisEvent.y,
otherEvent.map.map_id,otherEvent.x,otherEvent.y)
thisEvent.map.map_id, thisEvent.x, thisEvent.y,
otherEvent.map.map_id, otherEvent.x, otherEvent.y)
end
def getThisAndOtherPosRelativePos(thisEvent,otherMapID,otherX,otherY)
return [0,0] if !thisEvent
def getThisAndOtherPosRelativePos(thisEvent, otherMapID, otherX, otherY)
return [0, 0] if !thisEvent
return getRelativePos(
thisEvent.map.map_id,thisEvent.x,thisEvent.y,otherMapID,otherX,otherY)
thisEvent.map.map_id, thisEvent.x, thisEvent.y, otherMapID, otherX, otherY)
end
# Unused
def getOffsetEventPos(event,xOffset,yOffset)
def getOffsetEventPos(event, xOffset, yOffset)
event = $game_player if !event
return nil if !event
return getRealTilePos(event.map.map_id,event.x+xOffset,event.y+yOffset)
return getRealTilePos(event.map.map_id, event.x + xOffset, event.y + yOffset)
end
# NOTE: Assumes the event is 1x1 tile in size. Only returns one tile.
def getFacingTile(direction = nil,event = nil,steps = 1)
event = $game_player if event==nil
return [0,0,0] if !event
def getFacingTile(direction = nil, event = nil, steps = 1)
event = $game_player if event == nil
return [0, 0, 0] if !event
x = event.x
y = event.y
id = event.map.map_id
direction = event.direction if direction==nil
return getFacingTileFromPos(id,x,y,direction,steps)
direction = event.direction if direction == nil
return getFacingTileFromPos(id, x, y, direction, steps)
end
def getFacingTileFromPos(mapID,x,y,direction = 0,steps = 1)
def getFacingTileFromPos(mapID, x, y, direction = 0, steps = 1)
id = mapID
case direction
when 1
@@ -323,9 +323,9 @@ class PokemonMapFactory
x += steps
y -= steps
else
return [id,x,y]
return [id, x, y]
end
return getRealTilePos(mapID,x,y)
return getRealTilePos(mapID, x, y)
end
def getRealTilePos(mapID, x, y)
@@ -354,7 +354,7 @@ class PokemonMapFactory
return nil
end
def getFacingCoords(x,y,direction = 0,steps = 1)
def getFacingCoords(x, y, direction = 0, steps = 1)
case direction
when 1
x -= steps
@@ -377,7 +377,7 @@ class PokemonMapFactory
x += steps
y -= steps
end
return [x,y]
return [x, y]
end
def updateMaps(scene)
@@ -464,9 +464,9 @@ module MapFactoryHelper
if !@@MapDims[id]
begin
map = load_data(sprintf("Data/Map%03d.rxdata", id))
@@MapDims[id] = [map.width,map.height]
@@MapDims[id] = [map.width, map.height]
rescue
@@MapDims[id] = [0,0]
@@MapDims[id] = [0, 0]
end
end
# Return map in cache
@@ -475,11 +475,11 @@ module MapFactoryHelper
# Returns the X or Y coordinate of an edge on the map with id.
# Considers the special strings "N","W","E","S"
def self.getMapEdge(id,edge)
return 0 if edge=="N" || edge=="W"
def self.getMapEdge(id, edge)
return 0 if edge == "N" || edge == "W"
dims = getMapDims(id) # Get dimensions
return dims[0] if edge=="E"
return dims[1] if edge=="S"
return dims[0] if edge == "E"
return dims[1] if edge == "S"
return dims[0] # real dimension (use width)
end
@@ -494,7 +494,7 @@ module MapFactoryHelper
return true
end
def self.mapInRangeById?(id,dispx,dispy)
def self.mapInRangeById?(id, dispx, dispy)
range = 6 # Number of tiles
dims = MapFactoryHelper.getMapDims(id)
return false if dispx >= (dims[0] + range) * Game_Map::REAL_RES_X

View File

@@ -96,7 +96,7 @@ class Game_Character
end
def move_speed=(val)
return if val==@move_speed
return if val == @move_speed
@move_speed = val
# @move_speed_real is the number of quarter-pixels to move each frame. There
# are 128 quarter-pixels per tile. By default, it is calculated from
@@ -107,7 +107,7 @@ class Game_Character
# 4 => 25.6 # 5 frames per tile - running speed (2x walking speed)
# 5 => 32 # 4 frames per tile - cycling speed (1.25x running speed)
# 6 => 64 # 2 frames per tile
self.move_speed_real = (val == 6) ? 64 : (val == 5) ? 32 : (2 ** (val + 1)) * 0.8
self.move_speed_real = (val == 6) ? 64 : (val == 5) ? 32 : (2**(val + 1)) * 0.8
end
def move_speed_real
@@ -120,7 +120,7 @@ class Game_Character
end
def jump_speed_real
self.jump_speed_real = (2 ** (3 + 1)) * 0.8 if !@jump_speed_real # 3 is walking speed
self.jump_speed_real = (2**(3 + 1)) * 0.8 if !@jump_speed_real # 3 is walking speed
return @jump_speed_real
end
@@ -129,7 +129,7 @@ class Game_Character
end
def move_frequency=(val)
return if val==@move_frequency
return if val == @move_frequency
@move_frequency = val
# @move_frequency_real is the number of frames to wait between each action
# in a move route (not forced). Specifically, this is the number of frames
@@ -381,8 +381,8 @@ class Game_Character
def triggerLeaveTile
if @oldX && @oldY && @oldMap &&
(@oldX!=self.x || @oldY!=self.y || @oldMap!=self.map.map_id)
Events.onLeaveTile.trigger(self,self,@oldMap,@oldX,@oldY)
(@oldX != self.x || @oldY != self.y || @oldMap != self.map.map_id)
Events.onLeaveTile.trigger(self, self, @oldMap, @oldX, @oldY)
end
@oldX = self.x
@oldY = self.y
@@ -629,23 +629,23 @@ class Game_Character
end
end
def move_random_range(xrange = -1,yrange = -1)
def move_random_range(xrange = -1, yrange = -1)
dirs = [] # 0=down, 1=left, 2=right, 3=up
if xrange<0
if xrange < 0
dirs.push(1)
dirs.push(2)
elsif xrange>0
elsif xrange > 0
dirs.push(1) if @x > @original_x - xrange
dirs.push(2) if @x < @original_x + xrange
end
if yrange<0
if yrange < 0
dirs.push(0)
dirs.push(3)
elsif yrange>0
elsif yrange > 0
dirs.push(0) if @y < @original_y + yrange
dirs.push(3) if @y > @original_y - yrange
end
return if dirs.length==0
return if dirs.length == 0
case dirs[rand(dirs.length)]
when 0 then move_down(false)
when 1 then move_left(false)
@@ -655,11 +655,11 @@ class Game_Character
end
def move_random_UD(range = -1)
move_random_range(0,range)
move_random_range(0, range)
end
def move_random_LR(range = -1)
move_random_range(range,0)
move_random_range(range, 0)
end
def move_toward_player
@@ -755,19 +755,19 @@ class Game_Character
def jumpForward
case self.direction
when 2 then jump(0,1) # down
when 4 then jump(-1,0) # left
when 6 then jump(1,0) # right
when 8 then jump(0,-1) # up
when 2 then jump(0, 1) # down
when 4 then jump(-1, 0) # left
when 6 then jump(1, 0) # right
when 8 then jump(0, -1) # up
end
end
def jumpBackward
case self.direction
when 2 then jump(0,-1) # down
when 4 then jump(1,0) # left
when 6 then jump(-1,0) # right
when 8 then jump(0,1) # up
when 2 then jump(0, -1) # down
when 4 then jump(1, 0) # left
when 6 then jump(-1, 0) # right
when 8 then jump(0, 1) # up
end
end

View File

@@ -54,7 +54,7 @@ class Game_Event < Game_Character
end
def tsOn?(c)
return @tempSwitches && @tempSwitches[c]==true
return @tempSwitches && @tempSwitches[c] == true
end
def tsOff?(c)
@@ -62,17 +62,17 @@ class Game_Event < Game_Character
end
def setTempSwitchOn(c)
@tempSwitches[c]=true
@tempSwitches[c] = true
refresh
end
def setTempSwitchOff(c)
@tempSwitches[c]=false
@tempSwitches[c] = false
refresh
end
def isOff?(c)
return !$game_self_switches[[@map_id,@event.id,c]]
return !$game_self_switches[[@map_id, @event.id, c]]
end
def switchIsOn?(id)
@@ -87,31 +87,31 @@ class Game_Event < Game_Character
def variable
return nil if !$PokemonGlobal.eventvars
return $PokemonGlobal.eventvars[[@map_id,@event.id]]
return $PokemonGlobal.eventvars[[@map_id, @event.id]]
end
def setVariable(variable)
$PokemonGlobal.eventvars[[@map_id,@event.id]]=variable
$PokemonGlobal.eventvars[[@map_id, @event.id]] = variable
end
def varAsInt
return 0 if !$PokemonGlobal.eventvars
return $PokemonGlobal.eventvars[[@map_id,@event.id]].to_i
return $PokemonGlobal.eventvars[[@map_id, @event.id]].to_i
end
def expired?(secs = 86400)
ontime=self.variable
time=pbGetTimeNow
return ontime && (time.to_i>ontime+secs)
ontime = self.variable
time = pbGetTimeNow
return ontime && (time.to_i > ontime + secs)
end
def expiredDays?(days = 1)
ontime=self.variable.to_i
ontime = self.variable.to_i
return false if !ontime
now=pbGetTimeNow
elapsed=(now.to_i-ontime)/86400
elapsed+=1 if (now.to_i-ontime)%86400>(now.hour*3600+now.min*60+now.sec)
return elapsed>=days
now = pbGetTimeNow
elapsed = (now.to_i - ontime) / 86400
elapsed += 1 if (now.to_i - ontime) % 86400 > (now.hour * 3600 + now.min * 60 + now.sec)
return elapsed >= days
end
def cooledDown?(seconds)
@@ -143,7 +143,7 @@ class Game_Event < Game_Character
return if $game_system.map_interpreter.running? || @starting
if @event.name[/trainer\((\d+)\)/i]
distance = $~[1].to_i
if @trigger==2 && pbEventCanReachPlayer?(self,$game_player,distance)
if @trigger == 2 && pbEventCanReachPlayer?(self, $game_player, distance)
start if !jumping? && !over_trigger?
end
end
@@ -248,8 +248,8 @@ class Game_Event < Game_Character
return true if @move_route_forcing
return true if @event.name[/update/i]
range = 2 # Number of tiles
return false if self.screen_x - @sprite_size[0]/2 > Graphics.width + range * Game_Map::TILE_WIDTH
return false if self.screen_x + @sprite_size[0]/2 < -range * Game_Map::TILE_WIDTH
return false if self.screen_x - @sprite_size[0] / 2 > Graphics.width + range * Game_Map::TILE_WIDTH
return false if self.screen_x + @sprite_size[0] / 2 < -range * Game_Map::TILE_WIDTH
return false if self.screen_y_ground - @sprite_size[1] > Graphics.height + range * Game_Map::TILE_HEIGHT
return false if self.screen_y_ground < -range * Game_Map::TILE_HEIGHT
return true

View File

@@ -17,9 +17,9 @@ class Game_Player < Game_Character
def initialize(*arg)
super(*arg)
@lastdir=0
@lastdirframe=0
@bump_se=0
@lastdir = 0
@lastdirframe = 0
@bump_se = 0
end
def map
@@ -103,9 +103,9 @@ class Game_Player < Game_Character
end
def bump_into_object
return if @bump_se && @bump_se>0
return if @bump_se && @bump_se > 0
pbSEPlay("Player bump")
@bump_se = Graphics.frame_rate/4
@bump_se = Graphics.frame_rate / 4
end
def move_generic(dir, turn_enabled = true)
@@ -179,7 +179,7 @@ class Game_Player < Game_Character
triggerLeaveTile
end
def pbTriggeredTrainerEvents(triggers,checkIfRunning = true)
def pbTriggeredTrainerEvents(triggers, checkIfRunning = true)
result = []
# If event is running
return result if checkIfRunning && $game_system.map_interpreter.running?
@@ -188,7 +188,7 @@ class Game_Player < Game_Character
next if !event.name[/trainer\((\d+)\)/i]
distance = $~[1].to_i
# If event coordinates and triggers are consistent
if pbEventCanReachPlayer?(event,self,distance) && triggers.include?(event.trigger)
if pbEventCanReachPlayer?(event, self, distance) && triggers.include?(event.trigger)
# If starting determinant is front event (other than jumping)
result.push(event) if !event.jumping? && !event.over_trigger?
end
@@ -196,7 +196,7 @@ class Game_Player < Game_Character
return result
end
def pbTriggeredCounterEvents(triggers,checkIfRunning = true)
def pbTriggeredCounterEvents(triggers, checkIfRunning = true)
result = []
# If event is running
return result if checkIfRunning && $game_system.map_interpreter.running?
@@ -205,7 +205,7 @@ class Game_Player < Game_Character
next if !event.name[/counter\((\d+)\)/i]
distance = $~[1].to_i
# If event coordinates and triggers are consistent
if pbEventFacesPlayer?(event,self,distance) && triggers.include?(event.trigger)
if pbEventFacesPlayer?(event, self, distance) && triggers.include?(event.trigger)
# If starting determinant is front event (other than jumping)
result.push(event) if !event.jumping? && !event.over_trigger?
end
@@ -218,7 +218,7 @@ class Game_Player < Game_Character
def pbCheckEventTriggerFromDistance(triggers)
ret = pbTriggeredTrainerEvents(triggers)
ret.concat(pbTriggeredCounterEvents(triggers))
return false if ret.length==0
return false if ret.length == 0
for event in ret
event.start
end
@@ -401,10 +401,10 @@ class Game_Player < Game_Character
next if !event.at_coordinate?(@x + x_offset, @y + y_offset)
if event.name[/trainer\((\d+)\)/i]
distance = $~[1].to_i
next if !pbEventCanReachPlayer?(event,self,distance)
next if !pbEventCanReachPlayer?(event, self, distance)
elsif event.name[/counter\((\d+)\)/i]
distance = $~[1].to_i
next if !pbEventFacesPlayer?(event,self,distance)
next if !pbEventFacesPlayer?(event, self, distance)
end
# If starting determinant is front event (other than jumping)
next if event.jumping? || event.over_trigger?
@@ -429,12 +429,12 @@ class Game_Player < Game_Character
end
$game_temp.followers.update
# Count down the time between allowed bump sounds
@bump_se -= 1 if @bump_se && @bump_se>0
@bump_se -= 1 if @bump_se && @bump_se > 0
# Finish up dismounting from surfing
if $game_temp.ending_surf && !moving?
pbCancelVehicles
$game_temp.surf_base_coords = nil
$game_temp.ending_surf = false
$game_temp.ending_surf = false
end
update_event_triggering
end
@@ -538,7 +538,7 @@ class Game_Player < Game_Character
$game_temp.followers.turn_followers
result = pbCheckEventTriggerFromDistance([2])
# Event determinant is via touch of same position event
result |= check_event_trigger_here([1,2])
result |= check_event_trigger_here([1, 2])
# No events triggered, try other event triggers upon finishing a step
pbOnStepTaken(result)
end
@@ -546,7 +546,7 @@ class Game_Player < Game_Character
if Input.trigger?(Input::USE) && !$game_temp.in_mini_update
# Same position and front event determinant
check_event_trigger_here([0])
check_event_trigger_there([0,2])
check_event_trigger_there([0, 2])
end
end
end
@@ -566,8 +566,8 @@ def pbGetPlayerCharset(charset, trainer = nil, force = false)
end
$game_player.charsetData = [trainer.character_ID, charset, outfit] if $game_player
ret = charset
if pbResolveBitmap("Graphics/Characters/"+ret+"_"+outfit.to_s)
ret = ret+"_"+outfit.to_s
if pbResolveBitmap("Graphics/Characters/" + ret + "_" + outfit.to_s)
ret = ret + "_" + outfit.to_s
end
return ret
end

View File

@@ -161,7 +161,7 @@ class Game_Follower < Game_Event
def location_passable?(x, y, direction)
this_map = self.map
return false if !this_map || !this_map.valid?(x,y)
return false if !this_map || !this_map.valid?(x, y)
return true if @through
passed_tile_checks = false
bit = (1 << (direction / 2 - 1)) & 0x0f

View File

@@ -19,8 +19,8 @@ class Sprite_Picture
# If file name is not empty
if @picture_name != ""
# Get picture graphic
@sprite=IconSprite.new(0,0,@viewport) if !@sprite
@sprite.setBitmap("Graphics/Pictures/"+@picture_name)
@sprite = IconSprite.new(0, 0, @viewport) if !@sprite
@sprite.setBitmap("Graphics/Pictures/" + @picture_name)
end
end
# If file name is empty
@@ -28,7 +28,7 @@ class Sprite_Picture
# Set sprite to invisible
if @sprite
@sprite.dispose if @sprite
@sprite=nil
@sprite = nil
end
return
end

View File

@@ -1,15 +1,15 @@
class Sprite_Timer
def initialize(viewport = nil)
@viewport=viewport
@timer=nil
@total_sec=nil
@disposed=false
@viewport = viewport
@timer = nil
@total_sec = nil
@disposed = false
end
def dispose
@timer.dispose if @timer
@timer=nil
@disposed=true
@timer = nil
@disposed = true
end
def disposed?
@@ -21,14 +21,14 @@ class Sprite_Timer
if $game_system.timer_working
@timer.visible = true if @timer
if !@timer
@timer=Window_AdvancedTextPokemon.newWithSize("",Graphics.width-120,0,120,64)
@timer.width=@timer.borderX+96
@timer.x=Graphics.width-@timer.width
@timer.viewport=@viewport
@timer.z=99998
@timer = Window_AdvancedTextPokemon.newWithSize("", Graphics.width - 120, 0, 120, 64)
@timer.width = @timer.borderX + 96
@timer.x = Graphics.width - @timer.width
@timer.viewport = @viewport
@timer.z = 99998
end
curtime=$game_system.timer / Graphics.frame_rate
curtime=0 if curtime<0
curtime = $game_system.timer / Graphics.frame_rate
curtime = 0 if curtime < 0
if curtime != @total_sec
# Calculate total number of seconds
@total_sec = curtime
@@ -39,7 +39,7 @@ class Sprite_Timer
end
@timer.update
else
@timer.visible=false if @timer
@timer.visible = false if @timer
end
end
end

View File

@@ -2,13 +2,13 @@ class Sprite_Reflection
attr_reader :visible
attr_accessor :event
def initialize(sprite,event,viewport = nil)
def initialize(sprite, event, viewport = nil)
@rsprite = sprite
@sprite = nil
@event = event
@height = 0
@fixedheight = false
if @event && @event!=$game_player
if @event && @event != $game_player
if @event.name[/reflection\((\d+)\)/i]
@height = $~[1].to_i || 0
@fixedheight = true
@@ -50,35 +50,35 @@ class Sprite_Reflection
# Just-in-time creation of sprite
@sprite = Sprite.new(@viewport) if !@sprite
if @sprite
x = @rsprite.x-@rsprite.ox
y = @rsprite.y-@rsprite.oy
x = @rsprite.x - @rsprite.ox
y = @rsprite.y - @rsprite.oy
y -= 32 if @rsprite.character.character_name[/offset/i]
@height = $PokemonGlobal.bridge if !@fixedheight
y += @height*16
y += @height * 16
width = @rsprite.src_rect.width
height = @rsprite.src_rect.height
@sprite.x = x+width/2
@sprite.y = y+height+height/2
@sprite.ox = width/2
@sprite.oy = height/2-2 # Hard-coded 2 pixel shift up
@sprite.oy -= @rsprite.character.bob_height*2
@sprite.x = x + width / 2
@sprite.y = y + height + height / 2
@sprite.ox = width / 2
@sprite.oy = height / 2 - 2 # Hard-coded 2 pixel shift up
@sprite.oy -= @rsprite.character.bob_height * 2
@sprite.z = -50 # Still water is -100, map is 0 and above
@sprite.z += 1 if @event == $game_player
@sprite.zoom_x = @rsprite.zoom_x
@sprite.zoom_y = @rsprite.zoom_y
frame = (Graphics.frame_count%40)/10
frame = (Graphics.frame_count % 40) / 10
@sprite.zoom_x *= [1.0, 0.95, 1.0, 1.05][frame]
@sprite.angle = 180.0
@sprite.mirror = true
@sprite.bitmap = @rsprite.bitmap
@sprite.tone = @rsprite.tone
if @height>0
@sprite.color = Color.new(48,96,160,255) # Dark still water
if @height > 0
@sprite.color = Color.new(48, 96, 160, 255) # Dark still water
@sprite.opacity = @rsprite.opacity
@sprite.visible = !Settings::TIME_SHADING # Can't time-tone a colored sprite
else
@sprite.color = Color.new(224,224,224,96)
@sprite.opacity = @rsprite.opacity*3/4
@sprite.color = Color.new(224, 224, 224, 96)
@sprite.opacity = @rsprite.opacity * 3 / 4
@sprite.visible = true
end
@sprite.src_rect = @rsprite.src_rect

View File

@@ -2,7 +2,7 @@ class Sprite_SurfBase
attr_reader :visible
attr_accessor :event
def initialize(sprite,event,viewport = nil)
def initialize(sprite, event, viewport = nil)
@rsprite = sprite
@sprite = nil
@event = event
@@ -12,10 +12,10 @@ class Sprite_SurfBase
@divebitmap = AnimatedBitmap.new("Graphics/Characters/base_dive")
RPG::Cache.retain("Graphics/Characters/base_surf")
RPG::Cache.retain("Graphics/Characters/base_dive")
@cws = @surfbitmap.width/4
@chs = @surfbitmap.height/4
@cwd = @divebitmap.width/4
@chd = @divebitmap.height/4
@cws = @surfbitmap.width / 4
@chs = @surfbitmap.height / 4
@cwd = @divebitmap.width / 4
@chd = @divebitmap.height / 4
update
end
@@ -59,9 +59,9 @@ class Sprite_SurfBase
cw = @cwd
ch = @chd
end
sx = @event.pattern_surf*cw
sy = ((@event.direction-2)/2)*ch
@sprite.src_rect.set(sx,sy,cw,ch)
sx = @event.pattern_surf * cw
sy = ((@event.direction - 2) / 2) * ch
@sprite.src_rect.set(sx, sy, cw, ch)
if $game_temp.surf_base_coords
@sprite.x = ($game_temp.surf_base_coords[0] * Game_Map::REAL_RES_X - @event.map.display_x + 3) / 4 + (Game_Map::TILE_WIDTH / 2)
@sprite.y = ($game_temp.surf_base_coords[1] * Game_Map::REAL_RES_Y - @event.map.display_y + 3) / 4 + (Game_Map::TILE_HEIGHT / 2) + 16
@@ -69,10 +69,10 @@ class Sprite_SurfBase
@sprite.x = @rsprite.x
@sprite.y = @rsprite.y
end
@sprite.ox = cw/2
@sprite.oy = ch-16 # Assume base needs offsetting
@sprite.ox = cw / 2
@sprite.oy = ch - 16 # Assume base needs offsetting
@sprite.oy -= @event.bob_height
@sprite.z = @event.screen_z(ch)-1
@sprite.z = @event.screen_z(ch) - 1
@sprite.zoom_x = @rsprite.zoom_x
@sprite.zoom_y = @rsprite.zoom_y
@sprite.tone = @rsprite.tone

View File

@@ -1,30 +1,30 @@
# Unused
class ClippableSprite < Sprite_Character
def initialize(viewport,event,tilemap)
def initialize(viewport, event, tilemap)
@tilemap = tilemap
@_src_rect = Rect.new(0,0,0,0)
super(viewport,event)
@_src_rect = Rect.new(0, 0, 0, 0)
super(viewport, event)
end
def update
super
@_src_rect = self.src_rect
tmright = @tilemap.map_data.xsize*Game_Map::TILE_WIDTH-@tilemap.ox
tmright = @tilemap.map_data.xsize * Game_Map::TILE_WIDTH - @tilemap.ox
echoln "x=#{self.x},ox=#{self.ox},tmright=#{tmright},tmox=#{@tilemap.ox}"
if @tilemap.ox-self.ox<-self.x
if @tilemap.ox - self.ox < -self.x
# clipped on left
diff = -self.x-@tilemap.ox+self.ox
self.src_rect = Rect.new(@_src_rect.x+diff,@_src_rect.y,
@_src_rect.width-diff,@_src_rect.height)
echoln "clipped out left: #{diff} #{@tilemap.ox-self.ox} #{self.x}"
elsif tmright-self.ox<self.x
diff = -self.x - @tilemap.ox + self.ox
self.src_rect = Rect.new(@_src_rect.x + diff, @_src_rect.y,
@_src_rect.width - diff, @_src_rect.height)
echoln "clipped out left: #{diff} #{@tilemap.ox - self.ox} #{self.x}"
elsif tmright - self.ox < self.x
# clipped on right
diff = self.x-tmright+self.ox
self.src_rect = Rect.new(@_src_rect.x,@_src_rect.y,
@_src_rect.width-diff,@_src_rect.height)
echoln "clipped out right: #{diff} #{tmright+self.ox} #{self.x}"
diff = self.x - tmright + self.ox
self.src_rect = Rect.new(@_src_rect.x, @_src_rect.y,
@_src_rect.width - diff, @_src_rect.height)
echoln "clipped out right: #{diff} #{tmright + self.ox} #{self.x}"
else
echoln "-not- clipped out left: #{diff} #{@tilemap.ox-self.ox} #{self.x}"
echoln "-not- clipped out left: #{diff} #{@tilemap.ox - self.ox} #{self.x}"
end
end
end
@@ -55,11 +55,11 @@ class Spriteset_Map
@fog.z = 3000
@character_sprites = []
for i in @map.events.keys.sort
sprite = Sprite_Character.new(@@viewport1,@map.events[i])
sprite = Sprite_Character.new(@@viewport1, @map.events[i])
@character_sprites.push(sprite)
end
@weather = RPG::Weather.new(@@viewport1)
pbOnSpritesetCreate(self,@@viewport1)
pbOnSpritesetCreate(self, @@viewport1)
update
end
@@ -90,32 +90,32 @@ class Spriteset_Map
end
def update
if @panorama_name!=@map.panorama_name || @panorama_hue!=@map.panorama_hue
if @panorama_name != @map.panorama_name || @panorama_hue != @map.panorama_hue
@panorama_name = @map.panorama_name
@panorama_hue = @map.panorama_hue
@panorama.set_panorama(nil) if !@panorama.bitmap.nil?
@panorama.set_panorama(@panorama_name, @panorama_hue) if !nil_or_empty?(@panorama_name)
Graphics.frame_reset
end
if @fog_name!=@map.fog_name || @fog_hue!=@map.fog_hue
if @fog_name != @map.fog_name || @fog_hue != @map.fog_hue
@fog_name = @map.fog_name
@fog_hue = @map.fog_hue
@fog.set_fog(nil) if !@fog.bitmap.nil?
@fog.set_fog(@fog_name, @fog_hue) if !nil_or_empty?(@fog_name)
Graphics.frame_reset
end
tmox = (@map.display_x/Game_Map::X_SUBPIXELS).round
tmoy = (@map.display_y/Game_Map::Y_SUBPIXELS).round
@@viewport1.rect.set(0,0,Graphics.width,Graphics.height)
tmox = (@map.display_x / Game_Map::X_SUBPIXELS).round
tmoy = (@map.display_y / Game_Map::Y_SUBPIXELS).round
@@viewport1.rect.set(0, 0, Graphics.width, Graphics.height)
@@viewport1.ox = 0
@@viewport1.oy = 0
@@viewport1.ox += $game_screen.shake
@panorama.ox = tmox/2
@panorama.oy = tmoy/2
@fog.ox = tmox+@map.fog_ox
@fog.oy = tmoy+@map.fog_oy
@fog.zoom_x = @map.fog_zoom/100.0
@fog.zoom_y = @map.fog_zoom/100.0
@panorama.ox = tmox / 2
@panorama.oy = tmoy / 2
@fog.ox = tmox + @map.fog_ox
@fog.oy = tmoy + @map.fog_oy
@fog.zoom_x = @map.fog_zoom / 100.0
@fog.zoom_y = @map.fog_zoom / 100.0
@fog.opacity = @map.fog_opacity
@fog.blend_type = @map.fog_blend_type
@fog.tone = @map.fog_tone
@@ -124,7 +124,7 @@ class Spriteset_Map
for sprite in @character_sprites
sprite.update
end
if self.map!=$game_map
if self.map != $game_map
@weather.fade_in(:None, 0, 20)
else
@weather.fade_in($game_screen.weather_type, $game_screen.weather_max, $game_screen.weather_duration)

View File

@@ -5,7 +5,7 @@ automatically when its animation is finished.
Used for grass rustling and so forth.
=end
class AnimationSprite < RPG::Sprite
def initialize(animID,map,tileX,tileY,viewport = nil,tinting = false,height = 3)
def initialize(animID, map, tileX, tileY, viewport = nil, tinting = false, height = 3)
super(viewport)
@tileX = tileX
@tileY = tileY
@@ -14,7 +14,7 @@ class AnimationSprite < RPG::Sprite
@map = map
setCoords
pbDayNightTint(self) if tinting
self.animation($data_animations[animID],true,height)
self.animation($data_animations[animID], true, height)
end
def setCoords
@@ -46,20 +46,20 @@ class Spriteset_Map
alias _animationSprite_dispose dispose
def initialize(map = nil)
@usersprites=[]
@usersprites = []
_animationSprite_initialize(map)
end
def addUserAnimation(animID,x,y,tinting = false,height = 3)
sprite=AnimationSprite.new(animID,self.map,x,y,@@viewport1,tinting,height)
def addUserAnimation(animID, x, y, tinting = false, height = 3)
sprite = AnimationSprite.new(animID, self.map, x, y, @@viewport1, tinting, height)
addUserSprite(sprite)
return sprite
end
def addUserSprite(sprite)
for i in 0...@usersprites.length
if @usersprites[i]==nil || @usersprites[i].disposed?
@usersprites[i]=sprite
if @usersprites[i] == nil || @usersprites[i].disposed?
@usersprites[i] = sprite
return
end
end
@@ -75,7 +75,7 @@ class Spriteset_Map
end
def update
@@viewport3.tone.set(0,0,0,0)
@@viewport3.tone.set(0, 0, 0, 0)
_animationSprite_update
for i in 0...@usersprites.length
@usersprites[i].update if !@usersprites[i].disposed?

View File

@@ -7,13 +7,13 @@
class Sprite_Shadow < RPG::Sprite
attr_accessor :character
def initialize(viewport, character = nil,params = [])
def initialize(viewport, character = nil, params = [])
super(viewport)
@source = params[0]
@anglemin = (params.size>1) ? params[1] : 0
@anglemax = (params.size>2) ? params[2] : 0
@self_opacity = (params.size>4) ? params[4] : 100
@distancemax = (params.size>3) ? params[3] : 350
@anglemin = (params.size > 1) ? params[1] : 0
@anglemax = (params.size > 2) ? params[2] : 0
@self_opacity = (params.size > 4) ? params[4] : 100
@distancemax = (params.size > 3) ? params[3] : 350
@character = character
update
end
@@ -47,7 +47,7 @@ class Sprite_Shadow < RPG::Sprite
else
@chbitmap.dispose if @chbitmap
@chbitmap = AnimatedBitmap.new(
'Graphics/Characters/'+@character.character_name,@character.character_hue)
'Graphics/Characters/' + @character.character_name, @character.character_hue)
@cw = @chbitmap.width / 4
@ch = @chbitmap.height / 4
self.ox = @cw / 2
@@ -75,8 +75,8 @@ class Sprite_Shadow < RPG::Sprite
self.src_rect.set(sx, sy, @cw, @ch)
end
self.x = ScreenPosHelper.pbScreenX(@character)
self.y = ScreenPosHelper.pbScreenY(@character)-5
self.z = ScreenPosHelper.pbScreenZ(@character,@ch)-1
self.y = ScreenPosHelper.pbScreenY(@character) - 5
self.z = ScreenPosHelper.pbScreenZ(@character, @ch) - 1
self.zoom_x = ScreenPosHelper.pbScreenZoomX(@character)
self.zoom_y = ScreenPosHelper.pbScreenZoomY(@character)
self.blend_type = @character.blend_type
@@ -89,10 +89,10 @@ class Sprite_Shadow < RPG::Sprite
@deltax = ScreenPosHelper.pbScreenX(@source) - self.x
@deltay = ScreenPosHelper.pbScreenY(@source) - self.y
self.color = Color.new(0, 0, 0)
@distance = ((@deltax ** 2) + (@deltay ** 2))
@distance = ((@deltax**2) + (@deltay**2))
self.opacity = @self_opacity * 13000 / ((@distance * 370 / @distancemax) + 6000)
self.angle = 57.3 * Math.atan2(@deltax, @deltay)
@angle_trigo = self.angle+90
@angle_trigo = self.angle + 90
@angle_trigo += 360 if @angle_trigo < 0
if @anglemin != 0 || @anglemax != 0
if (@angle_trigo < @anglemin || @angle_trigo > @anglemax) && @anglemin < @anglemax
@@ -132,9 +132,9 @@ class Sprite_Character < RPG::Sprite
shadow_initialize(viewport, @character)
end
def setShadows(map,shadows)
def setShadows(map, shadows)
if character.is_a?(Game_Event) && shadows.length > 0
params = XPML_read(map,"Shadow",@character,4)
params = XPML_read(map, "Shadow", @character, 4)
if params != nil
for i in 0...shadows.size
@ombrelist.push(Sprite_Shadow.new(viewport, @character, shadows[i]))
@@ -158,7 +158,7 @@ class Sprite_Character < RPG::Sprite
def update
shadow_update
if @ombrelist.length>0
if @ombrelist.length > 0
for i in 0...@ombrelist.size
@ombrelist[i].update
end
@@ -193,7 +193,7 @@ class Spriteset_Map
warn = true if (ev.list != nil && ev.list.length > 0 &&
ev.list[0].code == 108 &&
(ev.list[0].parameters == ["s"] || ev.list[0].parameters == ["o"]))
params = XPML_read(map,"Shadow Source", ev, 4)
params = XPML_read(map, "Shadow Source", ev, 4)
@shadows.push([ev] + params) if params != nil
end
if warn == true
@@ -228,14 +228,14 @@ end
# p XPML_read("third", event_id) -> [3]
# p XPML_read("forth", event_id) -> nil
#===================================================
def XPML_read(map,markup,event,max_param_number = 0)
def XPML_read(map, markup, event, max_param_number = 0)
parameter_list = nil
return nil if !event || event.list == nil
for i in 0...event.list.size
if event.list[i].code == 108 &&
event.list[i].parameters[0].downcase == "begin " + markup.downcase
parameter_list = [] if parameter_list == nil
for j in i+1...event.list.size
for j in (i + 1)...event.list.size
if event.list[j].code == 108
parts = event.list[j].parameters[0].split
if parts.size != 1 && parts[0].downcase != "begin"

View File

@@ -2,7 +2,7 @@
# Based on version 2 by Near Fantastica, 04.01.06
# In turn based on the Particle Engine designed by PinkMan
class Particle_Engine
def initialize(viewport = nil,map = nil)
def initialize(viewport = nil, map = nil)
@map = (map) ? map : $game_map
@viewport = viewport
@effect = []
@@ -54,7 +54,7 @@ class Particle_Engine
@effect.delete_at(event.id)
end
def realloc_effect(event,particle)
def realloc_effect(event, particle)
type = pbEventCommentInput(event, 1, "Particle Engine Type")
if type.nil?
particle.dispose if particle
@@ -68,13 +68,13 @@ class Particle_Engine
end
if !particle || !particle.is_a?(cls)
particle.dispose if particle
particle = cls.new(event,@viewport)
particle = cls.new(event, @viewport)
end
return particle
end
def pbParticleEffect(event)
return realloc_effect(event,nil)
return realloc_effect(event, nil)
end
def update
@@ -91,7 +91,7 @@ class Particle_Engine
if particle.event.pe_refresh
event = particle.event
event.pe_refresh = false
particle = realloc_effect(event,particle)
particle = realloc_effect(event, particle)
@effect[i] = particle
end
particle.update if particle
@@ -153,21 +153,21 @@ class ParticleSprite
def update
w = Graphics.width
h = Graphics.height
if !@sprite && @x>=@minleft && @y>=@mintop && @x<w && @y<h
if !@sprite && @x >= @minleft && @y >= @mintop && @x < w && @y < h
@sprite = Sprite.new(@viewport)
elsif @sprite && (@x<@minleft || @y<@mintop || @x>=w || @y>=h)
elsif @sprite && (@x < @minleft || @y < @mintop || @x >= w || @y >= h)
@sprite.dispose
@sprite = nil
end
if @sprite
@sprite.x = @x if @sprite.x!=@x
@sprite.x = @x if @sprite.x != @x
@sprite.x -= @ox
@sprite.y = @y if @sprite.y!=@y
@sprite.y = @y if @sprite.y != @y
@sprite.y -= @oy
@sprite.z = @z if @sprite.z!=@z
@sprite.opacity = @opacity if @sprite.opacity!=@opacity
@sprite.blend_type = @blend_type if @sprite.blend_type!=@blend_type
@sprite.bitmap = @bitmap if @sprite.bitmap!=@bitmap
@sprite.z = @z if @sprite.z != @z
@sprite.opacity = @opacity if @sprite.opacity != @opacity
@sprite.blend_type = @blend_type if @sprite.blend_type != @blend_type
@sprite.bitmap = @bitmap if @sprite.bitmap != @bitmap
end
end
end
@@ -177,7 +177,7 @@ end
class ParticleEffect_Event < ParticleEffect
attr_accessor :event
def initialize(event,viewport = nil)
def initialize(event, viewport = nil)
@event = event
@viewport = viewport
@particles = []
@@ -185,24 +185,24 @@ class ParticleEffect_Event < ParticleEffect
end
def setParameters(params)
@randomhue,@leftright,@fade,
@maxparticless,@hue,@slowdown,
@ytop,@ybottom,@xleft,@xright,
@xgravity,@ygravity,@xoffset,@yoffset,
@opacityvar,@originalopacity = params
@randomhue, @leftright, @fade,
@maxparticless, @hue, @slowdown,
@ytop, @ybottom, @xleft, @xright,
@xgravity, @ygravity, @xoffset, @yoffset,
@opacityvar, @originalopacity = params
end
def loadBitmap(filename,hue)
key = [filename,hue]
def loadBitmap(filename, hue)
key = [filename, hue]
bitmap = @bitmaps[key]
if !bitmap || bitmap.disposed?
bitmap = AnimatedBitmap.new("Graphics/Fogs/"+filename,hue).deanimate
bitmap = AnimatedBitmap.new("Graphics/Fogs/" + filename, hue).deanimate
@bitmaps[key] = bitmap
end
return bitmap
end
def initParticles(filename,opacity,zOffset = 0,blendtype = 1)
def initParticles(filename, opacity, zOffset = 0, blendtype = 1)
@particles = []
@particlex = []
@particley = []
@@ -222,15 +222,15 @@ class ParticleEffect_Event < ParticleEffect
@particley[i] = -@yoffset
@particles[i] = ParticleSprite.new(@viewport)
@particles[i].bitmap = loadBitmap(filename, @hue) if filename
if i==0 && @particles[i].bitmap
if i == 0 && @particles[i].bitmap
@bmwidth = @particles[i].bitmap.width
@bmheight = @particles[i].bitmap.height
end
@particles[i].blend_type = blendtype
@particles[i].y = @startingy
@particles[i].x = @startingx
@particles[i].z = self.z+zOffset
@opacity[i] = rand(opacity/4)
@particles[i].z = self.z + zOffset
@opacity[i] = rand(opacity / 4)
@particles[i].opacity = @opacity[i]
@particles[i].update
end
@@ -253,28 +253,28 @@ class ParticleEffect_Event < ParticleEffect
newRealY = @event.real_y
@startingx = selfX + @xoffset
@startingy = selfY + @yoffset
@__offsetx = (@real_x==newRealX) ? 0 : selfX-@screen_x
@__offsety = (@real_y==newRealY) ? 0 : selfY-@screen_y
@__offsetx = (@real_x == newRealX) ? 0 : selfX - @screen_x
@__offsety = (@real_y == newRealY) ? 0 : selfY - @screen_y
@screen_x = selfX
@screen_y = selfY
@real_x = newRealX
@real_y = newRealY
if @opacityvar>0 && @viewport
opac = 255.0/@opacityvar
minX = opac*(-@xgravity*1.0 / @slowdown).floor + @startingx
maxX = opac*(@xgravity*1.0 / @slowdown).floor + @startingx
minY = opac*(-@ygravity*1.0 / @slowdown).floor + @startingy
if @opacityvar > 0 && @viewport
opac = 255.0 / @opacityvar
minX = opac * (-@xgravity * 1.0 / @slowdown).floor + @startingx
maxX = opac * (@xgravity * 1.0 / @slowdown).floor + @startingx
minY = opac * (-@ygravity * 1.0 / @slowdown).floor + @startingy
maxY = @startingy
minX -= @bmwidth
minY -= @bmheight
maxX += @bmwidth
maxY += @bmheight
if maxX<0 || maxY<0 || minX>=Graphics.width || minY>=Graphics.height
if maxX < 0 || maxY < 0 || minX >= Graphics.width || minY >= Graphics.height
# echo "skipped"
return
end
end
particleZ = selfZ+@zoffset
particleZ = selfZ + @zoffset
for i in 0...@maxparticless
@particles[i].z = particleZ
if @particles[i].y <= @ytop
@@ -333,19 +333,19 @@ class ParticleEffect_Event < ParticleEffect
def calcParticlePos(i)
@leftright = rand(2)
if @leftright == 1
xo = -@xgravity*1.0 / @slowdown
xo = -@xgravity * 1.0 / @slowdown
else
xo = @xgravity*1.0 / @slowdown
xo = @xgravity * 1.0 / @slowdown
end
yo = -@ygravity*1.0 / @slowdown
yo = -@ygravity * 1.0 / @slowdown
@particlex[i] += xo
@particley[i] += yo
@particlex[i] -= @__offsetx
@particley[i] -= @__offsety
@particlex[i] = @particlex[i].floor
@particley[i] = @particley[i].floor
@particles[i].x = @particlex[i]+@startingx+@xoffset
@particles[i].y = @particley[i]+@startingy+@yoffset
@particles[i].x = @particlex[i] + @startingx + @xoffset
@particles[i].y = @particley[i] + @startingy + @yoffset
end
def dispose
@@ -363,33 +363,33 @@ end
class Particle_Engine::Fire < ParticleEffect_Event
def initialize(event,viewport)
def initialize(event, viewport)
super
setParameters([0,0,1,20,40,0.5,-64,
Graphics.height,-64,Graphics.width,0.5,0.10,-5,-13,30,0])
initParticles("particle",250)
setParameters([0, 0, 1, 20, 40, 0.5, -64,
Graphics.height, -64, Graphics.width, 0.5, 0.10, -5, -13, 30, 0])
initParticles("particle", 250)
end
end
class Particle_Engine::Smoke < ParticleEffect_Event
def initialize(event,viewport)
def initialize(event, viewport)
super
setParameters([0,0,0,80,20,0.5,-64,
Graphics.height,-64,Graphics.width,0.5,0.10,-5,-15,5,80])
initParticles("smoke",250)
setParameters([0, 0, 0, 80, 20, 0.5, -64,
Graphics.height, -64, Graphics.width, 0.5, 0.10, -5, -15, 5, 80])
initParticles("smoke", 250)
end
end
class Particle_Engine::Teleport < ParticleEffect_Event
def initialize(event,viewport)
def initialize(event, viewport)
super
setParameters([1,1,1,10,rand(360),1,-64,
Graphics.height,-64,Graphics.width,0,3,-8,-15,20,0])
initParticles("wideportal",250)
setParameters([1, 1, 1, 10, rand(360), 1, -64,
Graphics.height, -64, Graphics.width, 0, 3, -8, -15, 20, 0])
initParticles("wideportal", 250)
for i in 0...@maxparticless
@particles[i].ox = 16
@particles[i].oy = 16
@@ -400,55 +400,55 @@ end
class Particle_Engine::Spirit < ParticleEffect_Event
def initialize(event,viewport)
def initialize(event, viewport)
super
setParameters([1,0,1,20,rand(360),0.5,-64,
Graphics.height,-64,Graphics.width,0.5,0.10,-5,-13,30,0])
initParticles("particle",250)
setParameters([1, 0, 1, 20, rand(360), 0.5, -64,
Graphics.height, -64, Graphics.width, 0.5, 0.10, -5, -13, 30, 0])
initParticles("particle", 250)
end
end
class Particle_Engine::Explosion < ParticleEffect_Event
def initialize(event,viewport)
def initialize(event, viewport)
super
setParameters([0,0,1,20,0,0.5,-64,
Graphics.height,-64,Graphics.width,0.5,0.10,-5,-13,30,0])
initParticles("explosion",250)
setParameters([0, 0, 1, 20, 0, 0.5, -64,
Graphics.height, -64, Graphics.width, 0.5, 0.10, -5, -13, 30, 0])
initParticles("explosion", 250)
end
end
class Particle_Engine::Aura < ParticleEffect_Event
def initialize(event,viewport)
def initialize(event, viewport)
super
setParameters([0,0,1,20,0,1,-64,
Graphics.height,-64,Graphics.width,2,2,-5,-13,30,0])
initParticles("particle",250)
setParameters([0, 0, 1, 20, 0, 1, -64,
Graphics.height, -64, Graphics.width, 2, 2, -5, -13, 30, 0])
initParticles("particle", 250)
end
end
class Particle_Engine::Soot < ParticleEffect_Event
def initialize(event,viewport)
def initialize(event, viewport)
super
setParameters([0,0,0,20,0,0.5,-64,
Graphics.height,-64,Graphics.width,0.5,0.10,-5,-15,5,80])
initParticles("smoke",100,0,2)
setParameters([0, 0, 0, 20, 0, 0.5, -64,
Graphics.height, -64, Graphics.width, 0.5, 0.10, -5, -15, 5, 80])
initParticles("smoke", 100, 0, 2)
end
end
class Particle_Engine::SootSmoke < ParticleEffect_Event
def initialize(event,viewport)
def initialize(event, viewport)
super
setParameters([0,0,0,30,0,0.5,-64,
Graphics.height,-64,Graphics.width,0.5,0.10,-5,-15,5,80])
initParticles("smoke",100,0)
setParameters([0, 0, 0, 30, 0, 0.5, -64,
Graphics.height, -64, Graphics.width, 0.5, 0.10, -5, -15, 5, 80])
initParticles("smoke", 100, 0)
for i in 0...@maxparticless
@particles[i].blend_type = rand(6) < 3 ? 1 : 2
end
@@ -458,22 +458,22 @@ end
class Particle_Engine::Rocket < ParticleEffect_Event
def initialize(event,viewport)
def initialize(event, viewport)
super
setParameters([0,0,0,60,0,0.5,-64,
Graphics.height,-64,Graphics.width,0.5,0,-5,-15,5,80])
initParticles("smoke",100,-1)
setParameters([0, 0, 0, 60, 0, 0.5, -64,
Graphics.height, -64, Graphics.width, 0.5, 0, -5, -15, 5, 80])
initParticles("smoke", 100, -1)
end
end
class Particle_Engine::FixedTeleport < ParticleEffect_Event
def initialize(event,viewport)
def initialize(event, viewport)
super
setParameters([1,0,1,10,rand(360),1,
-Graphics.height,Graphics.height,0,Graphics.width,0,3,-8,-15,20,0])
initParticles("wideportal",250)
setParameters([1, 0, 1, 10, rand(360), 1,
-Graphics.height, Graphics.height, 0, Graphics.width, 0, 3, -8, -15, 20, 0])
initParticles("wideportal", 250)
for i in 0...@maxparticless
@particles[i].ox = 16
@particles[i].oy = 16
@@ -485,11 +485,11 @@ end
# By Peter O.
class Particle_Engine::StarTeleport < ParticleEffect_Event
def initialize(event,viewport)
def initialize(event, viewport)
super
setParameters([0,0,1,10,0,1,
-Graphics.height,Graphics.height,0,Graphics.width,0,3,-8,-15,10,0])
initParticles("star",250)
setParameters([0, 0, 1, 10, 0, 1,
-Graphics.height, Graphics.height, 0, Graphics.width, 0, 3, -8, -15, 10, 0])
initParticles("star", 250)
for i in 0...@maxparticless
@particles[i].ox = 48
@particles[i].oy = 48
@@ -500,59 +500,59 @@ end
class Particle_Engine::Smokescreen < ParticleEffect_Event
def initialize(event,viewport)
def initialize(event, viewport)
super
setParameters([0,0,0,250,0,0.2,-64,
Graphics.height,-64,Graphics.width,0.8,0.8,-5,-15,5,80])
initParticles(nil,100)
setParameters([0, 0, 0, 250, 0, 0.2, -64,
Graphics.height, -64, Graphics.width, 0.8, 0.8, -5, -15, 5, 80])
initParticles(nil, 100)
for i in 0...@maxparticless
rnd = rand(3)
@opacity[i] = (rnd==0) ? 1 : 100
filename = (rnd==0) ? "explosionsmoke" : "smoke"
@opacity[i] = (rnd == 0) ? 1 : 100
filename = (rnd == 0) ? "explosionsmoke" : "smoke"
@particles[i].bitmap = loadBitmap(filename, @hue)
end
end
def calcParticlePos(i)
if @randomhue==1
filename = (rand(3)==0) ? "explosionsmoke" : "smoke"
if @randomhue == 1
filename = (rand(3) == 0) ? "explosionsmoke" : "smoke"
@particles[i].bitmap = loadBitmap(filename, @hue)
end
multiple = 1.7
xgrav = @xgravity*multiple/@slowdown
xgrav = -xgrav if (rand(2)==1)
ygrav = @ygravity*multiple/@slowdown
ygrav = -ygrav if (rand(2)==1)
xgrav = @xgravity * multiple / @slowdown
xgrav = -xgrav if (rand(2) == 1)
ygrav = @ygravity * multiple / @slowdown
ygrav = -ygrav if (rand(2) == 1)
@particlex[i] += xgrav
@particley[i] += ygrav
@particlex[i] -= @__offsetx
@particley[i] -= @__offsety
@particlex[i] = @particlex[i].floor
@particley[i] = @particley[i].floor
@particles[i].x = @particlex[i]+@startingx+@xoffset
@particles[i].y = @particley[i]+@startingy+@yoffset
@particles[i].x = @particlex[i] + @startingx + @xoffset
@particles[i].y = @particley[i] + @startingy + @yoffset
end
end
class Particle_Engine::Flare < ParticleEffect_Event
def initialize(event,viewport)
def initialize(event, viewport)
super
setParameters([0,0,1,30,10,1,-64,
Graphics.height,-64,Graphics.width,2,2,-5,-12,30,0])
initParticles("particle",255)
setParameters([0, 0, 1, 30, 10, 1, -64,
Graphics.height, -64, Graphics.width, 2, 2, -5, -12, 30, 0])
initParticles("particle", 255)
end
end
class Particle_Engine::Splash < ParticleEffect_Event
def initialize(event,viewport)
def initialize(event, viewport)
super
setParameters([0,0,1,30,255,1,-64,
Graphics.height,-64,Graphics.width,4,2,-5,-12,30,0])
initParticles("smoke",50)
setParameters([0, 0, 1, 30, 255, 1, -64,
Graphics.height, -64, Graphics.width, 4, 2, -5, -12, 30, 0])
initParticles("smoke", 50)
end
def update
@@ -570,7 +570,7 @@ class Game_Event < Game_Character
attr_accessor :pe_refresh
alias nf_particles_game_map_initialize initialize
def initialize(map_id,event,map = nil)
def initialize(map_id, event, map = nil)
@pe_refresh = false
begin
nf_particles_game_map_initialize(map_id, event, map)

View File

@@ -37,7 +37,7 @@ end
def getCubicPoint2(src,t)
def getCubicPoint2(src, t)
x0 = src[0]
y0 = src[1]
cx0 = src[2]
@@ -47,29 +47,29 @@ def getCubicPoint2(src,t)
x1 = src[6]
y1 = src[7]
x1 = cx1+(x1-cx1)*t
x0 = x0+(cx0-x0)*t
cx0 = cx0+(cx1-cx0)*t
cx1 = cx0+(x1-cx0)*t
cx0 = x0+(cx0-x0)*t
cx = cx0+(cx1-cx0)*t
x1 = cx1 + (x1 - cx1) * t
x0 = x0 + (cx0 - x0) * t
cx0 = cx0 + (cx1 - cx0) * t
cx1 = cx0 + (x1 - cx0) * t
cx0 = x0 + (cx0 - x0) * t
cx = cx0 + (cx1 - cx0) * t
# a = x1 - 3 * cx1 + 3 * cx0 - x0
# b = 3 * (cx1 - 2 * cx0 + x0)
# c = 3 * (cx0 - x0)
# d = x0
# cx = a*t*t*t + b*t*t + c*t + d
y1 = cy1+(y1-cy1)*t
y0 = y0+(cy0-y0)*t
cy0 = cy0+(cy1-cy0)*t
cy1 = cy0+(y1-cy0)*t
cy0 = y0+(cy0-y0)*t
cy = cy0+(cy1-cy0)*t
y1 = cy1 + (y1 - cy1) * t
y0 = y0 + (cy0 - y0) * t
cy0 = cy0 + (cy1 - cy0) * t
cy1 = cy0 + (y1 - cy0) * t
cy0 = y0 + (cy0 - y0) * t
cy = cy0 + (cy1 - cy0) * t
# a = y1 - 3 * cy1 + 3 * cy0 - y0
# b = 3 * (cy1 - 2 * cy0 + y0)
# c = 3 * (cy0 - y0)
# d = y0
# cy = a*t*t*t + b*t*t + c*t + d
return [cx,cy]
return [cx, cy]
end
@@ -115,7 +115,7 @@ class PictureEx
@blend_type = 0
@name = ""
@origin = PictureOrigin::TopLeft
@src_rect = Rect.new(0,0,-1,-1)
@src_rect = Rect.new(0, 0, -1, -1)
@cropBottom = -1
@frameUpdates = []
end
@@ -132,28 +132,28 @@ class PictureEx
def setCallback(delay, cb = nil)
delay = ensureDelayAndDuration(delay)
@processes.push([nil,delay,0,0,cb])
@processes.push([nil, delay, 0, 0, cb])
end
def running?
return @processes.length>0
return @processes.length > 0
end
def totalDuration
ret = 0
for process in @processes
dur = process[1]+process[2]
ret = dur if dur>ret
dur = process[1] + process[2]
ret = dur if dur > ret
end
ret *= 20.0/Graphics.frame_rate
ret *= 20.0 / Graphics.frame_rate
return ret.to_i
end
def ensureDelayAndDuration(delay, duration = nil)
delay = self.totalDuration if delay<0
delay *= Graphics.frame_rate/20.0
delay = self.totalDuration if delay < 0
delay *= Graphics.frame_rate / 20.0
if !duration.nil?
duration *= Graphics.frame_rate/20.0
duration *= Graphics.frame_rate / 20.0
return delay.to_i, duration.to_i
end
return delay.to_i
@@ -169,8 +169,8 @@ class PictureEx
# point. If you make a sprite auto-rotate, you should not try to alter
# the angle another way too.
def rotate(speed)
@rotate_speed = speed*20.0/Graphics.frame_rate
while @rotate_speed<0
@rotate_speed = speed * 20.0 / Graphics.frame_rate
while @rotate_speed < 0
@rotate_speed += 360
end
@rotate_speed %= 360
@@ -186,7 +186,7 @@ class PictureEx
def adjustPosition(xOffset, yOffset)
for process in @processes
next if process[0]!=Processes::XY
next if process[0] != Processes::XY
process[5] += xOffset
process[6] += yOffset
process[7] += xOffset
@@ -195,150 +195,150 @@ class PictureEx
end
def move(delay, duration, origin, x, y, zoom_x = 100.0, zoom_y = 100.0, opacity = 255)
setOrigin(delay,duration,origin)
moveXY(delay,duration,x,y)
moveZoomXY(delay,duration,zoom_x,zoom_y)
moveOpacity(delay,duration,opacity)
setOrigin(delay, duration, origin)
moveXY(delay, duration, x, y)
moveZoomXY(delay, duration, zoom_x, zoom_y)
moveOpacity(delay, duration, opacity)
end
def moveXY(delay, duration, x, y, cb = nil)
delay, duration = ensureDelayAndDuration(delay,duration)
@processes.push([Processes::XY,delay,duration,0,cb,@x,@y,x,y])
delay, duration = ensureDelayAndDuration(delay, duration)
@processes.push([Processes::XY, delay, duration, 0, cb, @x, @y, x, y])
end
def setXY(delay, x, y, cb = nil)
moveXY(delay,0,x,y,cb)
moveXY(delay, 0, x, y, cb)
end
def moveCurve(delay, duration, x1, y1, x2, y2, x3, y3, cb = nil)
delay, duration = ensureDelayAndDuration(delay,duration)
@processes.push([Processes::Curve,delay,duration,0,cb,[@x,@y,x1,y1,x2,y2,x3,y3]])
delay, duration = ensureDelayAndDuration(delay, duration)
@processes.push([Processes::Curve, delay, duration, 0, cb, [@x, @y, x1, y1, x2, y2, x3, y3]])
end
def moveDelta(delay, duration, x, y, cb = nil)
delay, duration = ensureDelayAndDuration(delay,duration)
@processes.push([Processes::DeltaXY,delay,duration,0,cb,@x,@y,x,y])
delay, duration = ensureDelayAndDuration(delay, duration)
@processes.push([Processes::DeltaXY, delay, duration, 0, cb, @x, @y, x, y])
end
def setDelta(delay, x, y, cb = nil)
moveDelta(delay,0,x,y,cb)
moveDelta(delay, 0, x, y, cb)
end
def moveZ(delay, duration, z, cb = nil)
delay, duration = ensureDelayAndDuration(delay,duration)
@processes.push([Processes::Z,delay,duration,0,cb,@z,z])
delay, duration = ensureDelayAndDuration(delay, duration)
@processes.push([Processes::Z, delay, duration, 0, cb, @z, z])
end
def setZ(delay, z, cb = nil)
moveZ(delay,0,z,cb)
moveZ(delay, 0, z, cb)
end
def moveZoomXY(delay, duration, zoom_x, zoom_y, cb = nil)
delay, duration = ensureDelayAndDuration(delay,duration)
@processes.push([Processes::Zoom,delay,duration,0,cb,@zoom_x,@zoom_y,zoom_x,zoom_y])
delay, duration = ensureDelayAndDuration(delay, duration)
@processes.push([Processes::Zoom, delay, duration, 0, cb, @zoom_x, @zoom_y, zoom_x, zoom_y])
end
def setZoomXY(delay, zoom_x, zoom_y, cb = nil)
moveZoomXY(delay,0,zoom_x,zoom_y,cb)
moveZoomXY(delay, 0, zoom_x, zoom_y, cb)
end
def moveZoom(delay, duration, zoom, cb = nil)
moveZoomXY(delay,duration,zoom,zoom,cb)
moveZoomXY(delay, duration, zoom, zoom, cb)
end
def setZoom(delay, zoom, cb = nil)
moveZoomXY(delay,0,zoom,zoom,cb)
moveZoomXY(delay, 0, zoom, zoom, cb)
end
def moveAngle(delay, duration, angle, cb = nil)
delay, duration = ensureDelayAndDuration(delay,duration)
@processes.push([Processes::Angle,delay,duration,0,cb,@angle,angle])
delay, duration = ensureDelayAndDuration(delay, duration)
@processes.push([Processes::Angle, delay, duration, 0, cb, @angle, angle])
end
def setAngle(delay, angle, cb = nil)
moveAngle(delay,0,angle,cb)
moveAngle(delay, 0, angle, cb)
end
def moveTone(delay, duration, tone, cb = nil)
delay, duration = ensureDelayAndDuration(delay,duration)
target = (tone) ? tone.clone : Tone.new(0,0,0,0)
@processes.push([Processes::Tone,delay,duration,0,cb,@tone.clone,target])
delay, duration = ensureDelayAndDuration(delay, duration)
target = (tone) ? tone.clone : Tone.new(0, 0, 0, 0)
@processes.push([Processes::Tone, delay, duration, 0, cb, @tone.clone, target])
end
def setTone(delay, tone, cb = nil)
moveTone(delay,0,tone,cb)
moveTone(delay, 0, tone, cb)
end
def moveColor(delay, duration, color, cb = nil)
delay, duration = ensureDelayAndDuration(delay,duration)
target = (color) ? color.clone : Color.new(0,0,0,0)
@processes.push([Processes::Color,delay,duration,0,cb,@color.clone,target])
delay, duration = ensureDelayAndDuration(delay, duration)
target = (color) ? color.clone : Color.new(0, 0, 0, 0)
@processes.push([Processes::Color, delay, duration, 0, cb, @color.clone, target])
end
def setColor(delay, color, cb = nil)
moveColor(delay,0,color,cb)
moveColor(delay, 0, color, cb)
end
# Hue changes don't actually work.
def moveHue(delay, duration, hue, cb = nil)
delay, duration = ensureDelayAndDuration(delay,duration)
@processes.push([Processes::Hue,delay,duration,0,cb,@hue,hue])
delay, duration = ensureDelayAndDuration(delay, duration)
@processes.push([Processes::Hue, delay, duration, 0, cb, @hue, hue])
end
# Hue changes don't actually work.
def setHue(delay, hue, cb = nil)
moveHue(delay,0,hue,cb)
moveHue(delay, 0, hue, cb)
end
def moveOpacity(delay, duration, opacity, cb = nil)
delay, duration = ensureDelayAndDuration(delay,duration)
@processes.push([Processes::Opacity,delay,duration,0,cb,@opacity,opacity])
delay, duration = ensureDelayAndDuration(delay, duration)
@processes.push([Processes::Opacity, delay, duration, 0, cb, @opacity, opacity])
end
def setOpacity(delay, opacity, cb = nil)
moveOpacity(delay,0,opacity,cb)
moveOpacity(delay, 0, opacity, cb)
end
def setVisible(delay, visible, cb = nil)
delay = ensureDelay(delay)
@processes.push([Processes::Visible,delay,0,0,cb,visible])
@processes.push([Processes::Visible, delay, 0, 0, cb, visible])
end
# Only values of 0 (normal), 1 (additive) and 2 (subtractive) are allowed.
def setBlendType(delay, blend, cb = nil)
delay = ensureDelayAndDuration(delay)
@processes.push([Processes::BlendType,delay,0,0,cb,blend])
@processes.push([Processes::BlendType, delay, 0, 0, cb, blend])
end
def setSE(delay, seFile, volume = nil, pitch = nil, cb = nil)
delay = ensureDelay(delay)
@processes.push([Processes::SE,delay,0,0,cb,seFile,volume,pitch])
@processes.push([Processes::SE, delay, 0, 0, cb, seFile, volume, pitch])
end
def setName(delay, name, cb = nil)
delay = ensureDelay(delay)
@processes.push([Processes::Name,delay,0,0,cb,name])
@processes.push([Processes::Name, delay, 0, 0, cb, name])
end
def setOrigin(delay, origin, cb = nil)
delay = ensureDelay(delay)
@processes.push([Processes::Origin,delay,0,0,cb,origin])
@processes.push([Processes::Origin, delay, 0, 0, cb, origin])
end
def setSrc(delay, srcX, srcY, cb = nil)
delay = ensureDelay(delay)
@processes.push([Processes::Src,delay,0,0,cb,srcX,srcY])
@processes.push([Processes::Src, delay, 0, 0, cb, srcX, srcY])
end
def setSrcSize(delay, srcWidth, srcHeight, cb = nil)
delay = ensureDelay(delay)
@processes.push([Processes::SrcSize,delay,0,0,cb,srcWidth,srcHeight])
@processes.push([Processes::SrcSize, delay, 0, 0, cb, srcWidth, srcHeight])
end
# Used to cut Pokémon sprites off when they faint and sink into the ground.
def setCropBottom(delay, y, cb = nil)
delay = ensureDelay(delay)
@processes.push([Processes::CropBottom,delay,0,0,cb,y])
@processes.push([Processes::CropBottom, delay, 0, 0, cb, y])
end
def update
@@ -347,9 +347,9 @@ class PictureEx
for i in 0...@processes.length
process = @processes[i]
# Decrease delay of processes that are scheduled to start later
if process[1]>=0
if process[1] >= 0
# Set initial values if the process will start this frame
if process[1]==0
if process[1] == 0
case process[0]
when Processes::XY
process[5] = @x
@@ -382,18 +382,18 @@ class PictureEx
# Decrease delay counter
process[1] -= 1
# Process hasn't started yet, skip to the next one
next if process[1]>=0
next if process[1] >= 0
end
# Update process
@frameUpdates.push(process[0]) if !@frameUpdates.include?(process[0])
fra = (process[2]==0) ? 1 : process[3] # Frame counter
dur = (process[2]==0) ? 1 : process[2] # Total duration of process
fra = (process[2] == 0) ? 1 : process[3] # Frame counter
dur = (process[2] == 0) ? 1 : process[2] # Total duration of process
case process[0]
when Processes::XY, Processes::DeltaXY
@x = process[5] + fra * (process[7] - process[5]) / dur
@y = process[6] + fra * (process[8] - process[6]) / dur
when Processes::Curve
@x, @y = getCubicPoint2(process[5],fra.to_f/dur)
@x, @y = getCubicPoint2(process[5], fra.to_f / dur)
when Processes::Z
@z = process[5] + fra * (process[6] - process[5]) / dur
when Processes::Zoom
@@ -420,7 +420,7 @@ class PictureEx
when Processes::BlendType
@blend_type = process[5]
when Processes::SE
pbSEPlay(process[5],process[6],process[7])
pbSEPlay(process[5], process[6], process[7])
when Processes::Name
@name = process[5]
when Processes::Origin
@@ -436,7 +436,7 @@ class PictureEx
end
# Increase frame counter
process[3] += 1
if process[3]>process[2]
if process[3] > process[2]
# Process has ended, erase it
callback(process[4]) if process[4]
@processes[i] = nil
@@ -449,7 +449,7 @@ class PictureEx
if @rotate_speed != 0
@frameUpdates.push(Processes::Angle) if !@frameUpdates.include?(Processes::Angle)
@angle += @rotate_speed
while @angle<0
while @angle < 0
@angle += 360
end
@angle %= 360
@@ -463,7 +463,7 @@ end
#
#===============================================================================
def setPictureSprite(sprite, picture, iconSprite = false)
return if picture.frameUpdates.length==0
return if picture.frameUpdates.length == 0
for i in 0...picture.frameUpdates.length
case picture.frameUpdates[i]
when Processes::XY, Processes::DeltaXY
@@ -495,7 +495,7 @@ def setPictureSprite(sprite, picture, iconSprite = false)
when PictureOrigin::TopLeft, PictureOrigin::Left, PictureOrigin::BottomLeft
sprite.ox = 0
when PictureOrigin::Top, PictureOrigin::Center, PictureOrigin::Bottom
sprite.ox = (sprite.bitmap && !sprite.bitmap.disposed?) ? sprite.src_rect.width/2 : 0
sprite.ox = (sprite.bitmap && !sprite.bitmap.disposed?) ? sprite.src_rect.width / 2 : 0
when PictureOrigin::TopRight, PictureOrigin::Right, PictureOrigin::BottomRight
sprite.ox = (sprite.bitmap && !sprite.bitmap.disposed?) ? sprite.src_rect.width : 0
end
@@ -503,7 +503,7 @@ def setPictureSprite(sprite, picture, iconSprite = false)
when PictureOrigin::TopLeft, PictureOrigin::Top, PictureOrigin::TopRight
sprite.oy = 0
when PictureOrigin::Left, PictureOrigin::Center, PictureOrigin::Right
sprite.oy = (sprite.bitmap && !sprite.bitmap.disposed?) ? sprite.src_rect.height/2 : 0
sprite.oy = (sprite.bitmap && !sprite.bitmap.disposed?) ? sprite.src_rect.height / 2 : 0
when PictureOrigin::BottomLeft, PictureOrigin::Bottom, PictureOrigin::BottomRight
sprite.oy = (sprite.bitmap && !sprite.bitmap.disposed?) ? sprite.src_rect.height : 0
end
@@ -517,14 +517,14 @@ def setPictureSprite(sprite, picture, iconSprite = false)
sprite.src_rect.height = picture.src_rect.height
end
end
if iconSprite && sprite.src_rect && picture.cropBottom>=0
spriteBottom = sprite.y-sprite.oy+sprite.src_rect.height
if spriteBottom>picture.cropBottom
sprite.src_rect.height = [picture.cropBottom-sprite.y+sprite.oy,0].max
if iconSprite && sprite.src_rect && picture.cropBottom >= 0
spriteBottom = sprite.y - sprite.oy + sprite.src_rect.height
if spriteBottom > picture.cropBottom
sprite.src_rect.height = [picture.cropBottom - sprite.y + sprite.oy, 0].max
end
end
end
def setPictureIconSprite(sprite, picture)
setPictureSprite(sprite,picture,true)
setPictureSprite(sprite, picture, true)
end

View File

@@ -19,24 +19,24 @@ class Interpolator
return @tweening
end
def tween(sprite,items,frames)
def tween(sprite, items, frames)
@tweensteps = []
if sprite && !sprite.disposed? && frames>0
if sprite && !sprite.disposed? && frames > 0
@frames = frames
@step = 0
@sprite = sprite
for item in items
case item[0]
when ZOOM_X
@tweensteps[item[0]] = [sprite.zoom_x,item[1]-sprite.zoom_x]
@tweensteps[item[0]] = [sprite.zoom_x, item[1] - sprite.zoom_x]
when ZOOM_Y
@tweensteps[item[0]] = [sprite.zoom_y,item[1]-sprite.zoom_y]
@tweensteps[item[0]] = [sprite.zoom_y, item[1] - sprite.zoom_y]
when X
@tweensteps[item[0]] = [sprite.x,item[1]-sprite.x]
@tweensteps[item[0]] = [sprite.x, item[1] - sprite.x]
when Y
@tweensteps[item[0]] = [sprite.y,item[1]-sprite.y]
@tweensteps[item[0]] = [sprite.y, item[1] - sprite.y]
when OPACITY
@tweensteps[item[0]] = [sprite.opacity,item[1]-sprite.opacity]
@tweensteps[item[0]] = [sprite.opacity, item[1] - sprite.opacity]
when COLOR
@tweensteps[item[0]] = [sprite.color.clone,
Color.new(item[1].red - sprite.color.red,
@@ -51,21 +51,21 @@ class Interpolator
def update
if @tweening
t = (@step*1.0)/@frames
t = (@step * 1.0) / @frames
for i in 0...@tweensteps.length
item = @tweensteps[i]
next if !item
case i
when ZOOM_X
@sprite.zoom_x = item[0]+item[1]*t
@sprite.zoom_x = item[0] + item[1] * t
when ZOOM_Y
@sprite.zoom_y = item[0]+item[1]*t
@sprite.zoom_y = item[0] + item[1] * t
when X
@sprite.x = item[0]+item[1]*t
@sprite.x = item[0] + item[1] * t
when Y
@sprite.y = item[0]+item[1]*t
@sprite.y = item[0] + item[1] * t
when OPACITY
@sprite.opacity = item[0]+item[1]*t
@sprite.opacity = item[0] + item[1] * t
when COLOR
@sprite.color = Color.new(item[0].red + item[1].red * t,
item[0].green + item[1].green * t,
@@ -74,7 +74,7 @@ class Interpolator
end
end
@step += 1
if @step==@frames
if @step == @frames
@step = 0
@frames = 0
@tweening = false
@@ -86,46 +86,46 @@ end
class RectInterpolator
def initialize(oldrect,newrect,frames)
restart(oldrect,newrect,frames)
def initialize(oldrect, newrect, frames)
restart(oldrect, newrect, frames)
end
def restart(oldrect,newrect,frames)
def restart(oldrect, newrect, frames)
@oldrect = oldrect
@newrect = newrect
@frames = [frames,1].max
@frames = [frames, 1].max
@curframe = 0
@rect = oldrect.clone
end
def set(rect)
rect.set(@rect.x,@rect.y,@rect.width,@rect.height)
rect.set(@rect.x, @rect.y, @rect.width, @rect.height)
end
def done?
@curframe>@frames
@curframe > @frames
end
def update
return if done?
t = (@curframe*1.0/@frames)
t = (@curframe * 1.0 / @frames)
x1 = @oldrect.x
x2 = @newrect.x
x = x1+t*(x2-x1)
x = x1 + t * (x2 - x1)
y1 = @oldrect.y
y2 = @newrect.y
y = y1+t*(y2-y1)
rx1 = @oldrect.x+@oldrect.width
rx2 = @newrect.x+@newrect.width
rx = rx1+t*(rx2-rx1)
ry1 = @oldrect.y+@oldrect.height
ry2 = @newrect.y+@newrect.height
ry = ry1+t*(ry2-ry1)
minx = x<rx ? x : rx
maxx = x>rx ? x : rx
miny = y<ry ? y : ry
maxy = y>ry ? y : ry
@rect.set(minx,miny,maxx-minx,maxy-miny)
y = y1 + t * (y2 - y1)
rx1 = @oldrect.x + @oldrect.width
rx2 = @newrect.x + @newrect.width
rx = rx1 + t * (rx2 - rx1)
ry1 = @oldrect.y + @oldrect.height
ry2 = @newrect.y + @newrect.height
ry = ry1 + t * (ry2 - ry1)
minx = x < rx ? x : rx
maxx = x > rx ? x : rx
miny = y < ry ? y : ry
maxy = y > ry ? y : ry
@rect.set(minx, miny, maxx - minx, maxy - miny)
@curframe += 1
end
end
@@ -136,11 +136,11 @@ class PointInterpolator
attr_reader :x
attr_reader :y
def initialize(oldx,oldy,newx,newy,frames)
restart(oldx,oldy,newx,newy,frames)
def initialize(oldx, oldy, newx, newy, frames)
restart(oldx, oldy, newx, newy, frames)
end
def restart(oldx,oldy,newx,newy,frames)
def restart(oldx, oldy, newx, newy, frames)
@oldx = oldx
@oldy = oldy
@newx = newx
@@ -152,18 +152,18 @@ class PointInterpolator
end
def done?
@curframe>@frames
@curframe > @frames
end
def update
return if done?
t = (@curframe*1.0/@frames)
t = (@curframe * 1.0 / @frames)
rx1 = @oldx
rx2 = @newx
@x = rx1+t*(rx2-rx1)
@x = rx1 + t * (rx2 - rx1)
ry1 = @oldy
ry2 = @newy
@y = ry1+t*(ry2-ry1)
@y = ry1 + t * (ry2 - ry1)
@curframe += 1
end
end

View File

@@ -1,10 +1,10 @@
module ScreenPosHelper
def self.pbScreenZoomX(ch)
return Game_Map::TILE_WIDTH/32.0
return Game_Map::TILE_WIDTH / 32.0
end
def self.pbScreenZoomY(ch)
return Game_Map::TILE_HEIGHT/32.0
return Game_Map::TILE_HEIGHT / 32.0
end
def self.pbScreenX(ch)
@@ -15,29 +15,29 @@ module ScreenPosHelper
return ch.screen_y
end
@heightcache={}
@heightcache = {}
def self.bmHeight(bm)
h=@heightcache[bm]
h = @heightcache[bm]
if !h
bmap=AnimatedBitmap.new("Graphics/Characters/"+bm,0)
h=bmap.height
@heightcache[bm]=h
bmap = AnimatedBitmap.new("Graphics/Characters/" + bm, 0)
h = bmap.height
@heightcache[bm] = h
bmap.dispose
end
return h
end
def self.pbScreenZ(ch,height = nil)
if height==nil
height=0
def self.pbScreenZ(ch, height = nil)
if height == nil
height = 0
if ch.tile_id > 0
height=32
elsif ch.character_name!=""
height=bmHeight(ch.character_name)/4
height = 32
elsif ch.character_name != ""
height = bmHeight(ch.character_name) / 4
end
end
ret=ch.screen_z(height)
ret = ch.screen_z(height)
return ret
end
end

View File

@@ -281,7 +281,7 @@ class TilemapRenderer
@tiles_horizontal_count.times do |i|
@tiles[i] = []
@tiles_vertical_count.times do |j|
@tiles[i][j] = Array.new(3) { TileSprite.new(@viewport) }
@tiles[i][j] = Array.new(3) { TileSprite.new(@viewport) }
end
end
@current_map_id = 0

View File

@@ -1,6 +1,6 @@
class TilemapRenderer
module AutotileExpander
MAX_TEXTURE_SIZE = (Bitmap.max_size / 1024) * 1024
MAX_TEXTURE_SIZE = (Bitmap.max_size / 1024) * 1024
module_function

View File

@@ -37,10 +37,10 @@ class TileDrawingHelper
36, 24, 36, 24, 21, 6, 21, 4, 36, 24, 36, 24, 20, 2, 20, 0
]
def self.tableNeighbors(data,x,y)
def self.tableNeighbors(data, x, y)
return 0 if x < 0 || x >= data.xsize
return 0 if y < 0 || y >= data.ysize
t = data[x,y]
t = data[x, y]
xp1 = [x + 1, data.xsize - 1].min
yp1 = [y + 1, data.ysize - 1].min
xm1 = [x - 1, 0].max
@@ -58,12 +58,12 @@ class TileDrawingHelper
end
def self.fromTileset(tileset)
bmtileset=pbGetTileset(tileset.tileset_name)
bmautotiles=[]
bmtileset = pbGetTileset(tileset.tileset_name)
bmautotiles = []
for i in 0...7
bmautotiles.push(pbGetAutotile(tileset.autotile_names[i]))
end
return self.new(bmtileset,bmautotiles)
return self.new(bmtileset, bmautotiles)
end
def initialize(tileset, autotiles)
@@ -87,7 +87,7 @@ class TileDrawingHelper
end
end
def bltSmallAutotile(bitmap,x,y,cxTile,cyTile,id,frame)
def bltSmallAutotile(bitmap, x, y, cxTile, cyTile, id, frame)
return if id >= 384 || frame < 0 || !@autotiles
autotile = @autotiles[id / 48 - 1]
return if !autotile || autotile.disposed?
@@ -111,14 +111,14 @@ class TileDrawingHelper
end
end
def bltSmallRegularTile(bitmap,x,y,cxTile,cyTile,id)
def bltSmallRegularTile(bitmap, x, y, cxTile, cyTile, id)
return if id < 384 || !@tileset || @tileset.disposed?
rect = Rect.new((id - 384) % 8 * 32, (id - 384) / 8 * 32, 32, 32)
rect = TilemapRenderer::TilesetWrapper.getWrappedRect(rect) if @shouldWrap
bitmap.stretch_blt(Rect.new(x, y, cxTile, cyTile), @tileset, rect)
end
def bltSmallTile(bitmap,x,y,cxTile,cyTile,id,frame = 0)
def bltSmallTile(bitmap, x, y, cxTile, cyTile, id, frame = 0)
if id >= 384
bltSmallRegularTile(bitmap, x, y, cxTile, cyTile, id)
elsif id > 0
@@ -126,15 +126,15 @@ class TileDrawingHelper
end
end
def bltAutotile(bitmap,x,y,id,frame)
def bltAutotile(bitmap, x, y, id, frame)
bltSmallAutotile(bitmap, x, y, 32, 32, id, frame)
end
def bltRegularTile(bitmap,x,y,id)
def bltRegularTile(bitmap, x, y, id)
bltSmallRegularTile(bitmap, x, y, 32, 32, id)
end
def bltTile(bitmap,x,y,id,frame = 0)
def bltTile(bitmap, x, y, id, frame = 0)
if id >= 384
bltRegularTile(bitmap, x, y, id)
elsif id > 0
@@ -147,79 +147,79 @@ end
#
#===============================================================================
def createMinimap(mapid)
map=load_data(sprintf("Data/Map%03d.rxdata",mapid)) rescue nil
return BitmapWrapper.new(32,32) if !map
bitmap=BitmapWrapper.new(map.width*4,map.height*4)
black=Color.new(0,0,0)
tilesets=$data_tilesets
tileset=tilesets[map.tileset_id]
map = load_data(sprintf("Data/Map%03d.rxdata", mapid)) rescue nil
return BitmapWrapper.new(32, 32) if !map
bitmap = BitmapWrapper.new(map.width * 4, map.height * 4)
black = Color.new(0, 0, 0)
tilesets = $data_tilesets
tileset = tilesets[map.tileset_id]
return bitmap if !tileset
helper=TileDrawingHelper.fromTileset(tileset)
helper = TileDrawingHelper.fromTileset(tileset)
for y in 0...map.height
for x in 0...map.width
for z in 0..2
id=map.data[x,y,z]
id=0 if !id
helper.bltSmallTile(bitmap,x*4,y*4,4,4,id)
id = map.data[x, y, z]
id = 0 if !id
helper.bltSmallTile(bitmap, x * 4, y * 4, 4, 4, id)
end
end
end
bitmap.fill_rect(0,0,bitmap.width,1,black)
bitmap.fill_rect(0,bitmap.height-1,bitmap.width,1,black)
bitmap.fill_rect(0,0,1,bitmap.height,black)
bitmap.fill_rect(bitmap.width-1,0,1,bitmap.height,black)
bitmap.fill_rect(0, 0, bitmap.width, 1, black)
bitmap.fill_rect(0, bitmap.height - 1, bitmap.width, 1, black)
bitmap.fill_rect(0, 0, 1, bitmap.height, black)
bitmap.fill_rect(bitmap.width - 1, 0, 1, bitmap.height, black)
return bitmap
end
def bltMinimapAutotile(dstBitmap,x,y,srcBitmap,id)
return if id>=48 || !srcBitmap || srcBitmap.disposed?
anim=0
cxTile=3
cyTile=3
tiles = TileDrawingHelper::AUTOTILE_PATTERNS[id>>3][id&7]
src=Rect.new(0,0,0,0)
def bltMinimapAutotile(dstBitmap, x, y, srcBitmap, id)
return if id >= 48 || !srcBitmap || srcBitmap.disposed?
anim = 0
cxTile = 3
cyTile = 3
tiles = TileDrawingHelper::AUTOTILE_PATTERNS[id >> 3][id & 7]
src = Rect.new(0, 0, 0, 0)
for i in 0...4
tile_position = tiles[i] - 1
src.set(
tile_position % 6 * cxTile + anim,
tile_position / 6 * cyTile, cxTile, cyTile)
dstBitmap.blt(i%2*cxTile+x,i/2*cyTile+y, srcBitmap, src)
dstBitmap.blt(i % 2 * cxTile + x, i / 2 * cyTile + y, srcBitmap, src)
end
end
def passable?(passages,tile_id)
def passable?(passages, tile_id)
return false if tile_id == nil
passage = passages[tile_id]
return (passage && passage<15)
return (passage && passage < 15)
end
# Unused
def getPassabilityMinimap(mapid)
map = load_data(sprintf("Data/Map%03d.rxdata",mapid))
map = load_data(sprintf("Data/Map%03d.rxdata", mapid))
tileset = $data_tilesets[map.tileset_id]
minimap = AnimatedBitmap.new("Graphics/Pictures/minimap_tiles")
ret = Bitmap.new(map.width*6,map.height*6)
passtable = Table.new(map.width,map.height)
ret = Bitmap.new(map.width * 6, map.height * 6)
passtable = Table.new(map.width, map.height)
passages = tileset.passages
for i in 0...map.width
for j in 0...map.height
pass=true
for z in [2,1,0]
if !passable?(passages,map.data[i,j,z])
pass=false
pass = true
for z in [2, 1, 0]
if !passable?(passages, map.data[i, j, z])
pass = false
break
end
end
passtable[i,j]=pass ? 1 : 0
passtable[i, j] = pass ? 1 : 0
end
end
neighbors=TileDrawingHelper::NEIGHBORS_TO_AUTOTILE_INDEX
neighbors = TileDrawingHelper::NEIGHBORS_TO_AUTOTILE_INDEX
for i in 0...map.width
for j in 0...map.height
if passtable[i,j]==0
nb=TileDrawingHelper.tableNeighbors(passtable,i,j)
tile=neighbors[nb]
bltMinimapAutotile(ret,i*6,j*6,minimap.bitmap,tile)
if passtable[i, j] == 0
nb = TileDrawingHelper.tableNeighbors(passtable, i, j)
tile = neighbors[nb]
bltMinimapAutotile(ret, i * 6, j * 6, minimap.bitmap, tile)
end
end
end

View File

@@ -40,39 +40,39 @@ module MessageConfig
end
def self.pbDefaultWindowskin
skin=($data_system) ? $data_system.windowskin_name : nil
if skin && skin!=""
skin=pbResolveBitmap("Graphics/Windowskins/"+skin) || ""
skin = ($data_system) ? $data_system.windowskin_name : nil
if skin && skin != ""
skin = pbResolveBitmap("Graphics/Windowskins/" + skin) || ""
end
skin=pbResolveBitmap("Graphics/System/Window") if nil_or_empty?(skin)
skin=pbResolveBitmap("Graphics/Windowskins/001-Blue01") if nil_or_empty?(skin)
skin = pbResolveBitmap("Graphics/System/Window") if nil_or_empty?(skin)
skin = pbResolveBitmap("Graphics/Windowskins/001-Blue01") if nil_or_empty?(skin)
return skin || ""
end
def self.pbGetSystemFrame
if !@@systemFrame
skin=MessageConfig.pbDefaultSystemFrame
skin=MessageConfig.pbDefaultWindowskin if nil_or_empty?(skin)
@@systemFrame=skin || ""
skin = MessageConfig.pbDefaultSystemFrame
skin = MessageConfig.pbDefaultWindowskin if nil_or_empty?(skin)
@@systemFrame = skin || ""
end
return @@systemFrame
end
def self.pbGetSpeechFrame
if !@@defaultTextSkin
skin=MessageConfig.pbDefaultSpeechFrame
skin=MessageConfig.pbDefaultWindowskin if nil_or_empty?(skin)
@@defaultTextSkin=skin || ""
skin = MessageConfig.pbDefaultSpeechFrame
skin = MessageConfig.pbDefaultWindowskin if nil_or_empty?(skin)
@@defaultTextSkin = skin || ""
end
return @@defaultTextSkin
end
def self.pbSetSystemFrame(value)
@@systemFrame=pbResolveBitmap(value) || ""
@@systemFrame = pbResolveBitmap(value) || ""
end
def self.pbSetSpeechFrame(value)
@@defaultTextSkin=pbResolveBitmap(value) || ""
@@defaultTextSkin = pbResolveBitmap(value) || ""
end
#-----------------------------------------------------------------------------
@@ -82,12 +82,12 @@ module MessageConfig
end
def self.pbGetTextSpeed
@@textSpeed=pbDefaultTextSpeed if !@@textSpeed
@@textSpeed = pbDefaultTextSpeed if !@@textSpeed
return @@textSpeed
end
def self.pbSetTextSpeed(value)
@@textSpeed=value
@@textSpeed = value
end
def self.pbSettingToTextSpeed(speed)
@@ -165,106 +165,106 @@ end
# Position a window
#===============================================================================
def pbBottomRight(window)
window.x=Graphics.width-window.width
window.y=Graphics.height-window.height
window.x = Graphics.width - window.width
window.y = Graphics.height - window.height
end
def pbBottomLeft(window)
window.x=0
window.y=Graphics.height-window.height
window.x = 0
window.y = Graphics.height - window.height
end
def pbBottomLeftLines(window,lines,width = nil)
window.x=0
window.width=width ? width : Graphics.width
window.height=(window.borderY rescue 32)+lines*32
window.y=Graphics.height-window.height
def pbBottomLeftLines(window, lines, width = nil)
window.x = 0
window.width = width ? width : Graphics.width
window.height = (window.borderY rescue 32) + lines * 32
window.y = Graphics.height - window.height
end
def pbPositionFaceWindow(facewindow,msgwindow)
def pbPositionFaceWindow(facewindow, msgwindow)
return if !facewindow
if msgwindow
if facewindow.height<=msgwindow.height
facewindow.y=msgwindow.y
if facewindow.height <= msgwindow.height
facewindow.y = msgwindow.y
else
facewindow.y=msgwindow.y+msgwindow.height-facewindow.height
facewindow.y = msgwindow.y + msgwindow.height - facewindow.height
end
facewindow.x=Graphics.width-facewindow.width
msgwindow.x=0
msgwindow.width=Graphics.width-facewindow.width
facewindow.x = Graphics.width - facewindow.width
msgwindow.x = 0
msgwindow.width = Graphics.width - facewindow.width
else
facewindow.height=Graphics.height if facewindow.height>Graphics.height
facewindow.x=0
facewindow.y=0
facewindow.height = Graphics.height if facewindow.height > Graphics.height
facewindow.x = 0
facewindow.y = 0
end
end
def pbPositionNearMsgWindow(cmdwindow,msgwindow,side)
def pbPositionNearMsgWindow(cmdwindow, msgwindow, side)
return if !cmdwindow
if msgwindow
height=[cmdwindow.height,Graphics.height-msgwindow.height].min
if cmdwindow.height!=height
cmdwindow.height=height
height = [cmdwindow.height, Graphics.height - msgwindow.height].min
if cmdwindow.height != height
cmdwindow.height = height
end
cmdwindow.y=msgwindow.y-cmdwindow.height
if cmdwindow.y<0
cmdwindow.y=msgwindow.y+msgwindow.height
if cmdwindow.y+cmdwindow.height>Graphics.height
cmdwindow.y=msgwindow.y-cmdwindow.height
cmdwindow.y = msgwindow.y - cmdwindow.height
if cmdwindow.y < 0
cmdwindow.y = msgwindow.y + msgwindow.height
if cmdwindow.y + cmdwindow.height > Graphics.height
cmdwindow.y = msgwindow.y - cmdwindow.height
end
end
case side
when :left
cmdwindow.x=msgwindow.x
cmdwindow.x = msgwindow.x
when :right
cmdwindow.x=msgwindow.x+msgwindow.width-cmdwindow.width
cmdwindow.x = msgwindow.x + msgwindow.width - cmdwindow.width
else
cmdwindow.x=msgwindow.x+msgwindow.width-cmdwindow.width
cmdwindow.x = msgwindow.x + msgwindow.width - cmdwindow.width
end
else
cmdwindow.height=Graphics.height if cmdwindow.height>Graphics.height
cmdwindow.x=0
cmdwindow.y=0
cmdwindow.height = Graphics.height if cmdwindow.height > Graphics.height
cmdwindow.x = 0
cmdwindow.y = 0
end
end
# internal function
def pbRepositionMessageWindow(msgwindow, linecount = 2)
msgwindow.height=32*linecount+msgwindow.borderY
msgwindow.y=(Graphics.height)-(msgwindow.height)
msgwindow.height = 32 * linecount + msgwindow.borderY
msgwindow.y = (Graphics.height) - (msgwindow.height)
if $game_system
case $game_system.message_position
when 0 # up
msgwindow.y=0
msgwindow.y = 0
when 1 # middle
msgwindow.y=(Graphics.height/2)-(msgwindow.height/2)
msgwindow.y = (Graphics.height / 2) - (msgwindow.height / 2)
when 2
msgwindow.y=(Graphics.height)-(msgwindow.height)
msgwindow.y = (Graphics.height) - (msgwindow.height)
end
msgwindow.opacity = 0 if $game_system.message_frame != 0
end
end
# internal function
def pbUpdateMsgWindowPos(msgwindow,event,eventChanged = false)
def pbUpdateMsgWindowPos(msgwindow, event, eventChanged = false)
if event
if eventChanged
msgwindow.resizeToFit2(msgwindow.text,Graphics.width*2/3,msgwindow.height)
msgwindow.resizeToFit2(msgwindow.text, Graphics.width * 2 / 3, msgwindow.height)
end
msgwindow.y=event.screen_y-48-msgwindow.height
if msgwindow.y<0
msgwindow.y=event.screen_y+24
msgwindow.y = event.screen_y - 48 - msgwindow.height
if msgwindow.y < 0
msgwindow.y = event.screen_y + 24
end
msgwindow.x=event.screen_x-(msgwindow.width/2)
msgwindow.x=0 if msgwindow.x<0
if msgwindow.x>Graphics.width-msgwindow.width
msgwindow.x=Graphics.width-msgwindow.width
msgwindow.x = event.screen_x - (msgwindow.width / 2)
msgwindow.x = 0 if msgwindow.x < 0
if msgwindow.x > Graphics.width - msgwindow.width
msgwindow.x = Graphics.width - msgwindow.width
end
else
curwidth=msgwindow.width
if curwidth!=Graphics.width
msgwindow.width=Graphics.width
msgwindow.width=Graphics.width
curwidth = msgwindow.width
if curwidth != Graphics.width
msgwindow.width = Graphics.width
msgwindow.width = Graphics.width
end
end
end
@@ -272,24 +272,24 @@ end
#===============================================================================
# Determine the colour of a background
#===============================================================================
def isDarkBackground(background,rect = nil)
def isDarkBackground(background, rect = nil)
return true if !background || background.disposed?
rect = background.rect if !rect
return true if rect.width<=0 || rect.height<=0
xSeg = (rect.width/16)
xLoop = (xSeg==0) ? 1 : 16
xStart = (xSeg==0) ? rect.x+(rect.width/2) : rect.x+xSeg/2
ySeg = (rect.height/16)
yLoop = (ySeg==0) ? 1 : 16
yStart = (ySeg==0) ? rect.y+(rect.height/2) : rect.y+ySeg/2
return true if rect.width <= 0 || rect.height <= 0
xSeg = (rect.width / 16)
xLoop = (xSeg == 0) ? 1 : 16
xStart = (xSeg == 0) ? rect.x + (rect.width / 2) : rect.x + xSeg / 2
ySeg = (rect.height / 16)
yLoop = (ySeg == 0) ? 1 : 16
yStart = (ySeg == 0) ? rect.y + (rect.height / 2) : rect.y + ySeg / 2
count = 0
y = yStart
r = g = b = 0
yLoop.times do
x = xStart
xLoop.times do
clr = background.get_pixel(x,y)
if clr.alpha!=0
clr = background.get_pixel(x, y)
if clr.alpha != 0
r += clr.red
g += clr.green
b += clr.blue
@@ -299,51 +299,51 @@ def isDarkBackground(background,rect = nil)
end
y += ySeg
end
return true if count==0
return true if count == 0
r /= count
g /= count
b /= count
return (r*0.299+g*0.587+b*0.114)<160
return (r * 0.299 + g * 0.587 + b * 0.114) < 160
end
def isDarkWindowskin(windowskin)
return true if !windowskin || windowskin.disposed?
if windowskin.width==192 && windowskin.height==128
return isDarkBackground(windowskin,Rect.new(0,0,128,128))
elsif windowskin.width==128 && windowskin.height==128
return isDarkBackground(windowskin,Rect.new(0,0,64,64))
elsif windowskin.width==96 && windowskin.height==48
return isDarkBackground(windowskin,Rect.new(32,16,16,16))
if windowskin.width == 192 && windowskin.height == 128
return isDarkBackground(windowskin, Rect.new(0, 0, 128, 128))
elsif windowskin.width == 128 && windowskin.height == 128
return isDarkBackground(windowskin, Rect.new(0, 0, 64, 64))
elsif windowskin.width == 96 && windowskin.height == 48
return isDarkBackground(windowskin, Rect.new(32, 16, 16, 16))
else
clr = windowskin.get_pixel(windowskin.width/2, windowskin.height/2)
return (clr.red*0.299+clr.green*0.587+clr.blue*0.114)<160
clr = windowskin.get_pixel(windowskin.width / 2, windowskin.height / 2)
return (clr.red * 0.299 + clr.green * 0.587 + clr.blue * 0.114) < 160
end
end
#===============================================================================
# Determine which text colours to use based on the darkness of the background
#===============================================================================
def getSkinColor(windowskin,color,isDarkSkin)
def getSkinColor(windowskin, color, isDarkSkin)
if !windowskin || windowskin.disposed? ||
windowskin.width!=128 || windowskin.height!=128
windowskin.width != 128 || windowskin.height != 128
# Base color, shadow color (these are reversed on dark windowskins)
textcolors = [
"0070F8","78B8E8", # 1 Blue
"E82010","F8A8B8", # 2 Red
"60B048","B0D090", # 3 Green
"48D8D8","A8E0E0", # 4 Cyan
"D038B8","E8A0E0", # 5 Magenta
"E8D020","F8E888", # 6 Yellow
"A0A0A8","D0D0D8", # 7 Grey
"F0F0F8","C8C8D0", # 8 White
"9040E8","B8A8E0", # 9 Purple
"F89818","F8C898", # 10 Orange
"0070F8", "78B8E8", # 1 Blue
"E82010", "F8A8B8", # 2 Red
"60B048", "B0D090", # 3 Green
"48D8D8", "A8E0E0", # 4 Cyan
"D038B8", "E8A0E0", # 5 Magenta
"E8D020", "F8E888", # 6 Yellow
"A0A0A8", "D0D0D8", # 7 Grey
"F0F0F8", "C8C8D0", # 8 White
"9040E8", "B8A8E0", # 9 Purple
"F89818", "F8C898", # 10 Orange
colorToRgb32(MessageConfig::DARK_TEXT_MAIN_COLOR),
colorToRgb32(MessageConfig::DARK_TEXT_SHADOW_COLOR), # 11 Dark default
colorToRgb32(MessageConfig::LIGHT_TEXT_MAIN_COLOR),
colorToRgb32(MessageConfig::LIGHT_TEXT_SHADOW_COLOR) # 12 Light default
]
if color==0 || color>textcolors.length/2 # No special colour, use default
if color == 0 || color > textcolors.length / 2 # No special colour, use default
if isDarkSkin # Dark background, light text
return shadowc3tag(MessageConfig::LIGHT_TEXT_MAIN_COLOR, MessageConfig::LIGHT_TEXT_SHADOW_COLOR)
end
@@ -351,13 +351,13 @@ def getSkinColor(windowskin,color,isDarkSkin)
return shadowc3tag(MessageConfig::DARK_TEXT_MAIN_COLOR, MessageConfig::DARK_TEXT_SHADOW_COLOR)
end
# Special colour as listed above
if isDarkSkin && color!=12 # Dark background, light text
return sprintf("<c3=%s,%s>",textcolors[2*(color-1)+1],textcolors[2*(color-1)])
if isDarkSkin && color != 12 # Dark background, light text
return sprintf("<c3=%s,%s>", textcolors[2 * (color - 1) + 1], textcolors[2 * (color - 1)])
end
# Light background, dark text
return sprintf("<c3=%s,%s>",textcolors[2*(color-1)],textcolors[2*(color-1)+1])
return sprintf("<c3=%s,%s>", textcolors[2 * (color - 1)], textcolors[2 * (color - 1) + 1])
else # VX windowskin
color = 0 if color>=32
color = 0 if color >= 32
x = 64 + (color % 8) * 8
y = 96 + (color / 8) * 8
pixel = windowskin.get_pixel(x, y)
@@ -367,7 +367,7 @@ end
def getDefaultTextColors(windowskin)
if !windowskin || windowskin.disposed? ||
windowskin.width!=128 || windowskin.height!=128
windowskin.width != 128 || windowskin.height != 128
if isDarkWindowskin(windowskin)
return [MessageConfig::LIGHT_TEXT_MAIN_COLOR, MessageConfig::LIGHT_TEXT_SHADOW_COLOR] # White
else
@@ -376,24 +376,24 @@ def getDefaultTextColors(windowskin)
else # VX windowskin
color = windowskin.get_pixel(64, 96)
shadow = nil
isDark = (color.red+color.green+color.blue)/3 < 128
isDark = (color.red + color.green + color.blue) / 3 < 128
if isDark
shadow = Color.new(color.red+64,color.green+64,color.blue+64)
shadow = Color.new(color.red + 64, color.green + 64, color.blue + 64)
else
shadow = Color.new(color.red-64,color.green-64,color.blue-64)
shadow = Color.new(color.red - 64, color.green - 64, color.blue - 64)
end
return [color,shadow]
return [color, shadow]
end
end
#===============================================================================
# Makes sure a bitmap exists
#===============================================================================
def pbDoEnsureBitmap(bitmap,dwidth,dheight)
if !bitmap || bitmap.disposed? || bitmap.width<dwidth || bitmap.height<dheight
def pbDoEnsureBitmap(bitmap, dwidth, dheight)
if !bitmap || bitmap.disposed? || bitmap.width < dwidth || bitmap.height < dheight
oldfont = (bitmap && !bitmap.disposed?) ? bitmap.font : nil
bitmap.dispose if bitmap
bitmap = Bitmap.new([1,dwidth].max,[1,dheight].max)
bitmap = Bitmap.new([1, dwidth].max, [1, dheight].max)
(oldfont) ? bitmap.font = oldfont : pbSetSystemFont(bitmap)
bitmap.font.shadow = false if bitmap.font && bitmap.font.respond_to?("shadow")
end
@@ -424,46 +424,46 @@ end
#===============================================================================
# Blend colours, set the colour of all bitmaps in a sprite hash
#===============================================================================
def pbAlphaBlend(dstColor,srcColor)
r=(255*(srcColor.red-dstColor.red)/255)+dstColor.red
g=(255*(srcColor.green-dstColor.green)/255)+dstColor.green
b=(255*(srcColor.blue-dstColor.blue)/255)+dstColor.blue
a=(255*(srcColor.alpha-dstColor.alpha)/255)+dstColor.alpha
return Color.new(r,g,b,a)
def pbAlphaBlend(dstColor, srcColor)
r = (255 * (srcColor.red - dstColor.red) / 255) + dstColor.red
g = (255 * (srcColor.green - dstColor.green) / 255) + dstColor.green
b = (255 * (srcColor.blue - dstColor.blue) / 255) + dstColor.blue
a = (255 * (srcColor.alpha - dstColor.alpha) / 255) + dstColor.alpha
return Color.new(r, g, b, a)
end
def pbSrcOver(dstColor,srcColor)
er=srcColor.red*srcColor.alpha/255
eg=srcColor.green*srcColor.alpha/255
eb=srcColor.blue*srcColor.alpha/255
iea=255-srcColor.alpha
cr=dstColor.red*dstColor.alpha/255
cg=dstColor.green*dstColor.alpha/255
cb=dstColor.blue*dstColor.alpha/255
ica=255-dstColor.alpha
a=255-(iea*ica)/255
r=(iea*cr)/255+er
g=(iea*cg)/255+eg
b=(iea*cb)/255+eb
r=(a==0) ? 0 : r*255/a
g=(a==0) ? 0 : g*255/a
b=(a==0) ? 0 : b*255/a
return Color.new(r,g,b,a)
def pbSrcOver(dstColor, srcColor)
er = srcColor.red * srcColor.alpha / 255
eg = srcColor.green * srcColor.alpha / 255
eb = srcColor.blue * srcColor.alpha / 255
iea = 255 - srcColor.alpha
cr = dstColor.red * dstColor.alpha / 255
cg = dstColor.green * dstColor.alpha / 255
cb = dstColor.blue * dstColor.alpha / 255
ica = 255 - dstColor.alpha
a = 255 - (iea * ica) / 255
r = (iea * cr) / 255 + er
g = (iea * cg) / 255 + eg
b = (iea * cb) / 255 + eb
r = (a == 0) ? 0 : r * 255 / a
g = (a == 0) ? 0 : g * 255 / a
b = (a == 0) ? 0 : b * 255 / a
return Color.new(r, g, b, a)
end
def pbSetSpritesToColor(sprites,color)
def pbSetSpritesToColor(sprites, color)
return if !sprites || !color
colors={}
colors = {}
for i in sprites
next if !i[1] || pbDisposed?(i[1])
colors[i[0]]=i[1].color.clone
i[1].color=pbSrcOver(i[1].color,color)
colors[i[0]] = i[1].color.clone
i[1].color = pbSrcOver(i[1].color, color)
end
Graphics.update
Input.update
for i in colors
next if !sprites[i[0]]
sprites[i[0]].color=i[1]
sprites[i[0]].color = i[1]
end
end
@@ -480,7 +480,7 @@ end
def pbUpdateSpriteHash(windows)
for i in windows
window=i[1]
window = i[1]
if window
if window.is_a?(Sprite) || window.is_a?(Window)
window.update if !pbDisposed?(window)
@@ -503,14 +503,14 @@ end
def pbDisposeSpriteHash(sprites)
return if !sprites
for i in sprites.keys
pbDisposeSprite(sprites,i)
pbDisposeSprite(sprites, i)
end
sprites.clear
end
# Disposes the specified graphics object within the specified hash. Basically
# like: sprites[id].dispose
def pbDisposeSprite(sprites,id)
def pbDisposeSprite(sprites, id)
sprite = sprites[id]
sprite.dispose if sprite && !pbDisposed?(sprite)
sprites[id] = nil
@@ -531,29 +531,29 @@ end
# Fades and window activations for sprite hashes
#===============================================================================
def pbPushFade
$game_temp.fadestate = [$game_temp.fadestate+1,0].max if $game_temp
$game_temp.fadestate = [$game_temp.fadestate + 1, 0].max if $game_temp
end
def pbPopFade
$game_temp.fadestate = [$game_temp.fadestate-1,0].max if $game_temp
$game_temp.fadestate = [$game_temp.fadestate - 1, 0].max if $game_temp
end
def pbIsFaded?
return ($game_temp) ? $game_temp.fadestate>0 : false
return ($game_temp) ? $game_temp.fadestate > 0 : false
end
# pbFadeOutIn(z) { block }
# Fades out the screen before a block is run and fades it back in after the
# block exits. z indicates the z-coordinate of the viewport used for this effect
def pbFadeOutIn(z = 99999,nofadeout = false)
col=Color.new(0,0,0,0)
viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
viewport.z=z
numFrames = (Graphics.frame_rate*0.4).floor
alphaDiff = (255.0/numFrames).ceil
def pbFadeOutIn(z = 99999, nofadeout = false)
col = Color.new(0, 0, 0, 0)
viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
viewport.z = z
numFrames = (Graphics.frame_rate * 0.4).floor
alphaDiff = (255.0 / numFrames).ceil
for j in 0..numFrames
col.set(0,0,0,j*alphaDiff)
viewport.color=col
col.set(0, 0, 0, j * alphaDiff)
viewport.color = col
Graphics.update
Input.update
end
@@ -566,8 +566,8 @@ def pbFadeOutIn(z = 99999,nofadeout = false)
pbPopFade
if !nofadeout
for j in 0..numFrames
col.set(0,0,0,(numFrames-j)*alphaDiff)
viewport.color=col
col.set(0, 0, 0, (numFrames - j) * alphaDiff)
viewport.color = col
Graphics.update
Input.update
end
@@ -576,15 +576,15 @@ def pbFadeOutIn(z = 99999,nofadeout = false)
end
end
def pbFadeOutInWithUpdate(z,sprites,nofadeout = false)
col=Color.new(0,0,0,0)
viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
viewport.z=z
numFrames = (Graphics.frame_rate*0.4).floor
alphaDiff = (255.0/numFrames).ceil
def pbFadeOutInWithUpdate(z, sprites, nofadeout = false)
col = Color.new(0, 0, 0, 0)
viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
viewport.z = z
numFrames = (Graphics.frame_rate * 0.4).floor
alphaDiff = (255.0 / numFrames).ceil
for j in 0..numFrames
col.set(0,0,0,j*alphaDiff)
viewport.color=col
col.set(0, 0, 0, j * alphaDiff)
viewport.color = col
pbUpdateSpriteHash(sprites)
Graphics.update
Input.update
@@ -596,8 +596,8 @@ def pbFadeOutInWithUpdate(z,sprites,nofadeout = false)
pbPopFade
if !nofadeout
for j in 0..numFrames
col.set(0,0,0,(numFrames-j)*alphaDiff)
viewport.color=col
col.set(0, 0, 0, (numFrames - j) * alphaDiff)
viewport.color = col
pbUpdateSpriteHash(sprites)
Graphics.update
Input.update
@@ -625,11 +625,11 @@ end
def pbFadeOutAndHide(sprites)
visiblesprites = {}
numFrames = (Graphics.frame_rate*0.4).floor
alphaDiff = (255.0/numFrames).ceil
numFrames = (Graphics.frame_rate * 0.4).floor
alphaDiff = (255.0 / numFrames).ceil
pbDeactivateWindows(sprites) {
for j in 0..numFrames
pbSetSpritesToColor(sprites,Color.new(0,0,0,j*alphaDiff))
pbSetSpritesToColor(sprites, Color.new(0, 0, 0, j * alphaDiff))
(block_given?) ? yield : pbUpdateSpriteHash(sprites)
end
}
@@ -642,7 +642,7 @@ def pbFadeOutAndHide(sprites)
return visiblesprites
end
def pbFadeInAndShow(sprites,visiblesprites = nil)
def pbFadeInAndShow(sprites, visiblesprites = nil)
if visiblesprites
for i in visiblesprites
if i[1] && sprites[i[0]] && !pbDisposed?(sprites[i[0]])
@@ -650,11 +650,11 @@ def pbFadeInAndShow(sprites,visiblesprites = nil)
end
end
end
numFrames = (Graphics.frame_rate*0.4).floor
alphaDiff = (255.0/numFrames).ceil
numFrames = (Graphics.frame_rate * 0.4).floor
alphaDiff = (255.0 / numFrames).ceil
pbDeactivateWindows(sprites) {
for j in 0..numFrames
pbSetSpritesToColor(sprites,Color.new(0,0,0,((numFrames-j)*alphaDiff)))
pbSetSpritesToColor(sprites, Color.new(0, 0, 0, ((numFrames - j) * alphaDiff)))
(block_given?) ? yield : pbUpdateSpriteHash(sprites)
end
}
@@ -662,11 +662,11 @@ end
# Restores which windows are active for the given sprite hash.
# _activeStatuses_ is the result of a previous call to pbActivateWindows
def pbRestoreActivations(sprites,activeStatuses)
def pbRestoreActivations(sprites, activeStatuses)
return if !sprites || !activeStatuses
for k in activeStatuses.keys
if sprites[k] && sprites[k].is_a?(Window) && !pbDisposed?(sprites[k])
sprites[k].active=activeStatuses[k] ? true : false
sprites[k].active = activeStatuses[k] ? true : false
end
end
end
@@ -675,29 +675,29 @@ end
# runs the code in the block, and reactivates them.
def pbDeactivateWindows(sprites)
if block_given?
pbActivateWindow(sprites,nil) { yield }
pbActivateWindow(sprites, nil) { yield }
else
pbActivateWindow(sprites,nil)
pbActivateWindow(sprites, nil)
end
end
# Activates a specific window of a sprite hash. _key_ is the key of the window
# in the sprite hash. If a code block is given, deactivates all windows except
# the specified window, runs the code in the block, and reactivates them.
def pbActivateWindow(sprites,key)
def pbActivateWindow(sprites, key)
return if !sprites
activeStatuses={}
activeStatuses = {}
for i in sprites
if i[1] && i[1].is_a?(Window) && !pbDisposed?(i[1])
activeStatuses[i[0]]=i[1].active
i[1].active=(i[0]==key)
activeStatuses[i[0]] = i[1].active
i[1].active = (i[0] == key)
end
end
if block_given?
begin
yield
ensure
pbRestoreActivations(sprites,activeStatuses)
pbRestoreActivations(sprites, activeStatuses)
end
return {}
else
@@ -713,18 +713,18 @@ end
# _background_ is a filename within the Graphics/Pictures/ folder and can be
# an animated image.
# _viewport_ is a viewport to place the background in.
def addBackgroundPlane(sprites,planename,background,viewport = nil)
sprites[planename]=AnimatedPlane.new(viewport)
bitmapName=pbResolveBitmap("Graphics/Pictures/#{background}")
if bitmapName==nil
def addBackgroundPlane(sprites, planename, background, viewport = nil)
sprites[planename] = AnimatedPlane.new(viewport)
bitmapName = pbResolveBitmap("Graphics/Pictures/#{background}")
if bitmapName == nil
# Plane should exist in any case
sprites[planename].bitmap=nil
sprites[planename].visible=false
sprites[planename].bitmap = nil
sprites[planename].visible = false
else
sprites[planename].setBitmap(bitmapName)
for spr in sprites.values
if spr.is_a?(Window)
spr.windowskin=nil
spr.windowskin = nil
end
end
end
@@ -736,17 +736,17 @@ end
# an animated image.
# _color_ is the color to use if the background can't be found.
# _viewport_ is a viewport to place the background in.
def addBackgroundOrColoredPlane(sprites,planename,background,color,viewport = nil)
bitmapName=pbResolveBitmap("Graphics/Pictures/#{background}")
if bitmapName==nil
def addBackgroundOrColoredPlane(sprites, planename, background, color, viewport = nil)
bitmapName = pbResolveBitmap("Graphics/Pictures/#{background}")
if bitmapName == nil
# Plane should exist in any case
sprites[planename]=ColoredPlane.new(color,viewport)
sprites[planename] = ColoredPlane.new(color, viewport)
else
sprites[planename]=AnimatedPlane.new(viewport)
sprites[planename] = AnimatedPlane.new(viewport)
sprites[planename].setBitmap(bitmapName)
for spr in sprites.values
if spr.is_a?(Window)
spr.windowskin=nil
spr.windowskin = nil
end
end
end
@@ -770,9 +770,9 @@ end
if !defined?(_INTL)
def _INTL(*args)
string=args[0].clone
string = args[0].clone
for i in 1...args.length
string.gsub!(/\{#{i}\}/,"#{args[i]}")
string.gsub!(/\{#{i}\}/, "#{args[i]}")
end
return string
end
@@ -780,10 +780,10 @@ end
if !defined?(_ISPRINTF)
def _ISPRINTF(*args)
string=args[0].clone
string = args[0].clone
for i in 1...args.length
string.gsub!(/\{#{i}\:([^\}]+?)\}/) { |m|
next sprintf("%"+$1,args[i])
next sprintf("%" + $1, args[i])
}
end
return string
@@ -792,9 +792,9 @@ end
if !defined?(_MAPINTL)
def _MAPINTL(*args)
string=args[1].clone
string = args[1].clone
for i in 2...args.length
string.gsub!(/\{#{i}\}/,"#{args[i+1]}")
string.gsub!(/\{#{i}\}/, "#{args[i + 1]}")
end
return string
end

View File

@@ -76,51 +76,51 @@ class Window
end
def initialize(viewport = nil)
@sprites={}
@spritekeys=[
@sprites = {}
@spritekeys = [
"back",
"corner0","side0","scroll0",
"corner1","side1","scroll1",
"corner2","side2","scroll2",
"corner3","side3","scroll3",
"cursor","contents","pause"
"corner0", "side0", "scroll0",
"corner1", "side1", "scroll1",
"corner2", "side2", "scroll2",
"corner3", "side3", "scroll3",
"cursor", "contents", "pause"
]
@sidebitmaps=[nil,nil,nil,nil]
@cursorbitmap=nil
@bgbitmap=nil
@viewport=viewport
@sidebitmaps = [nil, nil, nil, nil]
@cursorbitmap = nil
@bgbitmap = nil
@viewport = viewport
for i in @spritekeys
@sprites[i]=Sprite.new(@viewport)
@sprites[i] = Sprite.new(@viewport)
end
@disposed=false
@tone=Tone.new(0,0,0)
@color=Color.new(0,0,0,0)
@blankcontents=Bitmap.new(1,1) # RGSS2 requires this
@contents=@blankcontents
@_windowskin=nil
@rpgvx=false # Set to true to emulate RPGVX windows
@x=0
@y=0
@width=0
@openness=255
@height=0
@ox=0
@oy=0
@z=0
@stretch=true
@visible=true
@active=true
@blend_type=0
@contents_blend_type=0
@opacity=255
@back_opacity=255
@contents_opacity=255
@cursor_rect=WindowCursorRect.new(self)
@cursorblink=0
@cursoropacity=255
@pause=false
@pauseopacity=255
@pauseframe=0
@disposed = false
@tone = Tone.new(0, 0, 0)
@color = Color.new(0, 0, 0, 0)
@blankcontents = Bitmap.new(1, 1) # RGSS2 requires this
@contents = @blankcontents
@_windowskin = nil
@rpgvx = false # Set to true to emulate RPGVX windows
@x = 0
@y = 0
@width = 0
@openness = 255
@height = 0
@ox = 0
@oy = 0
@z = 0
@stretch = true
@visible = true
@active = true
@blend_type = 0
@contents_blend_type = 0
@opacity = 255
@back_opacity = 255
@contents_opacity = 255
@cursor_rect = WindowCursorRect.new(self)
@cursorblink = 0
@cursoropacity = 255
@pause = false
@pauseopacity = 255
@pauseframe = 0
privRefresh(true)
end
@@ -128,55 +128,55 @@ class Window
if !self.disposed?
for i in @sprites
i[1].dispose if i[1]
@sprites[i[0]]=nil
@sprites[i[0]] = nil
end
for i in 0...@sidebitmaps.length
@sidebitmaps[i].dispose if @sidebitmaps[i]
@sidebitmaps[i]=nil
@sidebitmaps[i] = nil
end
@blankcontents.dispose
@cursorbitmap.dispose if @cursorbitmap
@backbitmap.dispose if @backbitmap
@sprites.clear
@sidebitmaps.clear
@_windowskin=nil
@_contents=nil
@disposed=true
@_windowskin = nil
@_contents = nil
@disposed = true
end
end
def openness=(value)
@openness=value
@openness=0 if @openness<0
@openness=255 if @openness>255
@openness = value
@openness = 0 if @openness < 0
@openness = 255 if @openness > 255
privRefresh
end
def stretch=(value)
@stretch=value
@stretch = value
privRefresh(true)
end
def visible=(value)
@visible=value
@visible = value
privRefresh
end
def viewport=(value)
@viewport=value
@viewport = value
for i in @spritekeys
@sprites[i].dispose
if @sprites[i].is_a?(Sprite)
@sprites[i]=Sprite.new(@viewport)
@sprites[i] = Sprite.new(@viewport)
else
@sprites[i]=nil
@sprites[i] = nil
end
end
privRefresh(true)
end
def z=(value)
@z=value
@z = value
privRefresh
end
@@ -185,27 +185,27 @@ class Window
end
def contents=(value)
@contents=value
@contents = value
privRefresh
end
def windowskin=(value)
@_windowskin=value
if value && value.is_a?(Bitmap) && !value.disposed? && value.width==128
@rpgvx=true
@_windowskin = value
if value && value.is_a?(Bitmap) && !value.disposed? && value.width == 128
@rpgvx = true
else
@rpgvx=false
@rpgvx = false
end
privRefresh(true)
end
def ox=(value)
@ox=value
@ox = value
privRefresh
end
def active=(value)
@active=value
@active = value
privRefresh(true)
end
@@ -213,104 +213,104 @@ class Window
if !value
@cursor_rect.empty
else
@cursor_rect.set(value.x,value.y,value.width,value.height)
@cursor_rect.set(value.x, value.y, value.width, value.height)
end
end
def oy=(value)
@oy=value
@oy = value
privRefresh
end
def width=(value)
@width=value
@width = value
privRefresh(true)
end
def height=(value)
@height=value
@height = value
privRefresh(true)
end
def pause=(value)
@pause=value
@pauseopacity=0 if !value
@pause = value
@pauseopacity = 0 if !value
privRefresh
end
def x=(value)
@x=value
@x = value
privRefresh
end
def y=(value)
@y=value
@y = value
privRefresh
end
def opacity=(value)
@opacity=value
@opacity=0 if @opacity<0
@opacity=255 if @opacity>255
@opacity = value
@opacity = 0 if @opacity < 0
@opacity = 255 if @opacity > 255
privRefresh
end
def back_opacity=(value)
@back_opacity=value
@back_opacity=0 if @back_opacity<0
@back_opacity=255 if @back_opacity>255
@back_opacity = value
@back_opacity = 0 if @back_opacity < 0
@back_opacity = 255 if @back_opacity > 255
privRefresh
end
def contents_opacity=(value)
@contents_opacity=value
@contents_opacity=0 if @contents_opacity<0
@contents_opacity=255 if @contents_opacity>255
@contents_opacity = value
@contents_opacity = 0 if @contents_opacity < 0
@contents_opacity = 255 if @contents_opacity > 255
privRefresh
end
def tone=(value)
@tone=value
@tone = value
privRefresh
end
def color=(value)
@color=value
@color = value
privRefresh
end
def blend_type=(value)
@blend_type=value
@blend_type = value
privRefresh
end
def flash(color,duration)
def flash(color, duration)
return if disposed?
for i in @sprites
i[1].flash(color,duration)
i[1].flash(color, duration)
end
end
def update
return if disposed?
mustchange=false
mustchange = false
if @active
if @cursorblink==0
@cursoropacity-=8
@cursorblink=1 if @cursoropacity<=128
if @cursorblink == 0
@cursoropacity -= 8
@cursorblink = 1 if @cursoropacity <= 128
else
@cursoropacity+=8
@cursorblink=0 if @cursoropacity>=255
@cursoropacity += 8
@cursorblink = 0 if @cursoropacity >= 255
end
mustchange=true if !@cursor_rect.empty?
mustchange = true if !@cursor_rect.empty?
else
mustchange=true if @cursoropacity!=128
@cursoropacity=128
mustchange = true if @cursoropacity != 128
@cursoropacity = 128
end
if @pause
@pauseframe=(Graphics.frame_count / 8) % 4
@pauseopacity=[@pauseopacity+64,255].min
mustchange=true
@pauseframe = (Graphics.frame_count / 8) % 4
@pauseopacity = [@pauseopacity + 64, 255].min
mustchange = true
end
privRefresh if mustchange
for i in @sprites
@@ -320,139 +320,139 @@ class Window
private
def ensureBitmap(bitmap,dwidth,dheight)
if !bitmap||bitmap.disposed?||bitmap.width<dwidth||bitmap.height<dheight
def ensureBitmap(bitmap, dwidth, dheight)
if !bitmap || bitmap.disposed? || bitmap.width < dwidth || bitmap.height < dheight
bitmap.dispose if bitmap
bitmap=Bitmap.new([1,dwidth].max,[1,dheight].max)
bitmap = Bitmap.new([1, dwidth].max, [1, dheight].max)
end
return bitmap
end
def tileBitmap(dstbitmap,dstrect,srcbitmap,srcrect)
def tileBitmap(dstbitmap, dstrect, srcbitmap, srcrect)
return if !srcbitmap || srcbitmap.disposed?
left=dstrect.x
top=dstrect.y
left = dstrect.x
top = dstrect.y
y = 0
loop do
break unless y < dstrect.height
x = 0
loop do
break unless x < dstrect.width
dstbitmap.blt(x+left,y+top,srcbitmap,srcrect)
x+=srcrect.width
dstbitmap.blt(x + left, y + top, srcbitmap, srcrect)
x += srcrect.width
end
y+=srcrect.height
y += srcrect.height
end
end
def privRefresh(changeBitmap = false)
return if self.disposed?
backopac=self.back_opacity*self.opacity/255
contopac=self.contents_opacity
cursoropac=@cursoropacity*contopac/255
backopac = self.back_opacity * self.opacity / 255
contopac = self.contents_opacity
cursoropac = @cursoropacity * contopac / 255
for i in 0...4
@sprites["corner#{i}"].bitmap=@_windowskin
@sprites["scroll#{i}"].bitmap=@_windowskin
@sprites["corner#{i}"].bitmap = @_windowskin
@sprites["scroll#{i}"].bitmap = @_windowskin
end
@sprites["pause"].bitmap=@_windowskin
@sprites["contents"].bitmap=@contents
@sprites["pause"].bitmap = @_windowskin
@sprites["contents"].bitmap = @contents
if @_windowskin && !@_windowskin.disposed?
for i in 0...4
@sprites["corner#{i}"].opacity=@opacity
@sprites["corner#{i}"].tone=@tone
@sprites["corner#{i}"].color=@color
@sprites["corner#{i}"].blend_type=@blend_type
@sprites["corner#{i}"].visible=@visible
@sprites["side#{i}"].opacity=@opacity
@sprites["side#{i}"].tone=@tone
@sprites["side#{i}"].color=@color
@sprites["side#{i}"].blend_type=@blend_type
@sprites["side#{i}"].visible=@visible
@sprites["scroll#{i}"].opacity=@opacity
@sprites["scroll#{i}"].tone=@tone
@sprites["scroll#{i}"].blend_type=@blend_type
@sprites["scroll#{i}"].color=@color
@sprites["scroll#{i}"].visible=@visible
@sprites["corner#{i}"].opacity = @opacity
@sprites["corner#{i}"].tone = @tone
@sprites["corner#{i}"].color = @color
@sprites["corner#{i}"].blend_type = @blend_type
@sprites["corner#{i}"].visible = @visible
@sprites["side#{i}"].opacity = @opacity
@sprites["side#{i}"].tone = @tone
@sprites["side#{i}"].color = @color
@sprites["side#{i}"].blend_type = @blend_type
@sprites["side#{i}"].visible = @visible
@sprites["scroll#{i}"].opacity = @opacity
@sprites["scroll#{i}"].tone = @tone
@sprites["scroll#{i}"].blend_type = @blend_type
@sprites["scroll#{i}"].color = @color
@sprites["scroll#{i}"].visible = @visible
end
for i in ["back","cursor","pause","contents"]
@sprites[i].color=@color
@sprites[i].tone=@tone
@sprites[i].blend_type=@blend_type
for i in ["back", "cursor", "pause", "contents"]
@sprites[i].color = @color
@sprites[i].tone = @tone
@sprites[i].blend_type = @blend_type
end
@sprites["contents"].blend_type=@contents_blend_type
@sprites["back"].opacity=backopac
@sprites["contents"].opacity=contopac
@sprites["cursor"].opacity=cursoropac
@sprites["pause"].opacity=@pauseopacity
@sprites["back"].visible=@visible
@sprites["contents"].visible=@visible && @openness==255
@sprites["pause"].visible=@visible && @pause
@sprites["cursor"].visible=@visible && @openness==255
hascontents=(@contents && !@contents.disposed?)
@sprites["contents"].blend_type = @contents_blend_type
@sprites["back"].opacity = backopac
@sprites["contents"].opacity = contopac
@sprites["cursor"].opacity = cursoropac
@sprites["pause"].opacity = @pauseopacity
@sprites["back"].visible = @visible
@sprites["contents"].visible = @visible && @openness == 255
@sprites["pause"].visible = @visible && @pause
@sprites["cursor"].visible = @visible && @openness == 255
hascontents = (@contents && !@contents.disposed?)
@sprites["scroll0"].visible = @visible && hascontents && @oy > 0
@sprites["scroll1"].visible = @visible && hascontents && @ox > 0
@sprites["scroll2"].visible = @visible && hascontents &&
(@contents.width - @ox) > @width-32
(@contents.width - @ox) > @width - 32
@sprites["scroll3"].visible = @visible && hascontents &&
(@contents.height - @oy) > @height-32
(@contents.height - @oy) > @height - 32
else
for i in 0...4
@sprites["corner#{i}"].visible=false
@sprites["side#{i}"].visible=false
@sprites["scroll#{i}"].visible=false
@sprites["corner#{i}"].visible = false
@sprites["side#{i}"].visible = false
@sprites["scroll#{i}"].visible = false
end
@sprites["contents"].visible=@visible && @openness==255
@sprites["contents"].color=@color
@sprites["contents"].tone=@tone
@sprites["contents"].blend_type=@contents_blend_type
@sprites["contents"].opacity=contopac
@sprites["back"].visible=false
@sprites["pause"].visible=false
@sprites["cursor"].visible=false
@sprites["contents"].visible = @visible && @openness == 255
@sprites["contents"].color = @color
@sprites["contents"].tone = @tone
@sprites["contents"].blend_type = @contents_blend_type
@sprites["contents"].opacity = contopac
@sprites["back"].visible = false
@sprites["pause"].visible = false
@sprites["cursor"].visible = false
end
for i in @sprites
i[1].z=@z
i[1].z = @z
end
if @rpgvx
@sprites["cursor"].z=@z # For Compatibility
@sprites["contents"].z=@z # For Compatibility
@sprites["pause"].z=@z # For Compatibility
@sprites["cursor"].z = @z # For Compatibility
@sprites["contents"].z = @z # For Compatibility
@sprites["pause"].z = @z # For Compatibility
else
@sprites["cursor"].z=@z+1 # For Compatibility
@sprites["contents"].z=@z+2 # For Compatibility
@sprites["pause"].z=@z+2 # For Compatibility
@sprites["cursor"].z = @z + 1 # For Compatibility
@sprites["contents"].z = @z + 2 # For Compatibility
@sprites["pause"].z = @z + 2 # For Compatibility
end
if @rpgvx
trimX=64
trimY=0
backRect=Rect.new(0,0,64,64)
blindsRect=Rect.new(0,64,64,64)
trimX = 64
trimY = 0
backRect = Rect.new(0, 0, 64, 64)
blindsRect = Rect.new(0, 64, 64, 64)
else
trimX=128
trimY=0
backRect=Rect.new(0,0,128,128)
blindsRect=nil
trimX = 128
trimY = 0
backRect = Rect.new(0, 0, 128, 128)
blindsRect = nil
end
@sprites["corner0"].src_rect.set(trimX,trimY+0,16,16)
@sprites["corner1"].src_rect.set(trimX+48,trimY+0,16,16)
@sprites["corner2"].src_rect.set(trimX,trimY+48,16,16)
@sprites["corner3"].src_rect.set(trimX+48,trimY+48,16,16)
@sprites["scroll0"].src_rect.set(trimX+24, trimY+16, 16, 8) # up
@sprites["scroll3"].src_rect.set(trimX+24, trimY+40, 16, 8) # down
@sprites["scroll1"].src_rect.set(trimX+16, trimY+24, 8, 16) # left
@sprites["scroll2"].src_rect.set(trimX+40, trimY+24, 8, 16) # right
cursorX=trimX
cursorY=trimY+64
sideRects=[
Rect.new(trimX+16,trimY+0,32,16),
Rect.new(trimX,trimY+16,16,32),
Rect.new(trimX+48,trimY+16,16,32),
Rect.new(trimX+16,trimY+48,32,16)
@sprites["corner0"].src_rect.set(trimX, trimY + 0, 16, 16)
@sprites["corner1"].src_rect.set(trimX + 48, trimY + 0, 16, 16)
@sprites["corner2"].src_rect.set(trimX, trimY + 48, 16, 16)
@sprites["corner3"].src_rect.set(trimX + 48, trimY + 48, 16, 16)
@sprites["scroll0"].src_rect.set(trimX + 24, trimY + 16, 16, 8) # up
@sprites["scroll3"].src_rect.set(trimX + 24, trimY + 40, 16, 8) # down
@sprites["scroll1"].src_rect.set(trimX + 16, trimY + 24, 8, 16) # left
@sprites["scroll2"].src_rect.set(trimX + 40, trimY + 24, 8, 16) # right
cursorX = trimX
cursorY = trimY + 64
sideRects = [
Rect.new(trimX + 16, trimY + 0, 32, 16),
Rect.new(trimX, trimY + 16, 16, 32),
Rect.new(trimX + 48, trimY + 16, 16, 32),
Rect.new(trimX + 16, trimY + 48, 32, 16)
]
if @width>32 && @height>32
@sprites["contents"].src_rect.set(@ox,@oy,@width-32,@height-32)
if @width > 32 && @height > 32
@sprites["contents"].src_rect.set(@ox, @oy, @width - 32, @height - 32)
else
@sprites["contents"].src_rect.set(0,0,0,0)
@sprites["contents"].src_rect.set(0, 0, 0, 0)
end
pauseRects = [
trimX + 32, trimY + 64,
@@ -460,75 +460,75 @@ class Window
trimX + 32, trimY + 80,
trimX + 48, trimY + 80
]
pauseWidth=16
pauseHeight=16
pauseWidth = 16
pauseHeight = 16
@sprites["pause"].src_rect.set(pauseRects[@pauseframe * 2],
pauseRects[@pauseframe * 2 + 1],
pauseWidth,
pauseHeight)
@sprites["pause"].x=@x+(@width/2)-(pauseWidth/2)
@sprites["pause"].y=@y+@height-16 # 16 refers to skin margin
@sprites["contents"].x=@x+16
@sprites["contents"].y=@y+16
@sprites["corner0"].x=@x
@sprites["corner0"].y=@y
@sprites["corner1"].x=@x+@width-16
@sprites["corner1"].y=@y
@sprites["corner2"].x=@x
@sprites["corner2"].y=@y+@height-16
@sprites["corner3"].x=@x+@width-16
@sprites["corner3"].y=@y+@height-16
@sprites["side0"].x=@x+16
@sprites["side0"].y=@y
@sprites["side1"].x=@x
@sprites["side1"].y=@y+16
@sprites["side2"].x=@x+@width-16
@sprites["side2"].y=@y+16
@sprites["side3"].x=@x+16
@sprites["side3"].y=@y+@height-16
@sprites["scroll0"].x = @x+@width / 2 - 8
@sprites["scroll0"].y = @y+8
@sprites["scroll1"].x = @x+8
@sprites["scroll1"].y = @y+@height / 2 - 8
@sprites["scroll2"].x = @x+@width - 16
@sprites["scroll2"].y = @y+@height / 2 - 8
@sprites["scroll3"].x = @x+@width / 2 - 8
@sprites["scroll3"].y = @y+@height - 16
@sprites["back"].x=@x+2
@sprites["back"].y=@y+2
@sprites["cursor"].x=@x+16+@cursor_rect.x
@sprites["cursor"].y=@y+16+@cursor_rect.y
@sprites["pause"].x = @x + (@width / 2) - (pauseWidth / 2)
@sprites["pause"].y = @y + @height - 16 # 16 refers to skin margin
@sprites["contents"].x = @x + 16
@sprites["contents"].y = @y + 16
@sprites["corner0"].x = @x
@sprites["corner0"].y = @y
@sprites["corner1"].x = @x + @width - 16
@sprites["corner1"].y = @y
@sprites["corner2"].x = @x
@sprites["corner2"].y = @y + @height - 16
@sprites["corner3"].x = @x + @width - 16
@sprites["corner3"].y = @y + @height - 16
@sprites["side0"].x = @x + 16
@sprites["side0"].y = @y
@sprites["side1"].x = @x
@sprites["side1"].y = @y + 16
@sprites["side2"].x = @x + @width - 16
@sprites["side2"].y = @y + 16
@sprites["side3"].x = @x + 16
@sprites["side3"].y = @y + @height - 16
@sprites["scroll0"].x = @x + @width / 2 - 8
@sprites["scroll0"].y = @y + 8
@sprites["scroll1"].x = @x + 8
@sprites["scroll1"].y = @y + @height / 2 - 8
@sprites["scroll2"].x = @x + @width - 16
@sprites["scroll2"].y = @y + @height / 2 - 8
@sprites["scroll3"].x = @x + @width / 2 - 8
@sprites["scroll3"].y = @y + @height - 16
@sprites["back"].x = @x + 2
@sprites["back"].y = @y + 2
@sprites["cursor"].x = @x + 16 + @cursor_rect.x
@sprites["cursor"].y = @y + 16 + @cursor_rect.y
if changeBitmap && @_windowskin && !@_windowskin.disposed?
width=@cursor_rect.width
height=@cursor_rect.height
width = @cursor_rect.width
height = @cursor_rect.height
if width > 0 && height > 0
cursorrects=[
cursorrects = [
# sides
Rect.new(cursorX+2, cursorY+0, 28, 2),
Rect.new(cursorX+0, cursorY+2, 2, 28),
Rect.new(cursorX+30, cursorY+2, 2, 28),
Rect.new(cursorX+2, cursorY+30, 28, 2),
Rect.new(cursorX + 2, cursorY + 0, 28, 2),
Rect.new(cursorX + 0, cursorY + 2, 2, 28),
Rect.new(cursorX + 30, cursorY + 2, 2, 28),
Rect.new(cursorX + 2, cursorY + 30, 28, 2),
# corners
Rect.new(cursorX+0, cursorY+0, 2, 2),
Rect.new(cursorX+30, cursorY+0, 2, 2),
Rect.new(cursorX+0, cursorY+30, 2, 2),
Rect.new(cursorX+30, cursorY+30, 2, 2),
Rect.new(cursorX + 0, cursorY + 0, 2, 2),
Rect.new(cursorX + 30, cursorY + 0, 2, 2),
Rect.new(cursorX + 0, cursorY + 30, 2, 2),
Rect.new(cursorX + 30, cursorY + 30, 2, 2),
# back
Rect.new(cursorX+2, cursorY+2, 28, 28)
Rect.new(cursorX + 2, cursorY + 2, 28, 28)
]
margin=2
fullmargin=4
margin = 2
fullmargin = 4
@cursorbitmap = ensureBitmap(@cursorbitmap, width, height)
@cursorbitmap.clear
@sprites["cursor"].bitmap=@cursorbitmap
@sprites["cursor"].src_rect.set(0,0,width,height)
rect = Rect.new(margin,margin,
@sprites["cursor"].bitmap = @cursorbitmap
@sprites["cursor"].src_rect.set(0, 0, width, height)
rect = Rect.new(margin, margin,
width - fullmargin, height - fullmargin)
@cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[8])
@cursorbitmap.blt(0, 0, @_windowskin, cursorrects[4]) # top left
@cursorbitmap.blt(width-margin, 0, @_windowskin, cursorrects[5]) # top right
@cursorbitmap.blt(0, height-margin, @_windowskin, cursorrects[6]) # bottom right
@cursorbitmap.blt(width-margin, height-margin, @_windowskin, cursorrects[7]) # bottom left
@cursorbitmap.blt(width - margin, 0, @_windowskin, cursorrects[5]) # top right
@cursorbitmap.blt(0, height - margin, @_windowskin, cursorrects[6]) # bottom right
@cursorbitmap.blt(width - margin, height - margin, @_windowskin, cursorrects[7]) # bottom left
rect = Rect.new(margin, 0,
width - fullmargin, margin)
@cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[0])
@@ -538,67 +538,67 @@ class Window
rect = Rect.new(width - margin, margin,
margin, height - fullmargin)
@cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[2])
rect = Rect.new(margin, height-margin,
rect = Rect.new(margin, height - margin,
width - fullmargin, margin)
@cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[3])
else
@sprites["cursor"].visible=false
@sprites["cursor"].src_rect.set(0,0,0,0)
@sprites["cursor"].visible = false
@sprites["cursor"].src_rect.set(0, 0, 0, 0)
end
for i in 0...4
dwidth = [0, 3].include?(i) ? @width - 32 : 16
dheight = [0, 3].include?(i) ? 16 : @height - 32
@sidebitmaps[i]=ensureBitmap(@sidebitmaps[i],dwidth,dheight)
@sprites["side#{i}"].bitmap=@sidebitmaps[i]
@sprites["side#{i}"].src_rect.set(0,0,dwidth,dheight)
@sidebitmaps[i] = ensureBitmap(@sidebitmaps[i], dwidth, dheight)
@sprites["side#{i}"].bitmap = @sidebitmaps[i]
@sprites["side#{i}"].src_rect.set(0, 0, dwidth, dheight)
@sidebitmaps[i].clear
if sideRects[i].width>0 && sideRects[i].height>0
if sideRects[i].width > 0 && sideRects[i].height > 0
@sidebitmaps[i].stretch_blt(@sprites["side#{i}"].src_rect,
@_windowskin,sideRects[i])
@_windowskin, sideRects[i])
end
end
backwidth=@width-4
backheight=@height-4
if backwidth>0 && backheight>0
@backbitmap=ensureBitmap(@backbitmap,backwidth,backheight)
@sprites["back"].bitmap=@backbitmap
@sprites["back"].src_rect.set(0,0,backwidth,backheight)
backwidth = @width - 4
backheight = @height - 4
if backwidth > 0 && backheight > 0
@backbitmap = ensureBitmap(@backbitmap, backwidth, backheight)
@sprites["back"].bitmap = @backbitmap
@sprites["back"].src_rect.set(0, 0, backwidth, backheight)
@backbitmap.clear
if @stretch
@backbitmap.stretch_blt(@sprites["back"].src_rect,@_windowskin,backRect)
@backbitmap.stretch_blt(@sprites["back"].src_rect, @_windowskin, backRect)
else
tileBitmap(@backbitmap,@sprites["back"].src_rect,@_windowskin,backRect)
tileBitmap(@backbitmap, @sprites["back"].src_rect, @_windowskin, backRect)
end
if blindsRect
tileBitmap(@backbitmap,@sprites["back"].src_rect,@_windowskin,blindsRect)
tileBitmap(@backbitmap, @sprites["back"].src_rect, @_windowskin, blindsRect)
end
else
@sprites["back"].visible=false
@sprites["back"].src_rect.set(0,0,0,0)
@sprites["back"].visible = false
@sprites["back"].src_rect.set(0, 0, 0, 0)
end
end
if @openness!=255
opn=@openness/255.0
if @openness != 255
opn = @openness / 255.0
for k in @spritekeys
sprite=@sprites[k]
ratio=(@height<=0) ? 0 : (sprite.y-@y)*1.0/@height
sprite.zoom_y=opn
sprite.oy=0
sprite.y=(@y+(@height/2.0)+(@height*ratio*opn)-(@height/2*opn)).floor
sprite = @sprites[k]
ratio = (@height <= 0) ? 0 : (sprite.y - @y) * 1.0 / @height
sprite.zoom_y = opn
sprite.oy = 0
sprite.y = (@y + (@height / 2.0) + (@height * ratio * opn) - (@height / 2 * opn)).floor
end
else
for k in @spritekeys
sprite=@sprites[k]
sprite.zoom_y=1.0
sprite = @sprites[k]
sprite.zoom_y = 1.0
end
end
i=0
i = 0
# Ensure Z order
for k in @spritekeys
sprite=@sprites[k]
y=sprite.y
sprite.y=i
sprite.oy=(sprite.zoom_y<=0) ? 0 : (i-y)/sprite.zoom_y
sprite = @sprites[k]
y = sprite.y
sprite.y = i
sprite.oy = (sprite.zoom_y <= 0) ? 0 : (i - y) / sprite.zoom_y
end
end
end

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -4,12 +4,12 @@
class IconWindow < SpriteWindow_Base
attr_reader :name
def initialize(x,y,width,height,viewport = nil)
super(x,y,width,height)
self.viewport=viewport
self.contents=nil
@name=""
@_iconbitmap=nil
def initialize(x, y, width, height, viewport = nil)
super(x, y, width, height)
self.viewport = viewport
self.contents = nil
@name = ""
@_iconbitmap = nil
end
def dispose
@@ -21,14 +21,14 @@ class IconWindow < SpriteWindow_Base
super
if @_iconbitmap
@_iconbitmap.update
self.contents=@_iconbitmap.bitmap
self.contents = @_iconbitmap.bitmap
end
end
def clearBitmaps
@_iconbitmap.dispose if @_iconbitmap
@_iconbitmap=nil
self.contents=nil if !self.disposed?
@_iconbitmap = nil
self.contents = nil if !self.disposed?
end
# Sets the icon's filename. Alias for setBitmap.
@@ -37,16 +37,16 @@ class IconWindow < SpriteWindow_Base
end
# Sets the icon's filename.
def setBitmap(file,hue = 0)
def setBitmap(file, hue = 0)
clearBitmaps()
@name=file
return if file==nil
if file!=""
@_iconbitmap=AnimatedBitmap.new(file,hue)
@name = file
return if file == nil
if file != ""
@_iconbitmap = AnimatedBitmap.new(file, hue)
# for compatibility
self.contents=@_iconbitmap ? @_iconbitmap.bitmap : nil
self.contents = @_iconbitmap ? @_iconbitmap.bitmap : nil
else
@_iconbitmap=nil
@_iconbitmap = nil
end
end
end
@@ -59,10 +59,10 @@ end
#===============================================================================
class PictureWindow < SpriteWindow_Base
def initialize(pathOrBitmap)
super(0,0,32,32)
self.viewport=viewport
self.contents=nil
@_iconbitmap=nil
super(0, 0, 32, 32)
self.viewport = viewport
self.contents = nil
@_iconbitmap = nil
setBitmap(pathOrBitmap)
end
@@ -75,45 +75,45 @@ class PictureWindow < SpriteWindow_Base
super
if @_iconbitmap
if @_iconbitmap.is_a?(Bitmap)
self.contents=@_iconbitmap
self.contents = @_iconbitmap
else
@_iconbitmap.update
self.contents=@_iconbitmap.bitmap
self.contents = @_iconbitmap.bitmap
end
end
end
def clearBitmaps
@_iconbitmap.dispose if @_iconbitmap
@_iconbitmap=nil
self.contents=nil if !self.disposed?
@_iconbitmap = nil
self.contents = nil if !self.disposed?
end
# Sets the icon's bitmap or filename. (hue parameter
# is ignored unless pathOrBitmap is a filename)
def setBitmap(pathOrBitmap,hue = 0)
def setBitmap(pathOrBitmap, hue = 0)
clearBitmaps()
if pathOrBitmap!=nil && pathOrBitmap!=""
if pathOrBitmap != nil && pathOrBitmap != ""
if pathOrBitmap.is_a?(Bitmap)
@_iconbitmap=pathOrBitmap
self.contents=@_iconbitmap
self.width=@_iconbitmap.width+self.borderX
self.height=@_iconbitmap.height+self.borderY
@_iconbitmap = pathOrBitmap
self.contents = @_iconbitmap
self.width = @_iconbitmap.width + self.borderX
self.height = @_iconbitmap.height + self.borderY
elsif pathOrBitmap.is_a?(AnimatedBitmap)
@_iconbitmap=pathOrBitmap
self.contents=@_iconbitmap.bitmap
self.width=@_iconbitmap.bitmap.width+self.borderX
self.height=@_iconbitmap.bitmap.height+self.borderY
@_iconbitmap = pathOrBitmap
self.contents = @_iconbitmap.bitmap
self.width = @_iconbitmap.bitmap.width + self.borderX
self.height = @_iconbitmap.bitmap.height + self.borderY
else
@_iconbitmap=AnimatedBitmap.new(pathOrBitmap,hue)
@_iconbitmap = AnimatedBitmap.new(pathOrBitmap, hue)
self.contents = @_iconbitmap&.bitmap
self.width = self.borderX + (@_iconbitmap&.bitmap&.width || 32)
self.height = self.borderY + (@_iconbitmap&.bitmap&.height || 32)
end
else
@_iconbitmap=nil
self.width=32+self.borderX
self.height=32+self.borderY
@_iconbitmap = nil
self.width = 32 + self.borderX
self.height = 32 + self.borderY
end
end
end

View File

@@ -6,48 +6,48 @@ class SpriteWrapper
@sprite = Sprite.new(viewport)
end
def dispose; @sprite.dispose; end
def disposed?; return @sprite.disposed?; end
def viewport; return @sprite.viewport; end
def flash(color,duration); return @sprite.flash(color,duration); end
def update; return @sprite.update; end
def x; @sprite.x; end
def x=(value); @sprite.x = value; end
def y; @sprite.y; end
def y=(value); @sprite.y = value; end
def bitmap; @sprite.bitmap; end
def bitmap=(value); @sprite.bitmap = value; end
def src_rect; @sprite.src_rect; end
def src_rect=(value); @sprite.src_rect = value; end
def visible; @sprite.visible; end
def visible=(value); @sprite.visible = value; end
def z; @sprite.z; end
def z=(value); @sprite.z = value; end
def ox; @sprite.ox; end
def ox=(value); @sprite.ox = value; end
def oy; @sprite.oy; end
def oy=(value); @sprite.oy = value; end
def zoom_x; @sprite.zoom_x; end
def zoom_x=(value); @sprite.zoom_x = value; end
def zoom_y; @sprite.zoom_y; end
def zoom_y=(value); @sprite.zoom_y = value; end
def angle; @sprite.angle; end
def angle=(value); @sprite.angle = value; end
def mirror; @sprite.mirror; end
def mirror=(value); @sprite.mirror = value; end
def bush_depth; @sprite.bush_depth; end
def bush_depth=(value); @sprite.bush_depth = value; end
def opacity; @sprite.opacity; end
def opacity=(value); @sprite.opacity = value; end
def blend_type; @sprite.blend_type; end
def blend_type=(value); @sprite.blend_type = value; end
def color; @sprite.color; end
def color=(value); @sprite.color = value; end
def tone; @sprite.tone; end
def tone=(value); @sprite.tone = value; end
def dispose; @sprite.dispose; end
def disposed?; return @sprite.disposed?; end
def viewport; return @sprite.viewport; end
def flash(color, duration); return @sprite.flash(color, duration); end
def update; return @sprite.update; end
def x; @sprite.x; end
def x=(value); @sprite.x = value; end
def y; @sprite.y; end
def y=(value); @sprite.y = value; end
def bitmap; @sprite.bitmap; end
def bitmap=(value); @sprite.bitmap = value; end
def src_rect; @sprite.src_rect; end
def src_rect=(value); @sprite.src_rect = value; end
def visible; @sprite.visible; end
def visible=(value); @sprite.visible = value; end
def z; @sprite.z; end
def z=(value); @sprite.z = value; end
def ox; @sprite.ox; end
def ox=(value); @sprite.ox = value; end
def oy; @sprite.oy; end
def oy=(value); @sprite.oy = value; end
def zoom_x; @sprite.zoom_x; end
def zoom_x=(value); @sprite.zoom_x = value; end
def zoom_y; @sprite.zoom_y; end
def zoom_y=(value); @sprite.zoom_y = value; end
def angle; @sprite.angle; end
def angle=(value); @sprite.angle = value; end
def mirror; @sprite.mirror; end
def mirror=(value); @sprite.mirror = value; end
def bush_depth; @sprite.bush_depth; end
def bush_depth=(value); @sprite.bush_depth = value; end
def opacity; @sprite.opacity; end
def opacity=(value); @sprite.opacity = value; end
def blend_type; @sprite.blend_type; end
def blend_type=(value); @sprite.blend_type = value; end
def color; @sprite.color; end
def color=(value); @sprite.color = value; end
def tone; @sprite.tone; end
def tone=(value); @sprite.tone = value; end
def viewport=(value)
return if self.viewport==value
return if self.viewport == value
bitmap = @sprite.bitmap
src_rect = @sprite.src_rect
visible = @sprite.visible
@@ -94,10 +94,10 @@ end
# This bitmap can't be changed to a different one.
#===============================================================================
class BitmapSprite < SpriteWrapper
def initialize(width,height,viewport = nil)
def initialize(width, height, viewport = nil)
super(viewport)
self.bitmap=Bitmap.new(width,height)
@initialized=true
self.bitmap = Bitmap.new(width, height)
@initialized = true
end
def bitmap=(value)
@@ -122,82 +122,82 @@ class AnimatedSprite < SpriteWrapper
attr_reader :framecount
attr_reader :animname
def initializeLong(animname,framecount,framewidth,frameheight,frameskip)
@animname=pbBitmapName(animname)
@realframes=0
@frameskip=[1,frameskip].max
@frameskip *= Graphics.frame_rate/20
raise _INTL("Frame width is 0") if framewidth==0
raise _INTL("Frame height is 0") if frameheight==0
def initializeLong(animname, framecount, framewidth, frameheight, frameskip)
@animname = pbBitmapName(animname)
@realframes = 0
@frameskip = [1, frameskip].max
@frameskip *= Graphics.frame_rate / 20
raise _INTL("Frame width is 0") if framewidth == 0
raise _INTL("Frame height is 0") if frameheight == 0
begin
@animbitmap=AnimatedBitmap.new(animname).deanimate
@animbitmap = AnimatedBitmap.new(animname).deanimate
rescue
@animbitmap=Bitmap.new(framewidth,frameheight)
@animbitmap = Bitmap.new(framewidth, frameheight)
end
if @animbitmap.width%framewidth!=0
if @animbitmap.width % framewidth != 0
raise _INTL("Bitmap's width ({1}) is not a multiple of frame width ({2}) [Bitmap={3}]",
@animbitmap.width,framewidth,animname)
@animbitmap.width, framewidth, animname)
end
if @animbitmap.height%frameheight!=0
if @animbitmap.height % frameheight != 0
raise _INTL("Bitmap's height ({1}) is not a multiple of frame height ({2}) [Bitmap={3}]",
@animbitmap.height,frameheight,animname)
@animbitmap.height, frameheight, animname)
end
@framecount=framecount
@framewidth=framewidth
@frameheight=frameheight
@framesperrow=@animbitmap.width/@framewidth
@playing=false
self.bitmap=@animbitmap
self.src_rect.width=@framewidth
self.src_rect.height=@frameheight
self.frame=0
@framecount = framecount
@framewidth = framewidth
@frameheight = frameheight
@framesperrow = @animbitmap.width / @framewidth
@playing = false
self.bitmap = @animbitmap
self.src_rect.width = @framewidth
self.src_rect.height = @frameheight
self.frame = 0
end
# Shorter version of AnimationSprite. All frames are placed on a single row
# of the bitmap, so that the width and height need not be defined beforehand
def initializeShort(animname,framecount,frameskip)
@animname=pbBitmapName(animname)
@realframes=0
@frameskip=[1,frameskip].max
@frameskip *= Graphics.frame_rate/20
def initializeShort(animname, framecount, frameskip)
@animname = pbBitmapName(animname)
@realframes = 0
@frameskip = [1, frameskip].max
@frameskip *= Graphics.frame_rate / 20
begin
@animbitmap=AnimatedBitmap.new(animname).deanimate
@animbitmap = AnimatedBitmap.new(animname).deanimate
rescue
@animbitmap=Bitmap.new(framecount*4,32)
@animbitmap = Bitmap.new(framecount * 4, 32)
end
if @animbitmap.width%framecount!=0
if @animbitmap.width % framecount != 0
raise _INTL("Bitmap's width ({1}) is not a multiple of frame count ({2}) [Bitmap={3}]",
@animbitmap.width,framewidth,animname)
@animbitmap.width, framewidth, animname)
end
@framecount=framecount
@framewidth=@animbitmap.width/@framecount
@frameheight=@animbitmap.height
@framesperrow=framecount
@playing=false
self.bitmap=@animbitmap
self.src_rect.width=@framewidth
self.src_rect.height=@frameheight
self.frame=0
@framecount = framecount
@framewidth = @animbitmap.width / @framecount
@frameheight = @animbitmap.height
@framesperrow = framecount
@playing = false
self.bitmap = @animbitmap
self.src_rect.width = @framewidth
self.src_rect.height = @frameheight
self.frame = 0
end
def initialize(*args)
if args.length==1
if args.length == 1
super(args[0][3])
initializeShort(args[0][0],args[0][1],args[0][2])
initializeShort(args[0][0], args[0][1], args[0][2])
else
super(args[5])
initializeLong(args[0],args[1],args[2],args[3],args[4])
initializeLong(args[0], args[1], args[2], args[3], args[4])
end
end
def self.create(animname,framecount,frameskip,viewport = nil)
return self.new([animname,framecount,frameskip,viewport])
def self.create(animname, framecount, frameskip, viewport = nil)
return self.new([animname, framecount, frameskip, viewport])
end
def dispose
return if disposed?
@animbitmap.dispose
@animbitmap=nil
@animbitmap = nil
super
end
@@ -206,31 +206,31 @@ class AnimatedSprite < SpriteWrapper
end
def frame=(value)
@frame=value
@realframes=0
self.src_rect.x=@frame%@framesperrow*@framewidth
self.src_rect.y=@frame/@framesperrow*@frameheight
@frame = value
@realframes = 0
self.src_rect.x = @frame % @framesperrow * @framewidth
self.src_rect.y = @frame / @framesperrow * @frameheight
end
def start
@playing=true
@realframes=0
@playing = true
@realframes = 0
end
alias play start
def stop
@playing=false
@playing = false
end
def update
super
if @playing
@realframes+=1
if @realframes==@frameskip
@realframes=0
self.frame+=1
self.frame%=self.framecount
@realframes += 1
if @realframes == @frameskip
@realframes = 0
self.frame += 1
self.frame %= self.framecount
end
end
end
@@ -245,23 +245,23 @@ class IconSprite < SpriteWrapper
attr_reader :name
def initialize(*args)
if args.length==0
if args.length == 0
super(nil)
self.bitmap=nil
elsif args.length==1
self.bitmap = nil
elsif args.length == 1
super(args[0])
self.bitmap=nil
elsif args.length==2
self.bitmap = nil
elsif args.length == 2
super(nil)
self.x=args[0]
self.y=args[1]
self.x = args[0]
self.y = args[1]
else
super(args[2])
self.x=args[0]
self.y=args[1]
self.x = args[0]
self.y = args[1]
end
@name=""
@_iconbitmap=nil
@name = ""
@_iconbitmap = nil
end
def dispose
@@ -275,35 +275,35 @@ class IconSprite < SpriteWrapper
end
# Sets the icon's filename.
def setBitmap(file,hue = 0)
oldrc=self.src_rect
def setBitmap(file, hue = 0)
oldrc = self.src_rect
clearBitmaps()
@name=file
return if file==nil
if file!=""
@_iconbitmap=AnimatedBitmap.new(file,hue)
@name = file
return if file == nil
if file != ""
@_iconbitmap = AnimatedBitmap.new(file, hue)
# for compatibility
self.bitmap=@_iconbitmap ? @_iconbitmap.bitmap : nil
self.src_rect=oldrc
self.bitmap = @_iconbitmap ? @_iconbitmap.bitmap : nil
self.src_rect = oldrc
else
@_iconbitmap=nil
@_iconbitmap = nil
end
end
def clearBitmaps
@_iconbitmap.dispose if @_iconbitmap
@_iconbitmap=nil
self.bitmap=nil if !self.disposed?
@_iconbitmap = nil
self.bitmap = nil if !self.disposed?
end
def update
super
return if !@_iconbitmap
@_iconbitmap.update
if self.bitmap!=@_iconbitmap.bitmap
oldrc=self.src_rect
self.bitmap=@_iconbitmap.bitmap
self.src_rect=oldrc
if self.bitmap != @_iconbitmap.bitmap
oldrc = self.src_rect
self.bitmap = @_iconbitmap.bitmap
self.src_rect = oldrc
end
end
end
@@ -315,7 +315,7 @@ end
#===============================================================================
class GifSprite < IconSprite
def initialize(path)
super(0,0)
super(0, 0)
setBitmap(path)
end
end
@@ -326,7 +326,7 @@ end
# SpriteWrapper that stores multiple bitmaps, and displays only one at once.
#===============================================================================
class ChangelingSprite < SpriteWrapper
def initialize(x = 0,y = 0,viewport = nil)
def initialize(x = 0, y = 0, viewport = nil)
super(viewport)
self.x = x
self.y = y
@@ -334,7 +334,7 @@ class ChangelingSprite < SpriteWrapper
@currentBitmap = nil
end
def addBitmap(key,path)
def addBitmap(key, path)
@bitmaps[key].dispose if @bitmaps[key]
@bitmaps[key] = AnimatedBitmap.new(path)
end

View File

@@ -225,14 +225,14 @@ def pbGetTileBitmap(filename, tile_id, hue, width = 1, height = 1)
}
end
def pbGetTileset(name,hue = 0)
def pbGetTileset(name, hue = 0)
return AnimatedBitmap.new("Graphics/Tilesets/" + name, hue).deanimate
end
def pbGetAutotile(name,hue = 0)
def pbGetAutotile(name, hue = 0)
return AnimatedBitmap.new("Graphics/Autotiles/" + name, hue).deanimate
end
def pbGetAnimation(name,hue = 0)
def pbGetAnimation(name, hue = 0)
return AnimatedBitmap.new("Graphics/Animations/" + name, hue).deanimate
end

File diff suppressed because it is too large Load Diff

View File

@@ -43,11 +43,11 @@ def pbEventCommentInput(*args)
return nil
end
def pbCurrentEventCommentInput(elements,trigger)
def pbCurrentEventCommentInput(elements, trigger)
return nil if !pbMapInterpreterRunning?
event = pbMapInterpreter.get_self
return nil if !event
return pbEventCommentInput(event,elements,trigger)
return pbEventCommentInput(event, elements, trigger)
end
@@ -60,54 +60,54 @@ class ChooseNumberParams
attr_reader :skin
def initialize
@maxDigits=0
@minNumber=0
@maxNumber=0
@skin=nil
@messageSkin=nil
@negativesAllowed=false
@initialNumber=0
@cancelNumber=nil
@maxDigits = 0
@minNumber = 0
@maxNumber = 0
@skin = nil
@messageSkin = nil
@negativesAllowed = false
@initialNumber = 0
@cancelNumber = nil
end
def setMessageSkin(value)
@messageSkin=value
@messageSkin = value
end
def setSkin(value)
@skin=value
@skin = value
end
def setNegativesAllowed(value)
@negativeAllowed=value
@negativeAllowed = value
end
def negativesAllowed
@negativeAllowed ? true : false
end
def setRange(minNumber,maxNumber)
maxNumber=minNumber if minNumber>maxNumber
@maxDigits=0
@minNumber=minNumber
@maxNumber=maxNumber
def setRange(minNumber, maxNumber)
maxNumber = minNumber if minNumber > maxNumber
@maxDigits = 0
@minNumber = minNumber
@maxNumber = maxNumber
end
def setDefaultValue(number)
@initialNumber=number
@cancelNumber=nil
@initialNumber = number
@cancelNumber = nil
end
def setInitialValue(number)
@initialNumber=number
@initialNumber = number
end
def setCancelValue(number)
@cancelNumber=number
@cancelNumber = number
end
def initialNumber
return clamp(@initialNumber,self.minNumber,self.maxNumber)
return clamp(@initialNumber, self.minNumber, self.maxNumber)
end
def cancelNumber
@@ -115,51 +115,51 @@ class ChooseNumberParams
end
def minNumber
ret=0
if @maxDigits>0
ret=-((10**@maxDigits)-1)
ret = 0
if @maxDigits > 0
ret = -((10**@maxDigits) - 1)
else
ret=@minNumber
ret = @minNumber
end
ret=0 if !@negativeAllowed && ret<0
ret = 0 if !@negativeAllowed && ret < 0
return ret
end
def maxNumber
ret=0
if @maxDigits>0
ret=((10**@maxDigits)-1)
ret = 0
if @maxDigits > 0
ret = ((10**@maxDigits) - 1)
else
ret=@maxNumber
ret = @maxNumber
end
ret=0 if !@negativeAllowed && ret<0
ret = 0 if !@negativeAllowed && ret < 0
return ret
end
def setMaxDigits(value)
@maxDigits=[1,value].max
@maxDigits = [1, value].max
end
def maxDigits
if @maxDigits>0
if @maxDigits > 0
return @maxDigits
else
return [numDigits(self.minNumber),numDigits(self.maxNumber)].max
return [numDigits(self.minNumber), numDigits(self.maxNumber)].max
end
end
private
def clamp(v,mn,mx)
return v<mn ? mn : (v>mx ? mx : v)
def clamp(v, mn, mx)
return v < mn ? mn : (v > mx ? mx : v)
end
def numDigits(number)
ans = 1
number=number.abs
number = number.abs
while number >= 10
ans+=1
number/=10
ans += 1
number /= 10
end
return ans
end
@@ -167,20 +167,20 @@ end
def pbChooseNumber(msgwindow,params)
def pbChooseNumber(msgwindow, params)
return 0 if !params
ret=0
maximum=params.maxNumber
minimum=params.minNumber
defaultNumber=params.initialNumber
cancelNumber=params.cancelNumber
cmdwindow=Window_InputNumberPokemon.new(params.maxDigits)
cmdwindow.z=99999
cmdwindow.visible=true
ret = 0
maximum = params.maxNumber
minimum = params.minNumber
defaultNumber = params.initialNumber
cancelNumber = params.cancelNumber
cmdwindow = Window_InputNumberPokemon.new(params.maxDigits)
cmdwindow.z = 99999
cmdwindow.visible = true
cmdwindow.setSkin(params.skin) if params.skin
cmdwindow.sign=params.negativesAllowed # must be set before number
cmdwindow.number=defaultNumber
pbPositionNearMsgWindow(cmdwindow,msgwindow,:right)
cmdwindow.sign = params.negativesAllowed # must be set before number
cmdwindow.number = defaultNumber
pbPositionNearMsgWindow(cmdwindow, msgwindow, :right)
loop do
Graphics.update
Input.update
@@ -189,10 +189,10 @@ def pbChooseNumber(msgwindow,params)
msgwindow.update if msgwindow
yield if block_given?
if Input.trigger?(Input::USE)
ret=cmdwindow.number
if ret>maximum
ret = cmdwindow.number
if ret > maximum
pbPlayBuzzerSE()
elsif ret<minimum
elsif ret < minimum
pbPlayBuzzerSE()
else
pbPlayDecisionSE()
@@ -200,7 +200,7 @@ def pbChooseNumber(msgwindow,params)
end
elsif Input.trigger?(Input::BACK)
pbPlayCancelSE()
ret=cancelNumber
ret = cancelNumber
break
end
end
@@ -216,26 +216,26 @@ end
#===============================================================================
class FaceWindowVX < SpriteWindow_Base
def initialize(face)
super(0,0,128,128)
faceinfo=face.split(",")
facefile=pbResolveBitmap("Graphics/Faces/"+faceinfo[0])
facefile=pbResolveBitmap("Graphics/Pictures/"+faceinfo[0]) if !facefile
super(0, 0, 128, 128)
faceinfo = face.split(",")
facefile = pbResolveBitmap("Graphics/Faces/" + faceinfo[0])
facefile = pbResolveBitmap("Graphics/Pictures/" + faceinfo[0]) if !facefile
self.contents.dispose if self.contents
@faceIndex=faceinfo[1].to_i
@facebitmaptmp=AnimatedBitmap.new(facefile)
@facebitmap=BitmapWrapper.new(96,96)
@facebitmap.blt(0,0,@facebitmaptmp.bitmap,Rect.new(
@faceIndex = faceinfo[1].to_i
@facebitmaptmp = AnimatedBitmap.new(facefile)
@facebitmap = BitmapWrapper.new(96, 96)
@facebitmap.blt(0, 0, @facebitmaptmp.bitmap, Rect.new(
(@faceIndex % 4) * 96,
(@faceIndex / 4) * 96, 96, 96
))
self.contents=@facebitmap
self.contents = @facebitmap
end
def update
super
if @facebitmaptmp.totalFrames>1
if @facebitmaptmp.totalFrames > 1
@facebitmaptmp.update
@facebitmap.blt(0,0,@facebitmaptmp.bitmap,Rect.new(
@facebitmap.blt(0, 0, @facebitmaptmp.bitmap, Rect.new(
(@faceIndex % 4) * 96,
(@faceIndex / 4) * 96, 96, 96
))
@@ -272,44 +272,44 @@ def pbGetMapNameFromId(id)
end
def pbCsvField!(str)
ret=""
str.sub!(/\A\s*/,"")
if str[0,1]=="\""
str[0,1]=""
escaped=false
fieldbytes=0
ret = ""
str.sub!(/\A\s*/, "")
if str[0, 1] == "\""
str[0, 1] = ""
escaped = false
fieldbytes = 0
str.scan(/./) do |s|
fieldbytes+=s.length
break if s=="\"" && !escaped
if s=="\\" && !escaped
escaped=true
fieldbytes += s.length
break if s == "\"" && !escaped
if s == "\\" && !escaped
escaped = true
else
ret+=s
escaped=false
ret += s
escaped = false
end
end
str[0,fieldbytes]=""
str[0, fieldbytes] = ""
if !str[/\A\s*,/] && !str[/\A\s*$/]
raise _INTL("Invalid quoted field (in: {1})",ret)
raise _INTL("Invalid quoted field (in: {1})", ret)
end
str[0,str.length]=$~.post_match
str[0, str.length] = $~.post_match
else
if str[/,/]
str[0,str.length]=$~.post_match
ret=$~.pre_match
str[0, str.length] = $~.post_match
ret = $~.pre_match
else
ret=str.clone
str[0,str.length]=""
ret = str.clone
str[0, str.length] = ""
end
ret.gsub!(/\s+$/,"")
ret.gsub!(/\s+$/, "")
end
return ret
end
def pbCsvPosInt!(str)
ret=pbCsvField!(str)
ret = pbCsvField!(str)
if !ret[/\A\d+$/]
raise _INTL("Field {1} is not a positive integer",ret)
raise _INTL("Field {1} is not a positive integer", ret)
end
return ret.to_i
end
@@ -324,50 +324,50 @@ def pbGetGoldString
end
def pbDisplayGoldWindow(msgwindow)
moneyString=pbGetGoldString()
goldwindow=Window_AdvancedTextPokemon.new(_INTL("Money:\n<ar>{1}</ar>",moneyString))
moneyString = pbGetGoldString()
goldwindow = Window_AdvancedTextPokemon.new(_INTL("Money:\n<ar>{1}</ar>", moneyString))
goldwindow.setSkin("Graphics/Windowskins/goldskin")
goldwindow.resizeToFit(goldwindow.text,Graphics.width)
goldwindow.width=160 if goldwindow.width<=160
if msgwindow.y==0
goldwindow.y=Graphics.height-goldwindow.height
goldwindow.resizeToFit(goldwindow.text, Graphics.width)
goldwindow.width = 160 if goldwindow.width <= 160
if msgwindow.y == 0
goldwindow.y = Graphics.height - goldwindow.height
else
goldwindow.y=0
goldwindow.y = 0
end
goldwindow.viewport=msgwindow.viewport
goldwindow.z=msgwindow.z
goldwindow.viewport = msgwindow.viewport
goldwindow.z = msgwindow.z
return goldwindow
end
def pbDisplayCoinsWindow(msgwindow,goldwindow)
def pbDisplayCoinsWindow(msgwindow, goldwindow)
coinString = ($player) ? $player.coins.to_s_formatted : "0"
coinwindow=Window_AdvancedTextPokemon.new(_INTL("Coins:\n<ar>{1}</ar>",coinString))
coinwindow = Window_AdvancedTextPokemon.new(_INTL("Coins:\n<ar>{1}</ar>", coinString))
coinwindow.setSkin("Graphics/Windowskins/goldskin")
coinwindow.resizeToFit(coinwindow.text,Graphics.width)
coinwindow.width=160 if coinwindow.width<=160
if msgwindow.y==0
coinwindow.y=(goldwindow) ? goldwindow.y-coinwindow.height : Graphics.height-coinwindow.height
coinwindow.resizeToFit(coinwindow.text, Graphics.width)
coinwindow.width = 160 if coinwindow.width <= 160
if msgwindow.y == 0
coinwindow.y = (goldwindow) ? goldwindow.y - coinwindow.height : Graphics.height - coinwindow.height
else
coinwindow.y=(goldwindow) ? goldwindow.height : 0
coinwindow.y = (goldwindow) ? goldwindow.height : 0
end
coinwindow.viewport=msgwindow.viewport
coinwindow.z=msgwindow.z
coinwindow.viewport = msgwindow.viewport
coinwindow.z = msgwindow.z
return coinwindow
end
def pbDisplayBattlePointsWindow(msgwindow)
pointsString = ($player) ? $player.battle_points.to_s_formatted : "0"
pointswindow=Window_AdvancedTextPokemon.new(_INTL("Battle Points:\n<ar>{1}</ar>", pointsString))
pointswindow = Window_AdvancedTextPokemon.new(_INTL("Battle Points:\n<ar>{1}</ar>", pointsString))
pointswindow.setSkin("Graphics/Windowskins/goldskin")
pointswindow.resizeToFit(pointswindow.text,Graphics.width)
pointswindow.width=160 if pointswindow.width<=160
if msgwindow.y==0
pointswindow.y=Graphics.height-pointswindow.height
pointswindow.resizeToFit(pointswindow.text, Graphics.width)
pointswindow.width = 160 if pointswindow.width <= 160
if msgwindow.y == 0
pointswindow.y = Graphics.height - pointswindow.height
else
pointswindow.y=0
pointswindow.y = 0
end
pointswindow.viewport=msgwindow.viewport
pointswindow.z=msgwindow.z
pointswindow.viewport = msgwindow.viewport
pointswindow.z = msgwindow.z
return pointswindow
end
@@ -377,39 +377,39 @@ end
#
#===============================================================================
def pbCreateStatusWindow(viewport = nil)
msgwindow=Window_AdvancedTextPokemon.new("")
msgwindow = Window_AdvancedTextPokemon.new("")
if !viewport
msgwindow.z=99999
msgwindow.z = 99999
else
msgwindow.viewport=viewport
msgwindow.viewport = viewport
end
msgwindow.visible=false
msgwindow.letterbyletter=false
pbBottomLeftLines(msgwindow,2)
skinfile=MessageConfig.pbGetSpeechFrame()
msgwindow.visible = false
msgwindow.letterbyletter = false
pbBottomLeftLines(msgwindow, 2)
skinfile = MessageConfig.pbGetSpeechFrame()
msgwindow.setSkin(skinfile)
return msgwindow
end
def pbCreateMessageWindow(viewport = nil,skin = nil)
msgwindow=Window_AdvancedTextPokemon.new("")
def pbCreateMessageWindow(viewport = nil, skin = nil)
msgwindow = Window_AdvancedTextPokemon.new("")
if !viewport
msgwindow.z=99999
msgwindow.z = 99999
else
msgwindow.viewport=viewport
msgwindow.viewport = viewport
end
msgwindow.visible=true
msgwindow.letterbyletter=true
msgwindow.back_opacity=MessageConfig::WINDOW_OPACITY
pbBottomLeftLines(msgwindow,2)
$game_temp.message_window_showing=true if $game_temp
skin=MessageConfig.pbGetSpeechFrame() if !skin
msgwindow.visible = true
msgwindow.letterbyletter = true
msgwindow.back_opacity = MessageConfig::WINDOW_OPACITY
pbBottomLeftLines(msgwindow, 2)
$game_temp.message_window_showing = true if $game_temp
skin = MessageConfig.pbGetSpeechFrame() if !skin
msgwindow.setSkin(skin)
return msgwindow
end
def pbDisposeMessageWindow(msgwindow)
$game_temp.message_window_showing=false if $game_temp
$game_temp.message_window_showing = false if $game_temp
msgwindow.dispose
end
@@ -418,29 +418,29 @@ end
#===============================================================================
# Main message-displaying function
#===============================================================================
def pbMessageDisplay(msgwindow,message,letterbyletter = true,commandProc = nil)
def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = nil)
return if !msgwindow
oldletterbyletter=msgwindow.letterbyletter
msgwindow.letterbyletter=(letterbyletter) ? true : false
ret=nil
commands=nil
facewindow=nil
goldwindow=nil
coinwindow=nil
battlepointswindow=nil
cmdvariable=0
cmdIfCancel=0
msgwindow.waitcount=0
autoresume=false
text=message.clone
msgback=nil
linecount=(Graphics.height>400) ? 3 : 2
oldletterbyletter = msgwindow.letterbyletter
msgwindow.letterbyletter = (letterbyletter) ? true : false
ret = nil
commands = nil
facewindow = nil
goldwindow = nil
coinwindow = nil
battlepointswindow = nil
cmdvariable = 0
cmdIfCancel = 0
msgwindow.waitcount = 0
autoresume = false
text = message.clone
msgback = nil
linecount = (Graphics.height > 400) ? 3 : 2
### Text replacement
text.gsub!(/\\sign\[([^\]]*)\]/i) { # \sign[something] gets turned into
next "\\op\\cl\\ts[]\\w["+$1+"]" # \op\cl\ts[]\w[something]
next "\\op\\cl\\ts[]\\w[" + $1 + "]" # \op\cl\ts[]\w[something]
}
text.gsub!(/\\\\/,"\5")
text.gsub!(/\\1/,"\1")
text.gsub!(/\\\\/, "\5")
text.gsub!(/\\1/, "\1")
if $game_actors
text.gsub!(/\\n\[([1-8])\]/i) {
m = $1.to_i
@@ -461,17 +461,17 @@ def pbMessageDisplay(msgwindow,message,letterbyletter = true,commandProc = nil)
text.gsub!(/\\r/i, "<c3=E00808,D0D0C8>")
text.gsub!(/\\[Ww]\[([^\]]*)\]/) {
w = $1.to_s
if w==""
if w == ""
msgwindow.windowskin = nil
else
msgwindow.setSkin("Graphics/Windowskins/#{w}",false)
msgwindow.setSkin("Graphics/Windowskins/#{w}", false)
end
next ""
}
isDarkSkin = isDarkWindowskin(msgwindow.windowskin)
text.gsub!(/\\[Cc]\[([0-9]+)\]/) {
m = $1.to_i
next getSkinColor(msgwindow.windowskin,m,isDarkSkin)
next getSkinColor(msgwindow.windowskin, m, isDarkSkin)
}
loop do
last_text = text.clone
@@ -481,33 +481,33 @@ def pbMessageDisplay(msgwindow,message,letterbyletter = true,commandProc = nil)
loop do
last_text = text.clone
text.gsub!(/\\l\[([0-9]+)\]/i) {
linecount = [1,$1.to_i].max
linecount = [1, $1.to_i].max
next ""
}
break if text == last_text
end
colortag = ""
if $game_system && $game_system.message_frame != 0
colortag = getSkinColor(msgwindow.windowskin,0,true)
colortag = getSkinColor(msgwindow.windowskin, 0, true)
else
colortag = getSkinColor(msgwindow.windowskin,0,isDarkSkin)
colortag = getSkinColor(msgwindow.windowskin, 0, isDarkSkin)
end
text = colortag+text
text = colortag + text
### Controls
textchunks=[]
controls=[]
textchunks = []
controls = []
while text[/(?:\\(f|ff|ts|cl|me|se|wt|wtnp|ch)\[([^\]]*)\]|\\(g|cn|pt|wd|wm|op|cl|wu|\.|\||\!|\^))/i]
textchunks.push($~.pre_match)
if $~[1]
controls.push([$~[1].downcase,$~[2],-1])
controls.push([$~[1].downcase, $~[2], -1])
else
controls.push([$~[3].downcase,"",-1])
controls.push([$~[3].downcase, "", -1])
end
text=$~.post_match
text = $~.post_match
end
textchunks.push(text)
for chunk in textchunks
chunk.gsub!(/\005/,"\\")
chunk.gsub!(/\005/, "\\")
end
textlen = 0
for i in 0...controls.length
@@ -523,7 +523,7 @@ def pbMessageDisplay(msgwindow,message,letterbyletter = true,commandProc = nil)
end
text = textchunks.join("")
signWaitCount = 0
signWaitTime = Graphics.frame_rate/2
signWaitTime = Graphics.frame_rate / 2
haveSpecialClose = false
specialCloseSE = ""
for i in 0...controls.length
@@ -531,9 +531,9 @@ def pbMessageDisplay(msgwindow,message,letterbyletter = true,commandProc = nil)
param = controls[i][1]
case control
when "op"
signWaitCount = signWaitTime+1
signWaitCount = signWaitTime + 1
when "cl"
text = text.sub(/\001\z/,"") # fix: '$' can match end of line as well
text = text.sub(/\001\z/, "") # fix: '$' can match end of line as well
haveSpecialClose = true
specialCloseSE = param
when "f"
@@ -547,59 +547,59 @@ def pbMessageDisplay(msgwindow,message,letterbyletter = true,commandProc = nil)
cmdvariable = pbCsvPosInt!(cmds)
cmdIfCancel = pbCsvField!(cmds).to_i
commands = []
while cmds.length>0
while cmds.length > 0
commands.push(pbCsvField!(cmds))
end
when "wtnp", "^"
text = text.sub(/\001\z/,"") # fix: '$' can match end of line as well
text = text.sub(/\001\z/, "") # fix: '$' can match end of line as well
when "se"
if controls[i][2]==0
if controls[i][2] == 0
startSE = param
controls[i] = nil
end
end
end
if startSE!=nil
if startSE != nil
pbSEPlay(pbStringToAudioFile(startSE))
elsif signWaitCount==0 && letterbyletter
elsif signWaitCount == 0 && letterbyletter
pbPlayDecisionSE()
end
########## Position message window ##############
pbRepositionMessageWindow(msgwindow,linecount)
pbRepositionMessageWindow(msgwindow, linecount)
if facewindow
pbPositionNearMsgWindow(facewindow,msgwindow,:left)
pbPositionNearMsgWindow(facewindow, msgwindow, :left)
facewindow.viewport = msgwindow.viewport
facewindow.z = msgwindow.z
end
atTop = (msgwindow.y==0)
atTop = (msgwindow.y == 0)
########## Show text #############################
msgwindow.text = text
Graphics.frame_reset if Graphics.frame_rate>40
Graphics.frame_reset if Graphics.frame_rate > 40
loop do
if signWaitCount>0
if signWaitCount > 0
signWaitCount -= 1
if atTop
msgwindow.y = -msgwindow.height*signWaitCount/signWaitTime
msgwindow.y = -msgwindow.height * signWaitCount / signWaitTime
else
msgwindow.y = Graphics.height-msgwindow.height*(signWaitTime-signWaitCount)/signWaitTime
msgwindow.y = Graphics.height - msgwindow.height * (signWaitTime - signWaitCount) / signWaitTime
end
end
for i in 0...controls.length
next if !controls[i]
next if controls[i][2]>msgwindow.position || msgwindow.waitcount!=0
next if controls[i][2] > msgwindow.position || msgwindow.waitcount != 0
control = controls[i][0]
param = controls[i][1]
case control
when "f"
facewindow.dispose if facewindow
facewindow = PictureWindow.new("Graphics/Pictures/#{param}")
pbPositionNearMsgWindow(facewindow,msgwindow,:left)
pbPositionNearMsgWindow(facewindow, msgwindow, :left)
facewindow.viewport = msgwindow.viewport
facewindow.z = msgwindow.z
when "ff"
facewindow.dispose if facewindow
facewindow = FaceWindowVX.new(param)
pbPositionNearMsgWindow(facewindow,msgwindow,:left)
pbPositionNearMsgWindow(facewindow, msgwindow, :left)
facewindow.viewport = msgwindow.viewport
facewindow.z = msgwindow.z
when "g" # Display gold window
@@ -607,7 +607,7 @@ def pbMessageDisplay(msgwindow,message,letterbyletter = true,commandProc = nil)
goldwindow = pbDisplayGoldWindow(msgwindow)
when "cn" # Display coins window
coinwindow.dispose if coinwindow
coinwindow = pbDisplayCoinsWindow(msgwindow,goldwindow)
coinwindow = pbDisplayCoinsWindow(msgwindow, goldwindow)
when "pt" # Display battle points window
battlepointswindow.dispose if battlepointswindow
battlepointswindow = pbDisplayBattlePointsWindow(msgwindow)
@@ -615,31 +615,31 @@ def pbMessageDisplay(msgwindow,message,letterbyletter = true,commandProc = nil)
msgwindow.y = 0
atTop = true
msgback.y = msgwindow.y if msgback
pbPositionNearMsgWindow(facewindow,msgwindow,:left)
msgwindow.y = -msgwindow.height*signWaitCount/signWaitTime
pbPositionNearMsgWindow(facewindow, msgwindow, :left)
msgwindow.y = -msgwindow.height * signWaitCount / signWaitTime
when "wm"
atTop = false
msgwindow.y = (Graphics.height-msgwindow.height)/2
msgwindow.y = (Graphics.height - msgwindow.height) / 2
msgback.y = msgwindow.y if msgback
pbPositionNearMsgWindow(facewindow,msgwindow,:left)
pbPositionNearMsgWindow(facewindow, msgwindow, :left)
when "wd"
atTop = false
msgwindow.y = Graphics.height-msgwindow.height
msgwindow.y = Graphics.height - msgwindow.height
msgback.y = msgwindow.y if msgback
pbPositionNearMsgWindow(facewindow,msgwindow,:left)
msgwindow.y = Graphics.height-msgwindow.height*(signWaitTime-signWaitCount)/signWaitTime
pbPositionNearMsgWindow(facewindow, msgwindow, :left)
msgwindow.y = Graphics.height - msgwindow.height * (signWaitTime - signWaitCount) / signWaitTime
when "ts" # Change text speed
msgwindow.textspeed = (param=="") ? -999 : param.to_i
msgwindow.textspeed = (param == "") ? -999 : param.to_i
when "." # Wait 0.25 seconds
msgwindow.waitcount += Graphics.frame_rate/4
msgwindow.waitcount += Graphics.frame_rate / 4
when "|" # Wait 1 second
msgwindow.waitcount += Graphics.frame_rate
when "wt" # Wait X/20 seconds
param = param.sub(/\A\s+/,"").sub(/\s+\z/,"")
msgwindow.waitcount += param.to_i*Graphics.frame_rate/20
param = param.sub(/\A\s+/, "").sub(/\s+\z/, "")
msgwindow.waitcount += param.to_i * Graphics.frame_rate / 20
when "wtnp" # Wait X/20 seconds, no pause
param = param.sub(/\A\s+/,"").sub(/\s+\z/,"")
msgwindow.waitcount = param.to_i*Graphics.frame_rate/20
param = param.sub(/\A\s+/, "").sub(/\s+\z/, "")
msgwindow.waitcount = param.to_i * Graphics.frame_rate / 20
autoresume = true
when "^" # Wait, no pause
autoresume = true
@@ -654,7 +654,7 @@ def pbMessageDisplay(msgwindow,message,letterbyletter = true,commandProc = nil)
Graphics.update
Input.update
facewindow.update if facewindow
if autoresume && msgwindow.waitcount==0
if autoresume && msgwindow.waitcount == 0
msgwindow.resume if msgwindow.busy?
break if !msgwindow.busy?
end
@@ -663,7 +663,7 @@ def pbMessageDisplay(msgwindow,message,letterbyletter = true,commandProc = nil)
pbPlayDecisionSE if msgwindow.pausing?
msgwindow.resume
else
break if signWaitCount==0
break if signWaitCount == 0
end
end
pbUpdateSceneMap
@@ -672,13 +672,13 @@ def pbMessageDisplay(msgwindow,message,letterbyletter = true,commandProc = nil)
break if (!letterbyletter || commandProc || commands) && !msgwindow.busy?
end
Input.update # Must call Input.update again to avoid extra triggers
msgwindow.letterbyletter=oldletterbyletter
msgwindow.letterbyletter = oldletterbyletter
if commands
$game_variables[cmdvariable]=pbShowCommands(msgwindow,commands,cmdIfCancel)
$game_variables[cmdvariable] = pbShowCommands(msgwindow, commands, cmdIfCancel)
$game_map.need_refresh = true if $game_map
end
if commandProc
ret=commandProc.call(msgwindow)
ret = commandProc.call(msgwindow)
end
msgback.dispose if msgback
goldwindow.dispose if goldwindow
@@ -687,12 +687,12 @@ def pbMessageDisplay(msgwindow,message,letterbyletter = true,commandProc = nil)
facewindow.dispose if facewindow
if haveSpecialClose
pbSEPlay(pbStringToAudioFile(specialCloseSE))
atTop = (msgwindow.y==0)
atTop = (msgwindow.y == 0)
for i in 0..signWaitTime
if atTop
msgwindow.y = -msgwindow.height*i/signWaitTime
msgwindow.y = -msgwindow.height * i / signWaitTime
else
msgwindow.y = Graphics.height-msgwindow.height*(signWaitTime-i)/signWaitTime
msgwindow.y = Graphics.height - msgwindow.height * (signWaitTime - i) / signWaitTime
end
Graphics.update
Input.update
@@ -708,49 +708,49 @@ end
#===============================================================================
# Message-displaying functions
#===============================================================================
def pbMessage(message,commands = nil,cmdIfCancel = 0,skin = nil,defaultCmd = 0,&block)
def pbMessage(message, commands = nil, cmdIfCancel = 0, skin = nil, defaultCmd = 0, &block)
ret = 0
msgwindow = pbCreateMessageWindow(nil,skin)
msgwindow = pbCreateMessageWindow(nil, skin)
if commands
ret = pbMessageDisplay(msgwindow,message,true,
ret = pbMessageDisplay(msgwindow, message, true,
proc { |msgwindow|
next Kernel.pbShowCommands(msgwindow,commands,cmdIfCancel,defaultCmd,&block)
},&block)
next Kernel.pbShowCommands(msgwindow, commands, cmdIfCancel, defaultCmd, &block)
}, &block)
else
pbMessageDisplay(msgwindow,message,&block)
pbMessageDisplay(msgwindow, message, &block)
end
pbDisposeMessageWindow(msgwindow)
Input.update
return ret
end
def pbConfirmMessage(message,&block)
return (pbMessage(message,[_INTL("Yes"),_INTL("No")],2,&block)==0)
def pbConfirmMessage(message, &block)
return (pbMessage(message, [_INTL("Yes"), _INTL("No")], 2, &block) == 0)
end
def pbConfirmMessageSerious(message,&block)
return (pbMessage(message,[_INTL("No"),_INTL("Yes")],1,&block)==1)
def pbConfirmMessageSerious(message, &block)
return (pbMessage(message, [_INTL("No"), _INTL("Yes")], 1, &block) == 1)
end
def pbMessageChooseNumber(message,params,&block)
msgwindow = pbCreateMessageWindow(nil,params.messageSkin)
ret = pbMessageDisplay(msgwindow,message,true,
def pbMessageChooseNumber(message, params, &block)
msgwindow = pbCreateMessageWindow(nil, params.messageSkin)
ret = pbMessageDisplay(msgwindow, message, true,
proc { |msgwindow|
next pbChooseNumber(msgwindow,params,&block)
},&block)
next pbChooseNumber(msgwindow, params, &block)
}, &block)
pbDisposeMessageWindow(msgwindow)
return ret
end
def pbShowCommands(msgwindow,commands = nil,cmdIfCancel = 0,defaultCmd = 0)
def pbShowCommands(msgwindow, commands = nil, cmdIfCancel = 0, defaultCmd = 0)
return 0 if !commands
cmdwindow=Window_CommandPokemonEx.new(commands)
cmdwindow.z=99999
cmdwindow.visible=true
cmdwindow = Window_CommandPokemonEx.new(commands)
cmdwindow.z = 99999
cmdwindow.visible = true
cmdwindow.resizeToFit(cmdwindow.commands)
pbPositionNearMsgWindow(cmdwindow,msgwindow,:right)
cmdwindow.index=defaultCmd
command=0
pbPositionNearMsgWindow(cmdwindow, msgwindow, :right)
cmdwindow.index = defaultCmd
command = 0
loop do
Graphics.update
Input.update
@@ -758,80 +758,80 @@ def pbShowCommands(msgwindow,commands = nil,cmdIfCancel = 0,defaultCmd = 0)
msgwindow.update if msgwindow
yield if block_given?
if Input.trigger?(Input::BACK)
if cmdIfCancel>0
command=cmdIfCancel-1
if cmdIfCancel > 0
command = cmdIfCancel - 1
break
elsif cmdIfCancel<0
command=cmdIfCancel
elsif cmdIfCancel < 0
command = cmdIfCancel
break
end
end
if Input.trigger?(Input::USE)
command=cmdwindow.index
command = cmdwindow.index
break
end
pbUpdateSceneMap
end
ret=command
ret = command
cmdwindow.dispose
Input.update
return ret
end
def pbShowCommandsWithHelp(msgwindow,commands,help,cmdIfCancel = 0,defaultCmd = 0)
msgwin=msgwindow
msgwin=pbCreateMessageWindow(nil) if !msgwindow
oldlbl=msgwin.letterbyletter
msgwin.letterbyletter=false
def pbShowCommandsWithHelp(msgwindow, commands, help, cmdIfCancel = 0, defaultCmd = 0)
msgwin = msgwindow
msgwin = pbCreateMessageWindow(nil) if !msgwindow
oldlbl = msgwin.letterbyletter
msgwin.letterbyletter = false
if commands
cmdwindow=Window_CommandPokemonEx.new(commands)
cmdwindow.z=99999
cmdwindow.visible=true
cmdwindow = Window_CommandPokemonEx.new(commands)
cmdwindow.z = 99999
cmdwindow.visible = true
cmdwindow.resizeToFit(cmdwindow.commands)
cmdwindow.height=msgwin.y if cmdwindow.height>msgwin.y
cmdwindow.index=defaultCmd
command=0
msgwin.text=help[cmdwindow.index]
msgwin.width=msgwin.width # Necessary evil to make it use the proper margins
cmdwindow.height = msgwin.y if cmdwindow.height > msgwin.y
cmdwindow.index = defaultCmd
command = 0
msgwin.text = help[cmdwindow.index]
msgwin.width = msgwin.width # Necessary evil to make it use the proper margins
loop do
Graphics.update
Input.update
oldindex=cmdwindow.index
oldindex = cmdwindow.index
cmdwindow.update
if oldindex!=cmdwindow.index
msgwin.text=help[cmdwindow.index]
if oldindex != cmdwindow.index
msgwin.text = help[cmdwindow.index]
end
msgwin.update
yield if block_given?
if Input.trigger?(Input::BACK)
if cmdIfCancel>0
command=cmdIfCancel-1
if cmdIfCancel > 0
command = cmdIfCancel - 1
break
elsif cmdIfCancel<0
command=cmdIfCancel
elsif cmdIfCancel < 0
command = cmdIfCancel
break
end
end
if Input.trigger?(Input::USE)
command=cmdwindow.index
command = cmdwindow.index
break
end
pbUpdateSceneMap
end
ret=command
ret = command
cmdwindow.dispose
Input.update
end
msgwin.letterbyletter=oldlbl
msgwin.letterbyletter = oldlbl
msgwin.dispose if !msgwindow
return ret
end
# frames is the number of 1/20 seconds to wait for
def pbMessageWaitForInput(msgwindow,frames,showPause = false)
return if !frames || frames<=0
def pbMessageWaitForInput(msgwindow, frames, showPause = false)
return if !frames || frames <= 0
msgwindow.startPause if msgwindow && showPause
frames = frames*Graphics.frame_rate/20
frames = frames * Graphics.frame_rate / 20
frames.times do
Graphics.update
Input.update
@@ -845,24 +845,24 @@ def pbMessageWaitForInput(msgwindow,frames,showPause = false)
msgwindow.stopPause if msgwindow && showPause
end
def pbFreeText(msgwindow,currenttext,passwordbox,maxlength,width = 240)
window=Window_TextEntry_Keyboard.new(currenttext,0,0,width,64)
ret=""
window.maxlength=maxlength
window.visible=true
window.z=99999
pbPositionNearMsgWindow(window,msgwindow,:right)
window.text=currenttext
window.passwordChar="*" if passwordbox
def pbFreeText(msgwindow, currenttext, passwordbox, maxlength, width = 240)
window = Window_TextEntry_Keyboard.new(currenttext, 0, 0, width, 64)
ret = ""
window.maxlength = maxlength
window.visible = true
window.z = 99999
pbPositionNearMsgWindow(window, msgwindow, :right)
window.text = currenttext
window.passwordChar = "*" if passwordbox
Input.text_input = true
loop do
Graphics.update
Input.update
if Input.triggerex?(:ESCAPE)
ret=currenttext
ret = currenttext
break
elsif Input.triggerex?(:RETURN)
ret=window.text
ret = window.text
break
end
window.update
@@ -875,12 +875,12 @@ def pbFreeText(msgwindow,currenttext,passwordbox,maxlength,width = 240)
return ret
end
def pbMessageFreeText(message,currenttext,passwordbox,maxlength,width = 240,&block)
msgwindow=pbCreateMessageWindow
retval=pbMessageDisplay(msgwindow,message,true,
def pbMessageFreeText(message, currenttext, passwordbox, maxlength, width = 240, &block)
msgwindow = pbCreateMessageWindow
retval = pbMessageDisplay(msgwindow, message, true,
proc { |msgwindow|
next pbFreeText(msgwindow,currenttext,passwordbox,maxlength,width,&block)
},&block)
next pbFreeText(msgwindow, currenttext, passwordbox, maxlength, width, &block)
}, &block)
pbDisposeMessageWindow(msgwindow)
return retval
end

View File

@@ -8,22 +8,22 @@ class CharacterEntryHelper
attr_accessor :cursor
def initialize(text)
@maxlength=-1
@text=text
@passwordChar=""
@cursor=text.scan(/./m).length
@maxlength = -1
@text = text
@passwordChar = ""
@cursor = text.scan(/./m).length
end
def textChars
chars=text.scan(/./m)
if @passwordChar!=""
chars = text.scan(/./m)
if @passwordChar != ""
chars.length.times { |i| chars[i] = @passwordChar }
end
return chars
end
def passwordChar=(value)
@passwordChar=value ? value : ""
@passwordChar = value ? value : ""
end
def length
@@ -31,52 +31,52 @@ class CharacterEntryHelper
end
def canInsert?
chars=self.text.scan(/./m)
return false if @maxlength>=0 && chars.length>=@maxlength
chars = self.text.scan(/./m)
return false if @maxlength >= 0 && chars.length >= @maxlength
return true
end
def insert(ch)
chars=self.text.scan(/./m)
return false if @maxlength>=0 && chars.length>=@maxlength
chars.insert(@cursor,ch)
@text=""
chars = self.text.scan(/./m)
return false if @maxlength >= 0 && chars.length >= @maxlength
chars.insert(@cursor, ch)
@text = ""
for ch in chars
@text+=ch if ch
@text += ch if ch
end
@cursor+=1
@cursor += 1
return true
end
def canDelete?
chars=self.text.scan(/./m)
return false if chars.length<=0 || @cursor<=0
chars = self.text.scan(/./m)
return false if chars.length <= 0 || @cursor <= 0
return true
end
def delete
chars=self.text.scan(/./m)
return false if chars.length<=0 || @cursor<=0
chars.delete_at(@cursor-1)
@text=""
chars = self.text.scan(/./m)
return false if chars.length <= 0 || @cursor <= 0
chars.delete_at(@cursor - 1)
@text = ""
for ch in chars
@text+=ch if ch
@text += ch if ch
end
@cursor-=1
@cursor -= 1
return true
end
private
def ensure
return if @maxlength<0
chars=self.text.scan(/./m)
if chars.length>@maxlength && @maxlength>=0
chars=chars[0,@maxlength]
return if @maxlength < 0
chars = self.text.scan(/./m)
if chars.length > @maxlength && @maxlength >= 0
chars = chars[0, @maxlength]
end
@text=""
@text = ""
for ch in chars
@text+=ch if ch
@text += ch if ch
end
end
end
@@ -87,19 +87,19 @@ end
#
#===============================================================================
class Window_TextEntry < SpriteWindow_Base
def initialize(text,x,y,width,height,heading = nil,usedarkercolor = false)
super(x,y,width,height)
colors=getDefaultTextColors(self.windowskin)
@baseColor=colors[0]
@shadowColor=colors[1]
def initialize(text, x, y, width, height, heading = nil, usedarkercolor = false)
super(x, y, width, height)
colors = getDefaultTextColors(self.windowskin)
@baseColor = colors[0]
@shadowColor = colors[1]
if usedarkercolor
@baseColor=Color.new(16,24,32)
@shadowColor=Color.new(168,184,184)
@baseColor = Color.new(16, 24, 32)
@shadowColor = Color.new(168, 184, 184)
end
@helper=CharacterEntryHelper.new(text)
@heading=heading
self.active=true
@frame=0
@helper = CharacterEntryHelper.new(text)
@heading = heading
self.active = true
@frame = 0
refresh
end
@@ -116,23 +116,23 @@ class Window_TextEntry < SpriteWindow_Base
end
def text=(value)
@helper.text=value
@helper.text = value
self.refresh
end
def passwordChar=(value)
@helper.passwordChar=value
@helper.passwordChar = value
refresh
end
def maxlength=(value)
@helper.maxlength=value
@helper.maxlength = value
self.refresh
end
def insert(ch)
if @helper.insert(ch)
@frame=0
@frame = 0
self.refresh
return true
end
@@ -141,7 +141,7 @@ class Window_TextEntry < SpriteWindow_Base
def delete
if @helper.delete
@frame=0
@frame = 0
self.refresh
return true
end
@@ -151,7 +151,7 @@ class Window_TextEntry < SpriteWindow_Base
def update
@frame += 1
@frame %= 20
self.refresh if (@frame%10)==0
self.refresh if (@frame % 10) == 0
return if !self.active
# Moving cursor
if Input.repeat?(Input::LEFT) && Input.press?(Input::ACTION)
@@ -172,47 +172,47 @@ class Window_TextEntry < SpriteWindow_Base
end
def refresh
self.contents=pbDoEnsureBitmap(self.contents,self.width-self.borderX,
self.height-self.borderY)
bitmap=self.contents
self.contents = pbDoEnsureBitmap(self.contents, self.width - self.borderX,
self.height - self.borderY)
bitmap = self.contents
bitmap.clear
x=0
y=0
x = 0
y = 0
if @heading
textwidth=bitmap.text_size(@heading).width
pbDrawShadowText(bitmap,x,y, textwidth+4, 32, @heading,@baseColor,@shadowColor)
y+=32
textwidth = bitmap.text_size(@heading).width
pbDrawShadowText(bitmap, x, y, textwidth + 4, 32, @heading, @baseColor, @shadowColor)
y += 32
end
x+=4
width=self.width-self.borderX
cursorcolor=Color.new(16,24,32)
textscan=self.text.scan(/./m)
scanlength=textscan.length
@helper.cursor=scanlength if @helper.cursor>scanlength
@helper.cursor=0 if @helper.cursor<0
startpos=@helper.cursor
fromcursor=0
while (startpos>0)
c=(@helper.passwordChar!="") ? @helper.passwordChar : textscan[startpos-1]
fromcursor+=bitmap.text_size(c).width
break if fromcursor>width-4
startpos-=1
x += 4
width = self.width - self.borderX
cursorcolor = Color.new(16, 24, 32)
textscan = self.text.scan(/./m)
scanlength = textscan.length
@helper.cursor = scanlength if @helper.cursor > scanlength
@helper.cursor = 0 if @helper.cursor < 0
startpos = @helper.cursor
fromcursor = 0
while (startpos > 0)
c = (@helper.passwordChar != "") ? @helper.passwordChar : textscan[startpos - 1]
fromcursor += bitmap.text_size(c).width
break if fromcursor > width - 4
startpos -= 1
end
for i in startpos...scanlength
c=(@helper.passwordChar!="") ? @helper.passwordChar : textscan[i]
textwidth=bitmap.text_size(c).width
next if c=="\n"
c = (@helper.passwordChar != "") ? @helper.passwordChar : textscan[i]
textwidth = bitmap.text_size(c).width
next if c == "\n"
# Draw text
pbDrawShadowText(bitmap,x,y, textwidth+4, 32, c,@baseColor,@shadowColor)
pbDrawShadowText(bitmap, x, y, textwidth + 4, 32, c, @baseColor, @shadowColor)
# Draw cursor if necessary
if ((@frame/10)&1) == 0 && i==@helper.cursor
bitmap.fill_rect(x,y+4,2,24,cursorcolor)
if ((@frame / 10) & 1) == 0 && i == @helper.cursor
bitmap.fill_rect(x, y + 4, 2, 24, cursorcolor)
end
# Add x to drawn text width
x += textwidth
end
if ((@frame/10)&1) == 0 && textscan.length==@helper.cursor
bitmap.fill_rect(x,y+4,2,24,cursorcolor)
if ((@frame / 10) & 1) == 0 && textscan.length == @helper.cursor
bitmap.fill_rect(x, y + 4, 2, 24, cursorcolor)
end
end
end
@@ -224,27 +224,27 @@ end
#===============================================================================
class Window_TextEntry_Keyboard < Window_TextEntry
def update
@frame+=1
@frame%=20
self.refresh if ((@frame%10)==0)
@frame += 1
@frame %= 20
self.refresh if ((@frame % 10) == 0)
return if !self.active
# Moving cursor
if Input.triggerex?(:LEFT) || Input.repeatex?(:LEFT)
if @helper.cursor > 0
@helper.cursor-=1
@frame=0
@helper.cursor -= 1
@frame = 0
self.refresh
end
return
elsif Input.triggerex?(:RIGHT) || Input.repeatex?(:RIGHT)
if @helper.cursor < self.text.scan(/./m).length
@helper.cursor+=1
@frame=0
@helper.cursor += 1
@frame = 0
self.refresh
end
return
elsif Input.triggerex?(:BACKSPACE) || Input.repeatex?(:BACKSPACE)
self.delete if @helper.cursor>0
self.delete if @helper.cursor > 0
return
elsif Input.triggerex?(:RETURN) || Input.triggerex?(:ESCAPE)
return
@@ -259,17 +259,17 @@ end
#
#===============================================================================
class Window_MultilineTextEntry < SpriteWindow_Base
def initialize(text,x,y,width,height)
super(x,y,width,height)
colors=getDefaultTextColors(self.windowskin)
@baseColor=colors[0]
@shadowColor=colors[1]
@helper=CharacterEntryHelper.new(text)
@firstline=0
@cursorLine=0
@cursorColumn=0
@frame=0
self.active=true
def initialize(text, x, y, width, height)
super(x, y, width, height)
colors = getDefaultTextColors(self.windowskin)
@baseColor = colors[0]
@shadowColor = colors[1]
@helper = CharacterEntryHelper.new(text)
@firstline = 0
@cursorLine = 0
@cursorColumn = 0
@frame = 0
self.active = true
refresh
end
@@ -277,12 +277,12 @@ class Window_MultilineTextEntry < SpriteWindow_Base
attr_reader :shadowColor
def baseColor=(value)
@baseColor=value
@baseColor = value
refresh
end
def shadowColor=(value)
@shadowColor=value
@shadowColor = value
refresh
end
@@ -295,23 +295,23 @@ class Window_MultilineTextEntry < SpriteWindow_Base
end
def text=(value)
@helper.text=value
@textchars=nil
@helper.text = value
@textchars = nil
self.refresh
end
def maxlength=(value)
@helper.maxlength=value
@textchars=nil
@helper.maxlength = value
@textchars = nil
self.refresh
end
def insert(ch)
@helper.cursor=getPosFromLineAndColumn(@cursorLine,@cursorColumn)
@helper.cursor = getPosFromLineAndColumn(@cursorLine, @cursorColumn)
if @helper.insert(ch)
@frame=0
@textchars=nil
moveCursor(0,1)
@frame = 0
@textchars = nil
moveCursor(0, 1)
self.refresh
return true
end
@@ -319,11 +319,11 @@ class Window_MultilineTextEntry < SpriteWindow_Base
end
def delete
@helper.cursor=getPosFromLineAndColumn(@cursorLine,@cursorColumn)
@helper.cursor = getPosFromLineAndColumn(@cursorLine, @cursorColumn)
if @helper.delete
@frame=0
moveCursor(0,-1) # use old textchars
@textchars=nil
@frame = 0
moveCursor(0, -1) # use old textchars
@textchars = nil
self.refresh
return true
end
@@ -332,67 +332,67 @@ class Window_MultilineTextEntry < SpriteWindow_Base
def getTextChars
if !@textchars
@textchars=getLineBrokenText(self.contents,@helper.text,
self.contents.width,nil)
@textchars = getLineBrokenText(self.contents, @helper.text,
self.contents.width, nil)
end
return @textchars
end
def getTotalLines
textchars=getTextChars
return 1 if textchars.length==0
tchar=textchars[textchars.length-1]
return tchar[5]+1
textchars = getTextChars
return 1 if textchars.length == 0
tchar = textchars[textchars.length - 1]
return tchar[5] + 1
end
def getLineY(line)
textchars=getTextChars
return 0 if textchars.length==0
totallines=getTotalLines()
line=0 if line<0
line=totallines-1 if line>=totallines
maximumY=0
textchars = getTextChars
return 0 if textchars.length == 0
totallines = getTotalLines()
line = 0 if line < 0
line = totallines - 1 if line >= totallines
maximumY = 0
for i in 0...textchars.length
thisline=textchars[i][5]
y=textchars[i][2]
return y if thisline==line
maximumY=y if maximumY<y
thisline = textchars[i][5]
y = textchars[i][2]
return y if thisline == line
maximumY = y if maximumY < y
end
return maximumY
end
def getColumnsInLine(line)
textchars=getTextChars
return 0 if textchars.length==0
totallines=getTotalLines()
line=0 if line<0
line=totallines-1 if line>=totallines
endpos=0
textchars = getTextChars
return 0 if textchars.length == 0
totallines = getTotalLines()
line = 0 if line < 0
line = totallines - 1 if line >= totallines
endpos = 0
for i in 0...textchars.length
thisline=textchars[i][5]
thislength=textchars[i][8]
endpos+=thislength if thisline==line
thisline = textchars[i][5]
thislength = textchars[i][8]
endpos += thislength if thisline == line
end
return endpos
end
def getPosFromLineAndColumn(line,column)
textchars=getTextChars
return 0 if textchars.length==0
totallines=getTotalLines()
line=0 if line<0
line=totallines-1 if line>=totallines
endpos=0
def getPosFromLineAndColumn(line, column)
textchars = getTextChars
return 0 if textchars.length == 0
totallines = getTotalLines()
line = 0 if line < 0
line = totallines - 1 if line >= totallines
endpos = 0
for i in 0...textchars.length
thisline=textchars[i][5]
thispos=textchars[i][6]
thiscolumn=textchars[i][7]
thislength=textchars[i][8]
if thisline==line
endpos=thispos+thislength
thisline = textchars[i][5]
thispos = textchars[i][6]
thiscolumn = textchars[i][7]
thislength = textchars[i][8]
if thisline == line
endpos = thispos + thislength
# echoln [endpos,thispos+(column-thiscolumn),textchars[i]]
if column>=thiscolumn && column<=thiscolumn+thislength && thislength>0
return thispos+(column-thiscolumn)
if column >= thiscolumn && column <= thiscolumn + thislength && thislength > 0
return thispos + (column - thiscolumn)
end
end
end
@@ -406,89 +406,89 @@ class Window_MultilineTextEntry < SpriteWindow_Base
def getLastVisibleLine
getTextChars()
textheight=[1,self.contents.text_size("X").height].max
lastVisible=@firstline+((self.height-self.borderY)/textheight)-1
textheight = [1, self.contents.text_size("X").height].max
lastVisible = @firstline + ((self.height - self.borderY) / textheight) - 1
return lastVisible
end
def updateCursorPos(doRefresh)
# Calculate new cursor position
@helper.cursor=getPosFromLineAndColumn(@cursorLine,@cursorColumn)
@helper.cursor = getPosFromLineAndColumn(@cursorLine, @cursorColumn)
if doRefresh
@frame=0
@frame = 0
self.refresh
end
@firstline=@cursorLine if @cursorLine<@firstline
lastVisible=getLastVisibleLine()
@firstline+=(@cursorLine-lastVisible) if @cursorLine>lastVisible
@firstline = @cursorLine if @cursorLine < @firstline
lastVisible = getLastVisibleLine()
@firstline += (@cursorLine - lastVisible) if @cursorLine > lastVisible
end
def moveCursor(lineOffset, columnOffset)
# Move column offset first, then lines (since column offset
# can affect line offset)
# echoln ["beforemoving",@cursorLine,@cursorColumn]
totalColumns=getColumnsInLine(@cursorLine) # check current line
totalLines=getTotalLines()
oldCursorLine=@cursorLine
oldCursorColumn=@cursorColumn
@cursorColumn+=columnOffset
if @cursorColumn<0 && @cursorLine>0
totalColumns = getColumnsInLine(@cursorLine) # check current line
totalLines = getTotalLines()
oldCursorLine = @cursorLine
oldCursorColumn = @cursorColumn
@cursorColumn += columnOffset
if @cursorColumn < 0 && @cursorLine > 0
# Will happen if cursor is moved left from the beginning of a line
@cursorLine-=1
@cursorColumn=getColumnsInLine(@cursorLine)
elsif @cursorColumn>totalColumns && @cursorLine<totalLines-1
@cursorLine -= 1
@cursorColumn = getColumnsInLine(@cursorLine)
elsif @cursorColumn > totalColumns && @cursorLine < totalLines - 1
# Will happen if cursor is moved right from the end of a line
@cursorLine+=1
@cursorColumn=0
@cursorLine += 1
@cursorColumn = 0
end
# Ensure column bounds
totalColumns=getColumnsInLine(@cursorLine)
@cursorColumn=totalColumns if @cursorColumn>totalColumns
@cursorColumn=0 if @cursorColumn<0 # totalColumns can be 0
totalColumns = getColumnsInLine(@cursorLine)
@cursorColumn = totalColumns if @cursorColumn > totalColumns
@cursorColumn = 0 if @cursorColumn < 0 # totalColumns can be 0
# Move line offset
@cursorLine+=lineOffset
@cursorLine=0 if @cursorLine<0
@cursorLine=totalLines-1 if @cursorLine>=totalLines
@cursorLine += lineOffset
@cursorLine = 0 if @cursorLine < 0
@cursorLine = totalLines - 1 if @cursorLine >= totalLines
# Ensure column bounds again
totalColumns=getColumnsInLine(@cursorLine)
@cursorColumn=totalColumns if @cursorColumn>totalColumns
@cursorColumn=0 if @cursorColumn<0 # totalColumns can be 0
totalColumns = getColumnsInLine(@cursorLine)
@cursorColumn = totalColumns if @cursorColumn > totalColumns
@cursorColumn = 0 if @cursorColumn < 0 # totalColumns can be 0
updateCursorPos(
oldCursorLine!=@cursorLine ||
oldCursorColumn!=@cursorColumn
oldCursorLine != @cursorLine ||
oldCursorColumn != @cursorColumn
)
# echoln ["aftermoving",@cursorLine,@cursorColumn]
end
def update
@frame+=1
@frame%=20
self.refresh if ((@frame%10)==0)
@frame += 1
@frame %= 20
self.refresh if ((@frame % 10) == 0)
return if !self.active
# Moving cursor
if Input.triggerex?(:UP) || Input.repeatex?(:UP)
moveCursor(-1,0)
moveCursor(-1, 0)
return
elsif Input.triggerex?(:DOWN) || Input.repeatex?(:DOWN)
moveCursor(1,0)
moveCursor(1, 0)
return
elsif Input.triggerex?(:LEFT) || Input.repeatex?(:LEFT)
moveCursor(0,-1)
moveCursor(0, -1)
return
elsif Input.triggerex?(:RIGHT) || Input.repeatex?(:RIGHT)
moveCursor(0,1)
moveCursor(0, 1)
return
end
if Input.press?(Input::CTRL) && Input.triggerex?(:HOME)
# Move cursor to beginning
@cursorLine=0
@cursorColumn=0
@cursorLine = 0
@cursorColumn = 0
updateCursorPos(true)
return
elsif Input.press?(Input::CTRL) && Input.triggerex?(:END)
# Move cursor to end
@cursorLine=getTotalLines()-1
@cursorColumn=getColumnsInLine(@cursorLine)
@cursorLine = getTotalLines() - 1
@cursorColumn = getColumnsInLine(@cursorLine)
updateCursorPos(true)
return
elsif Input.triggerex?(:RETURN) || Input.repeatex?(:RETURN)
@@ -502,59 +502,59 @@ class Window_MultilineTextEntry < SpriteWindow_Base
end
def refresh
newContents=pbDoEnsureBitmap(self.contents,self.width-self.borderX,
self.height-self.borderY)
@textchars=nil if self.contents!=newContents
self.contents=newContents
bitmap=self.contents
newContents = pbDoEnsureBitmap(self.contents, self.width - self.borderX,
self.height - self.borderY)
@textchars = nil if self.contents != newContents
self.contents = newContents
bitmap = self.contents
bitmap.clear
getTextChars
height=self.height-self.borderY
cursorcolor=Color.new(0,0,0)
textchars=getTextChars()
startY=getLineY(@firstline)
height = self.height - self.borderY
cursorcolor = Color.new(0, 0, 0)
textchars = getTextChars()
startY = getLineY(@firstline)
for i in 0...textchars.length
thisline=textchars[i][5]
thiscolumn=textchars[i][7]
thislength=textchars[i][8]
textY=textchars[i][2]-startY
thisline = textchars[i][5]
thiscolumn = textchars[i][7]
thislength = textchars[i][8]
textY = textchars[i][2] - startY
# Don't draw lines before the first or zero-length segments
next if thisline<@firstline || thislength==0
next if thisline < @firstline || thislength == 0
# Don't draw lines beyond the window's height
break if textY >= height
c=textchars[i][0]
c = textchars[i][0]
# Don't draw spaces
next if c==" "
textwidth=textchars[i][3]+4 # add 4 to prevent draw_text from stretching text
textheight=textchars[i][4]
next if c == " "
textwidth = textchars[i][3] + 4 # add 4 to prevent draw_text from stretching text
textheight = textchars[i][4]
# Draw text
pbDrawShadowText(bitmap, textchars[i][1], textY, textwidth, textheight, c, @baseColor, @shadowColor)
end
# Draw cursor
if ((@frame/10)&1) == 0
textheight=bitmap.text_size("X").height
cursorY=(textheight*@cursorLine)-startY
cursorX=0
if ((@frame / 10) & 1) == 0
textheight = bitmap.text_size("X").height
cursorY = (textheight * @cursorLine) - startY
cursorX = 0
for i in 0...textchars.length
thisline=textchars[i][5]
thiscolumn=textchars[i][7]
thislength=textchars[i][8]
if thisline==@cursorLine && @cursorColumn>=thiscolumn &&
@cursorColumn<=thiscolumn+thislength
cursorY=textchars[i][2]-startY
cursorX=textchars[i][1]
textheight=textchars[i][4]
posToCursor=@cursorColumn-thiscolumn
if posToCursor>=0
partialString=textchars[i][0].scan(/./m)[0,posToCursor].join("")
cursorX+=bitmap.text_size(partialString).width
thisline = textchars[i][5]
thiscolumn = textchars[i][7]
thislength = textchars[i][8]
if thisline == @cursorLine && @cursorColumn >= thiscolumn &&
@cursorColumn <= thiscolumn + thislength
cursorY = textchars[i][2] - startY
cursorX = textchars[i][1]
textheight = textchars[i][4]
posToCursor = @cursorColumn - thiscolumn
if posToCursor >= 0
partialString = textchars[i][0].scan(/./m)[0, posToCursor].join("")
cursorX += bitmap.text_size(partialString).width
end
break
end
end
cursorY+=4
cursorHeight=[4,textheight-4,bitmap.text_size("X").height-4].max
bitmap.fill_rect(cursorX,cursorY,2,cursorHeight,cursorcolor)
cursorY += 4
cursorHeight = [4, textheight - 4, bitmap.text_size("X").height - 4].max
bitmap.fill_rect(cursorX, cursorY, 2, cursorHeight, cursorcolor)
end
end
end

View File

@@ -1,7 +1,7 @@
#####################################
# Needed because RGSS doesn't call at_exit procs on exit
# Exit is not called when game is reset (using F12)
$AtExitProcs=[] if !$AtExitProcs
$AtExitProcs = [] if !$AtExitProcs
def exit(code = 0)
for p in $AtExitProcs
@@ -127,7 +127,7 @@ def getPlayTime2(filename)
data = fgetdw.call(file)
return -1 if data != 0x61746164 # "data"
datasize = fgetdw.call(file)
time = (datasize*1.0)/bytessec
time = (datasize * 1.0) / bytessec
return time
elsif fdw == 0x5367674F # "OggS"
file.pos = 0

View File

@@ -3,13 +3,13 @@ def pbStringToAudioFile(str)
file = $1
volume = $2.to_i
pitch = $3.to_i
return RPG::AudioFile.new(file,volume,pitch)
return RPG::AudioFile.new(file, volume, pitch)
elsif str[/^(.*)\:\s*(\d+)\s*$/] # Of the format "XXX: ###"
file = $1
volume = $2.to_i
return RPG::AudioFile.new(file,volume,100)
return RPG::AudioFile.new(file, volume, 100)
else
return RPG::AudioFile.new(str,100,100)
return RPG::AudioFile.new(str, 100, 100)
end
end
@@ -21,7 +21,7 @@ end
# filename:volume:pitch
# volume -- Volume of the file, up to 100
# pitch -- Pitch of the file, normally 100
def pbResolveAudioFile(str,volume = nil,pitch = nil)
def pbResolveAudioFile(str, volume = nil, pitch = nil)
if str.is_a?(String)
str = pbStringToAudioFile(str)
str.volume = volume || 100
@@ -49,21 +49,21 @@ end
# filename:volume:pitch
# volume -- Volume of the file, up to 100
# pitch -- Pitch of the file, normally 100
def pbBGMPlay(param,volume = nil,pitch = nil)
def pbBGMPlay(param, volume = nil, pitch = nil)
return if !param
param=pbResolveAudioFile(param,volume,pitch)
if param.name && param.name!=""
param = pbResolveAudioFile(param, volume, pitch)
if param.name && param.name != ""
if $game_system
$game_system.bgm_play(param)
return
elsif (RPG.const_defined?(:BGM) rescue false)
b=RPG::BGM.new(param.name,param.volume,param.pitch)
b = RPG::BGM.new(param.name, param.volume, param.pitch)
if b && b.respond_to?("play")
b.play
return
end
end
Audio.bgm_play(canonicalize("Audio/BGM/"+param.name),param.volume,param.pitch)
Audio.bgm_play(canonicalize("Audio/BGM/" + param.name), param.volume, param.pitch)
end
end
@@ -80,12 +80,12 @@ def pbBGMStop(timeInSeconds = 0.0)
return
elsif (RPG.const_defined?(:BGM) rescue false)
begin
(timeInSeconds>0.0) ? RPG::BGM.fade((timeInSeconds*1000).floor) : RPG::BGM.stop
(timeInSeconds > 0.0) ? RPG::BGM.fade((timeInSeconds * 1000).floor) : RPG::BGM.stop
return
rescue
end
end
(timeInSeconds>0.0) ? Audio.bgm_fade((timeInSeconds*1000).floor) : Audio.bgm_stop
(timeInSeconds > 0.0) ? Audio.bgm_fade((timeInSeconds * 1000).floor) : Audio.bgm_stop
end
################################################################################
@@ -99,21 +99,21 @@ end
# filename:volume:pitch
# volume -- Volume of the file, up to 100
# pitch -- Pitch of the file, normally 100
def pbMEPlay(param,volume = nil,pitch = nil)
def pbMEPlay(param, volume = nil, pitch = nil)
return if !param
param=pbResolveAudioFile(param,volume,pitch)
if param.name && param.name!=""
param = pbResolveAudioFile(param, volume, pitch)
if param.name && param.name != ""
if $game_system
$game_system.me_play(param)
return
elsif (RPG.const_defined?(:ME) rescue false)
b=RPG::ME.new(param.name,param.volume,param.pitch)
b = RPG::ME.new(param.name, param.volume, param.pitch)
if b && b.respond_to?("play")
b.play
return
end
end
Audio.me_play(canonicalize("Audio/ME/"+param.name),param.volume,param.pitch)
Audio.me_play(canonicalize("Audio/ME/" + param.name), param.volume, param.pitch)
end
end
@@ -122,7 +122,7 @@ def pbMEFade(x = 0.0); pbMEStop(x); end
# Fades out or stops ME playback. 'x' is the time in seconds to fade out.
def pbMEStop(timeInSeconds = 0.0)
if $game_system && timeInSeconds>0.0 && $game_system.respond_to?("me_fade")
if $game_system && timeInSeconds > 0.0 && $game_system.respond_to?("me_fade")
$game_system.me_fade(timeInSeconds)
return
elsif $game_system && $game_system.respond_to?("me_stop")
@@ -130,12 +130,12 @@ def pbMEStop(timeInSeconds = 0.0)
return
elsif (RPG.const_defined?(:ME) rescue false)
begin
(timeInSeconds>0.0) ? RPG::ME.fade((timeInSeconds*1000).floor) : RPG::ME.stop
(timeInSeconds > 0.0) ? RPG::ME.fade((timeInSeconds * 1000).floor) : RPG::ME.stop
return
rescue
end
end
(timeInSeconds>0.0) ? Audio.me_fade((timeInSeconds*1000).floor) : Audio.me_stop
(timeInSeconds > 0.0) ? Audio.me_fade((timeInSeconds * 1000).floor) : Audio.me_stop
end
################################################################################
@@ -149,21 +149,21 @@ end
# filename:volume:pitch
# volume -- Volume of the file, up to 100
# pitch -- Pitch of the file, normally 100
def pbBGSPlay(param,volume = nil,pitch = nil)
def pbBGSPlay(param, volume = nil, pitch = nil)
return if !param
param=pbResolveAudioFile(param,volume,pitch)
if param.name && param.name!=""
param = pbResolveAudioFile(param, volume, pitch)
if param.name && param.name != ""
if $game_system
$game_system.bgs_play(param)
return
elsif (RPG.const_defined?(:BGS) rescue false)
b=RPG::BGS.new(param.name,param.volume,param.pitch)
b = RPG::BGS.new(param.name, param.volume, param.pitch)
if b && b.respond_to?("play")
b.play
return
end
end
Audio.bgs_play(canonicalize("Audio/BGS/"+param.name),param.volume,param.pitch)
Audio.bgs_play(canonicalize("Audio/BGS/" + param.name), param.volume, param.pitch)
end
end
@@ -180,12 +180,12 @@ def pbBGSStop(timeInSeconds = 0.0)
return
elsif (RPG.const_defined?(:BGS) rescue false)
begin
(timeInSeconds>0.0) ? RPG::BGS.fade((timeInSeconds*1000).floor) : RPG::BGS.stop
(timeInSeconds > 0.0) ? RPG::BGS.fade((timeInSeconds * 1000).floor) : RPG::BGS.stop
return
rescue
end
end
(timeInSeconds>0.0) ? Audio.bgs_fade((timeInSeconds*1000).floor) : Audio.bgs_stop
(timeInSeconds > 0.0) ? Audio.bgs_fade((timeInSeconds * 1000).floor) : Audio.bgs_stop
end
################################################################################
@@ -199,22 +199,22 @@ end
# filename:volume:pitch
# volume -- Volume of the file, up to 100
# pitch -- Pitch of the file, normally 100
def pbSEPlay(param,volume = nil,pitch = nil)
def pbSEPlay(param, volume = nil, pitch = nil)
return if !param
param = pbResolveAudioFile(param,volume,pitch)
if param.name && param.name!=""
param = pbResolveAudioFile(param, volume, pitch)
if param.name && param.name != ""
if $game_system
$game_system.se_play(param)
return
end
if (RPG.const_defined?(:SE) rescue false)
b = RPG::SE.new(param.name,param.volume,param.pitch)
b = RPG::SE.new(param.name, param.volume, param.pitch)
if b && b.respond_to?("play")
b.play
return
end
end
Audio.se_play(canonicalize("Audio/SE/"+param.name),param.volume,param.pitch)
Audio.se_play(canonicalize("Audio/SE/" + param.name), param.volume, param.pitch)
end
end
@@ -239,7 +239,7 @@ def pbPlayCursorSE
if !nil_or_empty?($data_system&.cursor_se&.name)
pbSEPlay($data_system.cursor_se)
elsif FileTest.audio_exist?("Audio/SE/GUI sel cursor")
pbSEPlay("GUI sel cursor",80)
pbSEPlay("GUI sel cursor", 80)
end
end
@@ -248,7 +248,7 @@ def pbPlayDecisionSE
if !nil_or_empty?($data_system&.decision_se&.name)
pbSEPlay($data_system.decision_se)
elsif FileTest.audio_exist?("Audio/SE/GUI sel decision")
pbSEPlay("GUI sel decision",80)
pbSEPlay("GUI sel decision", 80)
end
end
@@ -257,7 +257,7 @@ def pbPlayCancelSE
if !nil_or_empty?($data_system&.cancel_se&.name)
pbSEPlay($data_system.cancel_se)
elsif FileTest.audio_exist?("Audio/SE/GUI sel cancel")
pbSEPlay("GUI sel cancel",80)
pbSEPlay("GUI sel cancel", 80)
end
end
@@ -266,13 +266,13 @@ def pbPlayBuzzerSE
if !nil_or_empty?($data_system&.buzzer_se&.name)
pbSEPlay($data_system.buzzer_se)
elsif FileTest.audio_exist?("Audio/SE/GUI sel buzzer")
pbSEPlay("GUI sel buzzer",80)
pbSEPlay("GUI sel buzzer", 80)
end
end
# Plays a sound effect that plays when the player moves the cursor.
def pbPlayCloseMenuSE
if FileTest.audio_exist?("Audio/SE/GUI menu close")
pbSEPlay("GUI menu close",80)
pbSEPlay("GUI menu close", 80)
end
end

View File

@@ -41,7 +41,7 @@ module Graphics
@@transition = nil if @@transition && @@transition.disposed?
end
def self.judge_special_transition(duration,filename)
def self.judge_special_transition(duration, filename)
return false if @_interrupt_transition
ret = true
if @@transition && !@@transition.disposed?
@@ -282,7 +282,7 @@ module Transitions
move_x = (dx == 0) ? rand_sign * vague : dx * SPEED * 1.5
move_y = (dy == 0) ? rand_sign * vague : dy * SPEED * 1.5
else
radius = Math.sqrt(dx ** 2 + dy ** 2)
radius = Math.sqrt(dx**2 + dy**2)
move_x = dx * vague / radius
move_y = dy * vague / radius
end

View File

@@ -24,9 +24,9 @@ class PictureSprite < SpriteWrapper
super
@pictureBitmap.update if @pictureBitmap
# If picture file name is different from current one
if @customBitmap && @picture.name==""
if @customBitmap && @picture.name == ""
self.bitmap = (@customBitmapIsBitmap) ? @customBitmap : @customBitmap.bitmap
elsif @picture_name != @picture.name || @picture.hue.to_i != @hue.to_i
elsif @picture_name != @picture.name || @picture.hue.to_i != @hue.to_i
# Remember file name to instance variables
@picture_name = @picture.name
@hue = @picture.hue.to_i
@@ -46,16 +46,16 @@ class PictureSprite < SpriteWrapper
self.visible = false
return
end
setPictureSprite(self,@picture)
setPictureSprite(self, @picture)
end
end
def pbTextBitmap(text, maxwidth = Graphics.width)
tmp = Bitmap.new(maxwidth,Graphics.height)
tmp = Bitmap.new(maxwidth, Graphics.height)
pbSetSystemFont(tmp)
drawFormattedTextEx(tmp,0,0,maxwidth,text,Color.new(248,248,248),Color.new(168,184,184))
drawFormattedTextEx(tmp, 0, 0, maxwidth, text, Color.new(248, 248, 248), Color.new(168, 184, 184))
return tmp
end
@@ -65,7 +65,7 @@ end
# EventScene
#===============================================================================
class EventScene
attr_accessor :onCTrigger,:onBTrigger,:onUpdate
attr_accessor :onCTrigger, :onBTrigger, :onUpdate
def initialize(viewport = nil)
@viewport = viewport
@@ -105,26 +105,26 @@ class EventScene
# EventScene doesn't take ownership of the passed-in bitmap
num = @pictures.length
picture = PictureEx.new(num)
picture.setXY(0,x,y)
picture.setVisible(0,true)
picture.setXY(0, x, y)
picture.setVisible(0, true)
@pictures[num] = picture
@picturesprites[num] = PictureSprite.new(@viewport,picture)
@picturesprites[num] = PictureSprite.new(@viewport, picture)
@picturesprites[num].setCustomBitmap(bitmap)
return picture
end
def addLabel(x, y, width, text)
addBitmap(x,y,pbTextBitmap(text,width))
addBitmap(x, y, pbTextBitmap(text, width))
end
def addImage(x, y, name)
num = @pictures.length
picture = PictureEx.new(num)
picture.name = name
picture.setXY(0,x,y)
picture.setVisible(0,true)
picture.setXY(0, x, y)
picture.setVisible(0, true)
@pictures[num] = picture
@picturesprites[num] = PictureSprite.new(@viewport,picture)
@picturesprites[num] = PictureSprite.new(@viewport, picture)
return picture
end
@@ -188,7 +188,7 @@ end
#===============================================================================
def pbEventScreen(cls)
pbFadeOutIn {
viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
viewport.z = 99999
PBDebug.logonerr {
cls.new(viewport).main

View File

@@ -88,7 +88,7 @@ GameData::GrowthRate.register({
357911, 373248, 389017, 405224, 421875, 438976, 456533, 474552, 493039, 512000,
531441, 551368, 571787, 592704, 614125, 636056, 658503, 681472, 704969, 729000,
753571, 778688, 804357, 830584, 857375, 884736, 912673, 941192, 970299, 1000000],
:exp_formula => proc { |level| next level ** 3 }
:exp_formula => proc { |level| next level**3 }
})
# Erratic (600000):
@@ -111,7 +111,7 @@ GameData::GrowthRate.register({
286328, 296358, 305767, 316074, 326531, 336255, 346965, 357812, 367807, 378880,
390077, 400293, 411686, 423190, 433572, 445239, 457001, 467489, 479378, 491346,
501878, 513934, 526049, 536557, 548720, 560922, 571333, 583539, 591882, 600000],
:exp_formula => proc { |level| next (level ** 4) * 3 / 500 }
:exp_formula => proc { |level| next (level**4) * 3 / 500 }
})
# Fluctuating (1640000):
@@ -134,7 +134,7 @@ GameData::GrowthRate.register({
1160499, 1214753, 1254796, 1312322, 1354652, 1415577, 1460276, 1524731, 1571884, 1640000],
:exp_formula => proc { |level|
rate = [82 - (level - 100) / 2.0, 40].max
next (level ** 4) * rate / 5000
next (level**4) * rate / 5000
}
})
@@ -152,7 +152,7 @@ GameData::GrowthRate.register({
360838, 377197, 394045, 411388, 429235, 447591, 466464, 485862, 505791, 526260,
547274, 568841, 590969, 613664, 636935, 660787, 685228, 710266, 735907, 762160,
789030, 816525, 844653, 873420, 902835, 932903, 963632, 995030, 1027103, 1059860],
:exp_formula => proc { |level| next ((level ** 3) * 6 / 5) - 15 * (level ** 2) + 100 * level - 140 }
:exp_formula => proc { |level| next ((level**3) * 6 / 5) - 15 * (level**2) + 100 * level - 140 }
})
GameData::GrowthRate.register({
@@ -169,7 +169,7 @@ GameData::GrowthRate.register({
286328, 298598, 311213, 324179, 337500, 351180, 365226, 379641, 394431, 409600,
425152, 441094, 457429, 474163, 491300, 508844, 526802, 545177, 563975, 583200,
602856, 622950, 643485, 664467, 685900, 707788, 730138, 752953, 776239, 800000],
:exp_formula => proc { |level| (level ** 3) * 4 / 5 }
:exp_formula => proc { |level| (level**3) * 4 / 5 }
})
GameData::GrowthRate.register({
@@ -186,5 +186,5 @@ GameData::GrowthRate.register({
447388, 466560, 486271, 506530, 527343, 548720, 570666, 593190, 616298, 640000,
664301, 689210, 714733, 740880, 767656, 795070, 823128, 851840, 881211, 911250,
941963, 973360, 1005446, 1038230, 1071718, 1105920, 1140841, 1176490, 1212873, 1250000],
:exp_formula => proc { |level| (level ** 3) * 5 / 4 }
:exp_formula => proc { |level| (level**3) * 5 / 4 }
})

View File

@@ -72,7 +72,7 @@ module Effectiveness
NOT_VERY_EFFECTIVE_ONE = 1
NORMAL_EFFECTIVE_ONE = 2
SUPER_EFFECTIVE_ONE = 4
NORMAL_EFFECTIVE = NORMAL_EFFECTIVE_ONE ** 3
NORMAL_EFFECTIVE = NORMAL_EFFECTIVE_ONE**3
module_function

View File

@@ -13,10 +13,10 @@ module GameData
factors.push([1, try_form, ""]) if form > 0
factors.push([0, try_species, "000"])
# Go through each combination of parameters in turn to find an existing sprite
for i in 0...2 ** factors.length
for i in 0...2**factors.length
# Set try_ parameters for this combination
factors.each_with_index do |factor, index|
value = ((i / (2 ** index)) % 2 == 0) ? factor[1] : factor[2]
value = ((i / (2**index)) % 2 == 0) ? factor[1] : factor[2]
case factor[0]
when 0 then try_species = value
when 1 then try_form = value

View File

@@ -92,10 +92,10 @@ class Battle
#=============================================================================
# Creating the battle class
#=============================================================================
def initialize(scene,p1,p2,player,opponent)
if p1.length==0
def initialize(scene, p1, p2, player, opponent)
if p1.length == 0
raise ArgumentError.new(_INTL("Party 1 has no Pokémon."))
elsif p2.length==0
elsif p2.length == 0
raise ArgumentError.new(_INTL("Party 2 has no Pokémon."))
end
@scene = scene
@@ -106,7 +106,7 @@ class Battle
ActiveSide.new] # Foe's side
@positions = [] # Battler positions
@battlers = []
@sideSizes = [1,1] # Single battle, 1v1
@sideSizes = [1, 1] # Single battle, 1v1
@backdrop = ""
@backdropBase = nil
@time = 0
@@ -194,15 +194,15 @@ class Battle
end
def singleBattle?
return pbSideSize(0)==1 && pbSideSize(1)==1
return pbSideSize(0) == 1 && pbSideSize(1) == 1
end
def pbSideSize(index)
return @sideSizes[index%2]
return @sideSizes[index % 2]
end
def maxBattlerIndex
return (pbSideSize(0)>pbSideSize(1)) ? (pbSideSize(0)-1)*2 : pbSideSize(1)*2-1
return (pbSideSize(0) > pbSideSize(1)) ? (pbSideSize(0) - 1) * 2 : pbSideSize(1) * 2 - 1
end
#=============================================================================
@@ -219,11 +219,11 @@ class Battle
return 0 if !trainer
case trainer.length
when 2
n = pbSideSize(idxBattler%2)
return [0,0,1][idxBattler/2] if n==3
return idxBattler/2 # Same as [0,1][idxBattler/2], i.e. 2 battler slots
n = pbSideSize(idxBattler % 2)
return [0, 0, 1][idxBattler / 2] if n == 3
return idxBattler / 2 # Same as [0,1][idxBattler/2], i.e. 2 battler slots
when 3
return idxBattler/2
return idxBattler / 2
end
return 0
end
@@ -234,10 +234,10 @@ class Battle
return (trainer.nil?) ? nil : trainer[idxTrainer]
end
def pbGetOwnerIndexFromPartyIndex(idxBattler,idxParty)
def pbGetOwnerIndexFromPartyIndex(idxBattler, idxParty)
ret = -1
pbPartyStarts(idxBattler).each_with_index do |start,i|
break if start>idxParty
pbPartyStarts(idxBattler).each_with_index do |start, i|
break if start > idxParty
ret = i
end
return ret
@@ -245,8 +245,8 @@ class Battle
# Only used for the purpose of an error message when one trainer tries to
# switch another trainer's Pokémon.
def pbGetOwnerFromPartyIndex(idxBattler,idxParty)
idxTrainer = pbGetOwnerIndexFromPartyIndex(idxBattler,idxParty)
def pbGetOwnerFromPartyIndex(idxBattler, idxParty)
idxTrainer = pbGetOwnerIndexFromPartyIndex(idxBattler, idxParty)
trainer = (opposes?(idxBattler)) ? @opponent : @player
return (trainer.nil?) ? nil : trainer[idxTrainer]
end
@@ -254,7 +254,7 @@ class Battle
def pbGetOwnerName(idxBattler)
idxTrainer = pbGetOwnerIndexFromBattlerIndex(idxBattler)
return @opponent[idxTrainer].full_name if opposes?(idxBattler) # Opponent
return @player[idxTrainer].full_name if idxTrainer>0 # Ally trainer
return @player[idxTrainer].full_name if idxTrainer > 0 # Ally trainer
return @player[idxTrainer].name # Player
end
@@ -266,24 +266,24 @@ class Battle
# Returns whether the battler in position idxBattler is owned by the same
# trainer that owns the Pokémon in party slot idxParty. This assumes that
# both the battler position and the party slot are from the same side.
def pbIsOwner?(idxBattler,idxParty)
def pbIsOwner?(idxBattler, idxParty)
idxTrainer1 = pbGetOwnerIndexFromBattlerIndex(idxBattler)
idxTrainer2 = pbGetOwnerIndexFromPartyIndex(idxBattler,idxParty)
return idxTrainer1==idxTrainer2
idxTrainer2 = pbGetOwnerIndexFromPartyIndex(idxBattler, idxParty)
return idxTrainer1 == idxTrainer2
end
def pbOwnedByPlayer?(idxBattler)
return false if opposes?(idxBattler)
return pbGetOwnerIndexFromBattlerIndex(idxBattler)==0
return pbGetOwnerIndexFromBattlerIndex(idxBattler) == 0
end
# Returns the number of Pokémon positions controlled by the given trainerIndex
# on the given side of battle.
def pbNumPositions(side,idxTrainer)
def pbNumPositions(side, idxTrainer)
ret = 0
for i in 0...pbSideSize(side)
t = pbGetOwnerIndexFromBattlerIndex(i*2+side)
next if t!=idxTrainer
t = pbGetOwnerIndexFromBattlerIndex(i * 2 + side)
next if t != idxTrainer
ret += 1
end
return ret
@@ -314,7 +314,7 @@ class Battle
partyOrders = pbPartyOrder(idxBattler)
idxStart, _idxEnd = pbTeamIndexRangeFromBattlerIndex(idxBattler)
ret = []
eachInTeamFromBattlerIndex(idxBattler) { |pkmn,i| ret[partyOrders[i]-idxStart] = pkmn }
eachInTeamFromBattlerIndex(idxBattler) { |pkmn, i| ret[partyOrders[i] - idxStart] = pkmn }
return ret
end
@@ -329,7 +329,7 @@ class Battle
party = pbParty(idxBattler)
inBattleIndices = allSameSideBattlers(idxBattler).map { |b| b.pokemonIndex }
count = 0
party.each_with_index do |pkmn,idxParty|
party.each_with_index do |pkmn, idxParty|
next if !pkmn || !pkmn.able?
next if inBattleIndices.include?(idxParty)
count += 1
@@ -338,7 +338,7 @@ class Battle
end
def pbAllFainted?(idxBattler = 0)
return pbAbleCount(idxBattler)==0
return pbAbleCount(idxBattler) == 0
end
def pbTeamAbleNonActiveCount(idxBattler = 0)
@@ -360,10 +360,10 @@ class Battle
ret = []
idxTeam = -1
nextStart = 0
party.each_with_index do |pkmn,i|
if i>=nextStart
party.each_with_index do |pkmn, i|
if i >= nextStart
idxTeam += 1
nextStart = (idxTeam<partyStarts.length-1) ? partyStarts[idxTeam+1] : party.length
nextStart = (idxTeam < partyStarts.length - 1) ? partyStarts[idxTeam + 1] : party.length
end
next if !pkmn || !pkmn.able?
ret[idxTeam] = 0 if !ret[idxTeam]
@@ -380,27 +380,27 @@ class Battle
partyStarts = pbPartyStarts(idxBattler)
idxTrainer = pbGetOwnerIndexFromBattlerIndex(idxBattler)
idxPartyStart = partyStarts[idxTrainer]
idxPartyEnd = (idxTrainer<partyStarts.length-1) ? partyStarts[idxTrainer+1] : pbParty(idxBattler).length
idxPartyEnd = (idxTrainer < partyStarts.length - 1) ? partyStarts[idxTrainer + 1] : pbParty(idxBattler).length
return idxPartyStart, idxPartyEnd
end
def pbTeamLengthFromBattlerIndex(idxBattler)
idxPartyStart, idxPartyEnd = pbTeamIndexRangeFromBattlerIndex(idxBattler)
return idxPartyEnd-idxPartyStart
return idxPartyEnd - idxPartyStart
end
def eachInTeamFromBattlerIndex(idxBattler)
party = pbParty(idxBattler)
idxPartyStart, idxPartyEnd = pbTeamIndexRangeFromBattlerIndex(idxBattler)
party.each_with_index { |pkmn,i| yield pkmn,i if pkmn && i>=idxPartyStart && i<idxPartyEnd }
party.each_with_index { |pkmn, i| yield pkmn, i if pkmn && i >= idxPartyStart && i < idxPartyEnd }
end
def eachInTeam(side,idxTrainer)
def eachInTeam(side, idxTrainer)
party = pbParty(side)
partyStarts = pbPartyStarts(side)
idxPartyStart = partyStarts[idxTrainer]
idxPartyEnd = (idxTrainer<partyStarts.length-1) ? partyStarts[idxTrainer+1] : party.length
party.each_with_index { |pkmn,i| yield pkmn,i if pkmn && i>=idxPartyStart && i<idxPartyEnd }
idxPartyEnd = (idxTrainer < partyStarts.length - 1) ? partyStarts[idxTrainer + 1] : party.length
party.each_with_index { |pkmn, i| yield pkmn, i if pkmn && i >= idxPartyStart && i < idxPartyEnd }
end
# Used for Illusion.
@@ -412,8 +412,8 @@ class Battle
partyOrders = pbPartyOrder(idxBattler)
idxPartyStart, idxPartyEnd = pbTeamIndexRangeFromBattlerIndex(idxBattler)
ret = -1
party.each_with_index do |pkmn,i|
next if i<idxPartyStart || i>=idxPartyEnd # Check the team only
party.each_with_index do |pkmn, i|
next if i < idxPartyStart || i >= idxPartyEnd # Check the team only
next if !pkmn || !pkmn.able? # Can't copy a non-fainted Pokémon or egg
ret = i if ret < 0 || partyOrders[i] > partyOrders[ret]
end
@@ -421,10 +421,10 @@ class Battle
end
# Used to calculate money gained/lost after winning/losing a battle.
def pbMaxLevelInTeam(side,idxTrainer)
def pbMaxLevelInTeam(side, idxTrainer)
ret = 1
eachInTeam(side,idxTrainer) do |pkmn,_i|
ret = pkmn.level if pkmn.level>ret
eachInTeam(side, idxTrainer) do |pkmn, _i|
ret = pkmn.level if pkmn.level > ret
end
return ret
end
@@ -481,7 +481,7 @@ class Battle
return nil
end
def pbCheckOpposingAbility(abil,idxBattler = 0,nearOnly = false)
def pbCheckOpposingAbility(abil, idxBattler = 0, nearOnly = false)
allOtherSideBattlers(idxBattler).each do |b|
next if nearOnly && !b.near?(idxBattler)
return b if b.hasActiveAbility?(abil)
@@ -503,31 +503,31 @@ class Battle
return [1]
when 2 # 1v2
return [0] if opposes?(idxBattler)
return [3,1]
return [3, 1]
when 3 # 1v3
return [0] if opposes?(idxBattler)
return [3,5,1]
return [3, 5, 1]
end
when 2
case pbSideSize(1)
when 1 # 2v1
return [0,2] if opposes?(idxBattler)
return [0, 2] if opposes?(idxBattler)
return [1]
when 2 # 2v2 double
return [[3,1],[2,0],[1,3],[0,2]][idxBattler]
return [[3, 1], [2, 0], [1, 3], [0, 2]][idxBattler]
when 3 # 2v3
return [[5,3,1],[2,0],[3,1,5]][idxBattler] if idxBattler<3
return [0,2]
return [[5, 3, 1], [2, 0], [3, 1, 5]][idxBattler] if idxBattler < 3
return [0, 2]
end
when 3
case pbSideSize(1)
when 1 # 3v1
return [2,0,4] if opposes?(idxBattler)
return [2, 0, 4] if opposes?(idxBattler)
return [1]
when 2 # 3v2
return [[3,1],[2,4,0],[3,1],[2,0,4],[1,3]][idxBattler]
return [[3, 1], [2, 4, 0], [3, 1], [2, 0, 4], [1, 3]][idxBattler]
when 3 # 3v3 triple
return [[5,3,1],[4,2,0],[3,5,1],[2,0,4],[1,3,5],[0,2,4]][idxBattler]
return [[5, 3, 1], [4, 2, 0], [3, 5, 1], [2, 0, 4], [1, 3, 5], [0, 2, 4]][idxBattler]
end
end
return [idxBattler]
@@ -536,30 +536,30 @@ class Battle
#=============================================================================
# Comparing the positions of two battlers
#=============================================================================
def opposes?(idxBattler1,idxBattler2 = 0)
def opposes?(idxBattler1, idxBattler2 = 0)
idxBattler1 = idxBattler1.index if idxBattler1.respond_to?("index")
idxBattler2 = idxBattler2.index if idxBattler2.respond_to?("index")
return (idxBattler1&1)!=(idxBattler2&1)
return (idxBattler1 & 1) != (idxBattler2 & 1)
end
def nearBattlers?(idxBattler1,idxBattler2)
return false if idxBattler1==idxBattler2
return true if pbSideSize(0)<=2 && pbSideSize(1)<=2
def nearBattlers?(idxBattler1, idxBattler2)
return false if idxBattler1 == idxBattler2
return true if pbSideSize(0) <= 2 && pbSideSize(1) <= 2
# Get all pairs of battler positions that are not close to each other
pairsArray = [[0,4],[1,5]] # Covers 3v1 and 1v3
pairsArray = [[0, 4], [1, 5]] # Covers 3v1 and 1v3
case pbSideSize(0)
when 3
case pbSideSize(1)
when 3 # 3v3 (triple)
pairsArray.push([0,1])
pairsArray.push([4,5])
pairsArray.push([0, 1])
pairsArray.push([4, 5])
when 2 # 3v2
pairsArray.push([0,1])
pairsArray.push([3,4])
pairsArray.push([0, 1])
pairsArray.push([3, 4])
end
when 2 # 2v3
pairsArray.push([0,1])
pairsArray.push([2,5])
pairsArray.push([0, 1])
pairsArray.push([2, 5])
end
# See if any pair matches the two battlers being assessed
pairsArray.each do |pair|
@@ -571,7 +571,7 @@ class Battle
#=============================================================================
# Altering a party or rearranging battlers
#=============================================================================
def pbRemoveFromParty(idxBattler,idxParty)
def pbRemoveFromParty(idxBattler, idxParty)
party = pbParty(idxBattler)
# Erase the Pokémon from the party
party[idxParty] = nil
@@ -579,27 +579,27 @@ class Battle
# in it (to avoid gaps)
partyOrders = pbPartyOrder(idxBattler)
partyStarts = pbPartyStarts(idxBattler)
idxTrainer = pbGetOwnerIndexFromPartyIndex(idxBattler,idxParty)
idxTrainer = pbGetOwnerIndexFromPartyIndex(idxBattler, idxParty)
idxPartyStart = partyStarts[idxTrainer]
idxPartyEnd = (idxTrainer<partyStarts.length-1) ? partyStarts[idxTrainer+1] : party.length
idxPartyEnd = (idxTrainer < partyStarts.length - 1) ? partyStarts[idxTrainer + 1] : party.length
origPartyPos = partyOrders[idxParty] # Position of erased Pokémon initially
partyOrders[idxParty] = idxPartyEnd # Put erased Pokémon last in the team
party.each_with_index do |_pkmn,i|
next if i<idxPartyStart || i>=idxPartyEnd # Only check the team
next if partyOrders[i]<origPartyPos # Appeared before erased Pokémon
party.each_with_index do |_pkmn, i|
next if i < idxPartyStart || i >= idxPartyEnd # Only check the team
next if partyOrders[i] < origPartyPos # Appeared before erased Pokémon
partyOrders[i] -= 1 # Appeared after erased Pokémon; bump it up by 1
end
end
def pbSwapBattlers(idxA,idxB)
def pbSwapBattlers(idxA, idxB)
return false if !@battlers[idxA] || !@battlers[idxB]
# Can't swap if battlers aren't owned by the same trainer
return false if opposes?(idxA,idxB)
return false if pbGetOwnerIndexFromBattlerIndex(idxA)!=pbGetOwnerIndexFromBattlerIndex(idxB)
return false if opposes?(idxA, idxB)
return false if pbGetOwnerIndexFromBattlerIndex(idxA) != pbGetOwnerIndexFromBattlerIndex(idxB)
@battlers[idxA], @battlers[idxB] = @battlers[idxB], @battlers[idxA]
@battlers[idxA].index, @battlers[idxB].index = @battlers[idxB].index, @battlers[idxA].index
@choices[idxA], @choices[idxB] = @choices[idxB], @choices[idxA]
@scene.pbSwapBattlerSprites(idxA,idxB)
@scene.pbSwapBattlerSprites(idxA, idxB)
# Swap the target of any battlers' effects that point at either of the
# swapped battlers, to ensure they still point at the correct target
# NOTE: LeechSeed is not swapped, because drained HP goes to whichever
@@ -619,8 +619,8 @@ class Battle
PBEffects::TrappingUser]
allBattlers.each do |b|
for i in effectsToSwap
next if b.effects[i]!=idxA && b.effects[i]!=idxB
b.effects[i] = (b.effects[i]==idxA) ? idxB : idxA
next if b.effects[i] != idxA && b.effects[i] != idxB
b.effects[i] = (b.effects[i] == idxA) ? idxB : idxA
end
end
return true
@@ -631,19 +631,19 @@ class Battle
#=============================================================================
# Returns the battler representing the Pokémon at index idxParty in its party,
# on the same side as a battler with battler index of idxBattlerOther.
def pbFindBattler(idxParty,idxBattlerOther = 0)
allSameSideBattlers(idxBattlerOther).each { |b| return b if b.pokemonIndex==idxParty }
def pbFindBattler(idxParty, idxBattlerOther = 0)
allSameSideBattlers(idxBattlerOther).each { |b| return b if b.pokemonIndex == idxParty }
return nil
end
# Only used for Wish, as the Wishing Pokémon will no longer be in battle.
def pbThisEx(idxBattler,idxParty)
def pbThisEx(idxBattler, idxParty)
party = pbParty(idxBattler)
if opposes?(idxBattler)
return _INTL("The opposing {1}",party[idxParty].name) if trainerBattle?
return _INTL("The wild {1}",party[idxParty].name)
return _INTL("The opposing {1}", party[idxParty].name) if trainerBattle?
return _INTL("The wild {1}", party[idxParty].name)
end
return _INTL("The ally {1}",party[idxParty].name) if !pbOwnedByPlayer?(idxBattler)
return _INTL("The ally {1}", party[idxParty].name) if !pbOwnedByPlayer?(idxBattler)
return party[idxParty].name
end
@@ -696,13 +696,13 @@ class Battle
end
# Used for causing weather by a move or by an ability.
def pbStartWeather(user,newWeather,fixedDuration = false,showAnim = true)
return if @field.weather==newWeather
def pbStartWeather(user, newWeather, fixedDuration = false, showAnim = true)
return if @field.weather == newWeather
@field.weather = newWeather
duration = (fixedDuration) ? 5 : -1
if duration>0 && user && user.itemActive?
if duration > 0 && user && user.itemActive?
duration = Battle::ItemEffects.triggerWeatherExtender(user.item,
@field.weather,duration,user,self)
@field.weather, duration, user, self)
end
@field.weatherDuration = duration
weather_data = GameData::BattleWeather.try_get(@field.weather)
@@ -743,11 +743,11 @@ class Battle
pbDisplay("The mysterious air current has dissipated!")
end
end
if @field.weather!=oldWeather
if @field.weather != oldWeather
# Check for form changes caused by the weather changing
allBattlers.each { |b| b.pbCheckFormOnWeatherChange }
# Start up the default weather
pbStartWeather(nil,@field.defaultWeather) if @field.defaultWeather != :None
pbStartWeather(nil, @field.defaultWeather) if @field.defaultWeather != :None
end
end
@@ -774,13 +774,13 @@ class Battle
@field.terrainDuration = -1
end
def pbStartTerrain(user,newTerrain,fixedDuration = true)
return if @field.terrain==newTerrain
def pbStartTerrain(user, newTerrain, fixedDuration = true)
return if @field.terrain == newTerrain
@field.terrain = newTerrain
duration = (fixedDuration) ? 5 : -1
if duration>0 && user && user.itemActive?
if duration > 0 && user && user.itemActive?
duration = Battle::ItemEffects.triggerTerrainExtender(user.item,
newTerrain,duration,user,self)
newTerrain, duration, user, self)
end
@field.terrainDuration = duration
terrain_data = GameData::BattleTerrain.try_get(@field.terrain)
@@ -804,35 +804,35 @@ class Battle
#=============================================================================
# Messages and animations
#=============================================================================
def pbDisplay(msg,&block)
@scene.pbDisplayMessage(msg,&block)
def pbDisplay(msg, &block)
@scene.pbDisplayMessage(msg, &block)
end
def pbDisplayBrief(msg)
@scene.pbDisplayMessage(msg,true)
@scene.pbDisplayMessage(msg, true)
end
def pbDisplayPaused(msg,&block)
@scene.pbDisplayPausedMessage(msg,&block)
def pbDisplayPaused(msg, &block)
@scene.pbDisplayPausedMessage(msg, &block)
end
def pbDisplayConfirm(msg)
return @scene.pbDisplayConfirmMessage(msg)
end
def pbShowCommands(msg,commands,canCancel = true)
@scene.pbShowCommands(msg,commands,canCancel)
def pbShowCommands(msg, commands, canCancel = true)
@scene.pbShowCommands(msg, commands, canCancel)
end
def pbAnimation(move,user,targets,hitNum = 0)
@scene.pbAnimation(move,user,targets,hitNum) if @showAnims
def pbAnimation(move, user, targets, hitNum = 0)
@scene.pbAnimation(move, user, targets, hitNum) if @showAnims
end
def pbCommonAnimation(name,user = nil,targets = nil)
@scene.pbCommonAnimation(name,user,targets) if @showAnims
def pbCommonAnimation(name, user = nil, targets = nil)
@scene.pbCommonAnimation(name, user, targets) if @showAnims
end
def pbShowAbilitySplash(battler,delay = false,logTrigger = true)
def pbShowAbilitySplash(battler, delay = false, logTrigger = true)
PBDebug.log("[Ability triggered] #{battler.pbThis}'s #{battler.abilityName}") if logTrigger
return if !Scene::USE_ABILITY_SPLASH
@scene.pbShowAbilitySplash(battler)

View File

@@ -22,18 +22,18 @@ class Battle
# trainer, it's possible that battlers will be unable to move close
# enough to hit each other if there are multiple trainers on each
# side.
if trainerBattle? && (@sideSizes[0]>2 || @sideSizes[1]>2) &&
@player.length>1 && @opponent.length>1
if trainerBattle? && (@sideSizes[0] > 2 || @sideSizes[1] > 2) &&
@player.length > 1 && @opponent.length > 1
raise _INTL("Can't have battles larger than 2v2 where both sides have multiple trainers")
end
# Find out how many Pokémon each trainer has
side1counts = pbAbleTeamCounts(0)
side2counts = pbAbleTeamCounts(1)
# Change the size of the battle depending on how many wild Pokémon there are
if wildBattle? && side2counts[0]!=@sideSizes[1]
if @sideSizes[0]==@sideSizes[1]
if wildBattle? && side2counts[0] != @sideSizes[1]
if @sideSizes[0] == @sideSizes[1]
# Even number of battlers per side, change both equally
@sideSizes = [side2counts[0],side2counts[0]]
@sideSizes = [side2counts[0], side2counts[0]]
else
# Uneven number of battlers per side, just change wild side's size
@sideSizes[1] = side2counts[0]
@@ -44,31 +44,31 @@ class Battle
loop do
needsChanging = false
for side in 0...2 # Each side in turn
next if side==1 && wildBattle? # Wild side's size already checked above
sideCounts = (side==0) ? side1counts : side2counts
next if side == 1 && wildBattle? # Wild side's size already checked above
sideCounts = (side == 0) ? side1counts : side2counts
requireds = []
# Find out how many Pokémon each trainer on side needs to have
for i in 0...@sideSizes[side]
idxTrainer = pbGetOwnerIndexFromBattlerIndex(i*2+side)
idxTrainer = pbGetOwnerIndexFromBattlerIndex(i * 2 + side)
requireds[idxTrainer] = 0 if requireds[idxTrainer].nil?
requireds[idxTrainer] += 1
end
# Compare the have values with the need values
if requireds.length>sideCounts.length
if requireds.length > sideCounts.length
raise _INTL("Error: def pbGetOwnerIndexFromBattlerIndex gives invalid owner index ({1} for battle type {2}v{3}, trainers {4}v{5})",
requireds.length-1,@sideSizes[0],@sideSizes[1],side1counts.length,side2counts.length)
requireds.length - 1, @sideSizes[0], @sideSizes[1], side1counts.length, side2counts.length)
end
sideCounts.each_with_index do |_count,i|
if !requireds[i] || requireds[i]==0
sideCounts.each_with_index do |_count, i|
if !requireds[i] || requireds[i] == 0
raise _INTL("Player-side trainer {1} has no battler position for their Pokémon to go (trying {2}v{3} battle)",
i+1,@sideSizes[0],@sideSizes[1]) if side==0
i + 1, @sideSizes[0], @sideSizes[1]) if side == 0
raise _INTL("Opposing trainer {1} has no battler position for their Pokémon to go (trying {2}v{3} battle)",
i+1,@sideSizes[0],@sideSizes[1]) if side==1
i + 1, @sideSizes[0], @sideSizes[1]) if side == 1
end
next if requireds[i]<=sideCounts[i] # Trainer has enough Pokémon to fill their positions
if requireds[i]==1
raise _INTL("Player-side trainer {1} has no able Pokémon",i+1) if side==0
raise _INTL("Opposing trainer {1} has no able Pokémon",i+1) if side==1
next if requireds[i] <= sideCounts[i] # Trainer has enough Pokémon to fill their positions
if requireds[i] == 1
raise _INTL("Player-side trainer {1} has no able Pokémon", i + 1) if side == 0
raise _INTL("Opposing trainer {1} has no able Pokémon", i + 1) if side == 1
end
# Not enough Pokémon, try lowering the number of battler positions
needsChanging = true
@@ -81,18 +81,18 @@ class Battle
if wildBattle?
PBDebug.log("#{@sideSizes[0]}v#{@sideSizes[1]} battle isn't possible " +
"(#{side1counts} player-side teams versus #{side2counts[0]} wild Pokémon)")
newSize = @sideSizes[0]-1
newSize = @sideSizes[0] - 1
else
PBDebug.log("#{@sideSizes[0]}v#{@sideSizes[1]} battle isn't possible " +
"(#{side1counts} player-side teams versus #{side2counts} opposing teams)")
newSize = @sideSizes.max-1
newSize = @sideSizes.max - 1
end
if newSize==0
if newSize == 0
raise _INTL("Couldn't lower either side's size any further, battle isn't possible")
end
for side in 0...2
next if side==1 && wildBattle? # Wild Pokémon's side size is fixed
next if @sideSizes[side]==1 || newSize>@sideSizes[side]
next if side == 1 && wildBattle? # Wild Pokémon's side size is fixed
next if @sideSizes[side] == 1 || newSize > @sideSizes[side]
@sideSizes[side] = newSize
end
PBDebug.log("Trying #{@sideSizes[0]}v#{@sideSizes[1]} battle instead")
@@ -102,52 +102,52 @@ class Battle
#=============================================================================
# Set up all battlers
#=============================================================================
def pbCreateBattler(idxBattler,pkmn,idxParty)
def pbCreateBattler(idxBattler, pkmn, idxParty)
if !@battlers[idxBattler].nil?
raise _INTL("Battler index {1} already exists",idxBattler)
raise _INTL("Battler index {1} already exists", idxBattler)
end
@battlers[idxBattler] = Battler.new(self,idxBattler)
@battlers[idxBattler] = Battler.new(self, idxBattler)
@positions[idxBattler] = ActivePosition.new
pbClearChoice(idxBattler)
@successStates[idxBattler] = SuccessState.new
@battlers[idxBattler].pbInitialize(pkmn,idxParty)
@battlers[idxBattler].pbInitialize(pkmn, idxParty)
end
def pbSetUpSides
ret = [[],[]]
ret = [[], []]
for side in 0...2
# Set up wild Pokémon
if side==1 && wildBattle?
pbParty(1).each_with_index do |pkmn,idxPkmn|
pbCreateBattler(2*idxPkmn+side,pkmn,idxPkmn)
if side == 1 && wildBattle?
pbParty(1).each_with_index do |pkmn, idxPkmn|
pbCreateBattler(2 * idxPkmn + side, pkmn, idxPkmn)
# Changes the Pokémon's form upon entering battle (if it should)
@peer.pbOnEnteringBattle(self, @battlers[2 * idxPkmn + side], pkmn, true)
pbSetSeen(@battlers[2*idxPkmn+side])
pbSetSeen(@battlers[2 * idxPkmn + side])
@usedInBattle[side][idxPkmn] = true
end
next
end
# Set up player's Pokémon and trainers' Pokémon
trainer = (side==0) ? @player : @opponent
trainer = (side == 0) ? @player : @opponent
requireds = []
# Find out how many Pokémon each trainer on side needs to have
for i in 0...@sideSizes[side]
idxTrainer = pbGetOwnerIndexFromBattlerIndex(i*2+side)
idxTrainer = pbGetOwnerIndexFromBattlerIndex(i * 2 + side)
requireds[idxTrainer] = 0 if requireds[idxTrainer].nil?
requireds[idxTrainer] += 1
end
# For each trainer in turn, find the needed number of Pokémon for them to
# send out, and initialize them
battlerNumber = 0
trainer.each_with_index do |_t,idxTrainer|
trainer.each_with_index do |_t, idxTrainer|
ret[side][idxTrainer] = []
eachInTeam(side,idxTrainer) do |pkmn,idxPkmn|
eachInTeam(side, idxTrainer) do |pkmn, idxPkmn|
next if !pkmn.able?
idxBattler = 2*battlerNumber+side
pbCreateBattler(idxBattler,pkmn,idxPkmn)
idxBattler = 2 * battlerNumber + side
pbCreateBattler(idxBattler, pkmn, idxPkmn)
ret[side][idxTrainer].push(idxBattler)
battlerNumber += 1
break if ret[side][idxTrainer].length>=requireds[idxTrainer]
break if ret[side][idxTrainer].length >= requireds[idxTrainer]
end
end
end
@@ -163,71 +163,71 @@ class Battle
foeParty = pbParty(1)
case foeParty.length
when 1
pbDisplayPaused(_INTL("Oh! A wild {1} appeared!",foeParty[0].name))
pbDisplayPaused(_INTL("Oh! A wild {1} appeared!", foeParty[0].name))
when 2
pbDisplayPaused(_INTL("Oh! A wild {1} and {2} appeared!",foeParty[0].name,
pbDisplayPaused(_INTL("Oh! A wild {1} and {2} appeared!", foeParty[0].name,
foeParty[1].name))
when 3
pbDisplayPaused(_INTL("Oh! A wild {1}, {2} and {3} appeared!",foeParty[0].name,
foeParty[1].name,foeParty[2].name))
pbDisplayPaused(_INTL("Oh! A wild {1}, {2} and {3} appeared!", foeParty[0].name,
foeParty[1].name, foeParty[2].name))
end
else # Trainer battle
case @opponent.length
when 1
pbDisplayPaused(_INTL("You are challenged by {1}!",@opponent[0].full_name))
pbDisplayPaused(_INTL("You are challenged by {1}!", @opponent[0].full_name))
when 2
pbDisplayPaused(_INTL("You are challenged by {1} and {2}!",@opponent[0].full_name,
pbDisplayPaused(_INTL("You are challenged by {1} and {2}!", @opponent[0].full_name,
@opponent[1].full_name))
when 3
pbDisplayPaused(_INTL("You are challenged by {1}, {2} and {3}!",
@opponent[0].full_name,@opponent[1].full_name,@opponent[2].full_name))
@opponent[0].full_name, @opponent[1].full_name, @opponent[2].full_name))
end
end
# Send out Pokémon (opposing trainers first)
for side in [1,0]
next if side==1 && wildBattle?
for side in [1, 0]
next if side == 1 && wildBattle?
msg = ""
toSendOut = []
trainers = (side==0) ? @player : @opponent
trainers = (side == 0) ? @player : @opponent
# Opposing trainers and partner trainers's messages about sending out Pokémon
trainers.each_with_index do |t,i|
next if side==0 && i==0 # The player's message is shown last
msg += "\r\n" if msg.length>0
trainers.each_with_index do |t, i|
next if side == 0 && i == 0 # The player's message is shown last
msg += "\r\n" if msg.length > 0
sent = sendOuts[side][i]
case sent.length
when 1
msg += _INTL("{1} sent out {2}!",t.full_name,@battlers[sent[0]].name)
msg += _INTL("{1} sent out {2}!", t.full_name, @battlers[sent[0]].name)
when 2
msg += _INTL("{1} sent out {2} and {3}!",t.full_name,
@battlers[sent[0]].name,@battlers[sent[1]].name)
msg += _INTL("{1} sent out {2} and {3}!", t.full_name,
@battlers[sent[0]].name, @battlers[sent[1]].name)
when 3
msg += _INTL("{1} sent out {2}, {3} and {4}!",t.full_name,
@battlers[sent[0]].name,@battlers[sent[1]].name,@battlers[sent[2]].name)
msg += _INTL("{1} sent out {2}, {3} and {4}!", t.full_name,
@battlers[sent[0]].name, @battlers[sent[1]].name, @battlers[sent[2]].name)
end
toSendOut.concat(sent)
end
# The player's message about sending out Pokémon
if side==0
msg += "\r\n" if msg.length>0
if side == 0
msg += "\r\n" if msg.length > 0
sent = sendOuts[side][0]
case sent.length
when 1
msg += _INTL("Go! {1}!",@battlers[sent[0]].name)
msg += _INTL("Go! {1}!", @battlers[sent[0]].name)
when 2
msg += _INTL("Go! {1} and {2}!",@battlers[sent[0]].name,@battlers[sent[1]].name)
msg += _INTL("Go! {1} and {2}!", @battlers[sent[0]].name, @battlers[sent[1]].name)
when 3
msg += _INTL("Go! {1}, {2} and {3}!",@battlers[sent[0]].name,
@battlers[sent[1]].name,@battlers[sent[2]].name)
msg += _INTL("Go! {1}, {2} and {3}!", @battlers[sent[0]].name,
@battlers[sent[1]].name, @battlers[sent[2]].name)
end
toSendOut.concat(sent)
end
pbDisplayBrief(msg) if msg.length>0
pbDisplayBrief(msg) if msg.length > 0
# The actual sending out of Pokémon
animSendOuts = []
toSendOut.each do |idxBattler|
animSendOuts.push([idxBattler,@battlers[idxBattler].pokemon])
animSendOuts.push([idxBattler, @battlers[idxBattler].pokemon])
end
pbSendOut(animSendOuts,true)
pbSendOut(animSendOuts, true)
end
end
@@ -238,11 +238,11 @@ class Battle
PBDebug.log("")
PBDebug.log("******************************************")
logMsg = "[Started battle] "
if @sideSizes[0]==1 && @sideSizes[1]==1
if @sideSizes[0] == 1 && @sideSizes[1] == 1
logMsg += "Single "
elsif @sideSizes[0]==2 && @sideSizes[1]==2
elsif @sideSizes[0] == 2 && @sideSizes[1] == 2
logMsg += "Double "
elsif @sideSizes[0]==3 && @sideSizes[1]==3
elsif @sideSizes[0] == 3 && @sideSizes[1] == 3
logMsg += "Triple "
else
logMsg += "#{@sideSizes[0]}v#{@sideSizes[1]} "
@@ -309,8 +309,8 @@ class Battle
@turnCount = 0
loop do # Now begin the battle loop
PBDebug.log("")
PBDebug.log("***Round #{@turnCount+1}***")
if @debug && @turnCount>=100
PBDebug.log("***Round #{@turnCount + 1}***")
if @debug && @turnCount >= 100
@decision = pbDecisionOnTime
PBDebug.log("")
PBDebug.log("***Undecided after 100 rounds, aborting***")
@@ -320,13 +320,13 @@ class Battle
PBDebug.log("")
# Command phase
PBDebug.logonerr { pbCommandPhase }
break if @decision>0
break if @decision > 0
# Attack phase
PBDebug.logonerr { pbAttackPhase }
break if @decision>0
break if @decision > 0
# End of round phase
PBDebug.logonerr { pbEndOfRoundPhase }
break if @decision>0
break if @decision > 0
@turnCount += 1
end
pbEndOfBattle
@@ -340,29 +340,29 @@ class Battle
# Money rewarded from opposing trainers
if trainerBattle?
tMoney = 0
@opponent.each_with_index do |t,i|
@opponent.each_with_index do |t, i|
tMoney += pbMaxLevelInTeam(1, i) * t.base_money
end
tMoney *= 2 if @field.effects[PBEffects::AmuletCoin]
tMoney *= 2 if @field.effects[PBEffects::HappyHour]
oldMoney = pbPlayer.money
pbPlayer.money += tMoney
moneyGained = pbPlayer.money-oldMoney
if moneyGained>0
moneyGained = pbPlayer.money - oldMoney
if moneyGained > 0
$stats.battle_money_gained += moneyGained
pbDisplayPaused(_INTL("You got ${1} for winning!",moneyGained.to_s_formatted))
pbDisplayPaused(_INTL("You got ${1} for winning!", moneyGained.to_s_formatted))
end
end
# Pick up money scattered by Pay Day
if @field.effects[PBEffects::PayDay]>0
if @field.effects[PBEffects::PayDay] > 0
@field.effects[PBEffects::PayDay] *= 2 if @field.effects[PBEffects::AmuletCoin]
@field.effects[PBEffects::PayDay] *= 2 if @field.effects[PBEffects::HappyHour]
oldMoney = pbPlayer.money
pbPlayer.money += @field.effects[PBEffects::PayDay]
moneyGained = pbPlayer.money-oldMoney
if moneyGained>0
moneyGained = pbPlayer.money - oldMoney
if moneyGained > 0
$stats.battle_money_gained += moneyGained
pbDisplayPaused(_INTL("You picked up ${1}!",moneyGained.to_s_formatted))
pbDisplayPaused(_INTL("You picked up ${1}!", moneyGained.to_s_formatted))
end
end
end
@@ -370,27 +370,27 @@ class Battle
def pbLoseMoney
return if !@internalBattle || !@moneyGain
return if $game_switches[Settings::NO_MONEY_LOSS]
maxLevel = pbMaxLevelInTeam(0,0) # Player's Pokémon only, not partner's
multiplier = [8,16,24,36,48,64,80,100,120]
maxLevel = pbMaxLevelInTeam(0, 0) # Player's Pokémon only, not partner's
multiplier = [8, 16, 24, 36, 48, 64, 80, 100, 120]
idxMultiplier = [pbPlayer.badge_count, multiplier.length - 1].min
tMoney = maxLevel*multiplier[idxMultiplier]
tMoney = pbPlayer.money if tMoney>pbPlayer.money
tMoney = maxLevel * multiplier[idxMultiplier]
tMoney = pbPlayer.money if tMoney > pbPlayer.money
oldMoney = pbPlayer.money
pbPlayer.money -= tMoney
moneyLost = oldMoney-pbPlayer.money
if moneyLost>0
moneyLost = oldMoney - pbPlayer.money
if moneyLost > 0
$stats.battle_money_lost += moneyLost
if trainerBattle?
pbDisplayPaused(_INTL("You gave ${1} to the winner...",moneyLost.to_s_formatted))
pbDisplayPaused(_INTL("You gave ${1} to the winner...", moneyLost.to_s_formatted))
else
pbDisplayPaused(_INTL("You panicked and dropped ${1}...",moneyLost.to_s_formatted))
pbDisplayPaused(_INTL("You panicked and dropped ${1}...", moneyLost.to_s_formatted))
end
end
end
def pbEndOfBattle
oldDecision = @decision
@decision = 4 if @decision==1 && wildBattle? && @caughtPokemon.length>0
@decision = 4 if @decision == 1 && wildBattle? && @caughtPokemon.length > 0
case oldDecision
##### WIN #####
when 1
@@ -400,52 +400,52 @@ class Battle
@scene.pbTrainerBattleSuccess
case @opponent.length
when 1
pbDisplayPaused(_INTL("You defeated {1}!",@opponent[0].full_name))
pbDisplayPaused(_INTL("You defeated {1}!", @opponent[0].full_name))
when 2
pbDisplayPaused(_INTL("You defeated {1} and {2}!",@opponent[0].full_name,
pbDisplayPaused(_INTL("You defeated {1} and {2}!", @opponent[0].full_name,
@opponent[1].full_name))
when 3
pbDisplayPaused(_INTL("You defeated {1}, {2} and {3}!",@opponent[0].full_name,
@opponent[1].full_name,@opponent[2].full_name))
pbDisplayPaused(_INTL("You defeated {1}, {2} and {3}!", @opponent[0].full_name,
@opponent[1].full_name, @opponent[2].full_name))
end
@opponent.each_with_index do |_t,i|
@opponent.each_with_index do |_t, i|
@scene.pbShowOpponent(i)
msg = (@endSpeeches[i] && @endSpeeches[i]!="") ? @endSpeeches[i] : "..."
pbDisplayPaused(msg.gsub(/\\[Pp][Nn]/,pbPlayer.name))
msg = (@endSpeeches[i] && @endSpeeches[i] != "") ? @endSpeeches[i] : "..."
pbDisplayPaused(msg.gsub(/\\[Pp][Nn]/, pbPlayer.name))
end
end
# Gain money from winning a trainer battle, and from Pay Day
pbGainMoney if @decision!=4
pbGainMoney if @decision != 4
# Hide remaining trainer
@scene.pbShowOpponent(@opponent.length) if trainerBattle? && @caughtPokemon.length>0
@scene.pbShowOpponent(@opponent.length) if trainerBattle? && @caughtPokemon.length > 0
##### LOSE, DRAW #####
when 2, 5
PBDebug.log("")
PBDebug.log("***Player lost***") if @decision==2
PBDebug.log("***Player drew with opponent***") if @decision==5
PBDebug.log("***Player lost***") if @decision == 2
PBDebug.log("***Player drew with opponent***") if @decision == 5
if @internalBattle
pbDisplayPaused(_INTL("You have no more Pokémon that can fight!"))
if trainerBattle?
case @opponent.length
when 1
pbDisplayPaused(_INTL("You lost against {1}!",@opponent[0].full_name))
pbDisplayPaused(_INTL("You lost against {1}!", @opponent[0].full_name))
when 2
pbDisplayPaused(_INTL("You lost against {1} and {2}!",
@opponent[0].full_name,@opponent[1].full_name))
@opponent[0].full_name, @opponent[1].full_name))
when 3
pbDisplayPaused(_INTL("You lost against {1}, {2} and {3}!",
@opponent[0].full_name,@opponent[1].full_name,@opponent[2].full_name))
@opponent[0].full_name, @opponent[1].full_name, @opponent[2].full_name))
end
end
# Lose money from losing a battle
pbLoseMoney
pbDisplayPaused(_INTL("You blacked out!")) if !@canLose
elsif @decision==2
elsif @decision == 2
if @opponent
@opponent.each_with_index do |_t,i|
@opponent.each_with_index do |_t, i|
@scene.pbShowOpponent(i)
msg = (@endSpeechesWin[i] && @endSpeechesWin[i]!="") ? @endSpeechesWin[i] : "..."
pbDisplayPaused(msg.gsub(/\\[Pp][Nn]/,pbPlayer.name))
msg = (@endSpeechesWin[i] && @endSpeechesWin[i] != "") ? @endSpeechesWin[i] : "..."
pbDisplayPaused(msg.gsub(/\\[Pp][Nn]/, pbPlayer.name))
end
end
end
@@ -456,12 +456,12 @@ class Battle
# Register captured Pokémon in the Pokédex, and store them
pbRecordAndStoreCaughtPokemon
# Collect Pay Day money in a wild battle that ended in a capture
pbGainMoney if @decision==4
pbGainMoney if @decision == 4
# Pass on Pokérus within the party
if @internalBattle
infected = []
$player.party.each_with_index do |pkmn,i|
infected.push(i) if pkmn.pokerusStage==1
$player.party.each_with_index do |pkmn, i|
infected.push(i) if pkmn.pokerusStage == 1
end
infected.each do |idxParty|
strain = $player.party[idxParty].pokerusStrain
@@ -480,9 +480,9 @@ class Battle
pbCancelChoice(b.index) # Restore unused items to Bag
Battle::AbilityEffects.triggerOnSwitchOut(b.ability, b, true) if b.abilityActive?
end
pbParty(0).each_with_index do |pkmn,i|
pbParty(0).each_with_index do |pkmn, i|
next if !pkmn
@peer.pbOnLeavingBattle(self,pkmn,@usedInBattle[0][i],true) # Reset form
@peer.pbOnLeavingBattle(self, pkmn, @usedInBattle[0][i], true) # Reset form
pkmn.item = @initialItems[0][i]
end
return @decision
@@ -491,11 +491,11 @@ class Battle
#=============================================================================
# Judging
#=============================================================================
def pbJudgeCheckpoint(user,move = nil); end
def pbJudgeCheckpoint(user, move = nil); end
def pbDecisionOnTime
counts = [0,0]
hpTotals = [0,0]
counts = [0, 0]
hpTotals = [0, 0]
for side in 0...2
pbParty(side).each do |pkmn|
next if !pkmn || !pkmn.able?
@@ -503,29 +503,29 @@ class Battle
hpTotals[side] += pkmn.hp
end
end
return 1 if counts[0]>counts[1] # Win (player has more able Pokémon)
return 2 if counts[0]<counts[1] # Loss (foe has more able Pokémon)
return 1 if hpTotals[0]>hpTotals[1] # Win (player has more HP in total)
return 2 if hpTotals[0]<hpTotals[1] # Loss (foe has more HP in total)
return 1 if counts[0] > counts[1] # Win (player has more able Pokémon)
return 2 if counts[0] < counts[1] # Loss (foe has more able Pokémon)
return 1 if hpTotals[0] > hpTotals[1] # Win (player has more HP in total)
return 2 if hpTotals[0] < hpTotals[1] # Loss (foe has more HP in total)
return 5 # Draw
end
# Unused
def pbDecisionOnTime2
counts = [0,0]
hpTotals = [0,0]
counts = [0, 0]
hpTotals = [0, 0]
for side in 0...2
pbParty(side).each do |pkmn|
next if !pkmn || !pkmn.able?
counts[side] += 1
hpTotals[side] += 100*pkmn.hp/pkmn.totalhp
hpTotals[side] += 100 * pkmn.hp / pkmn.totalhp
end
hpTotals[side] /= counts[side] if counts[side]>1
hpTotals[side] /= counts[side] if counts[side] > 1
end
return 1 if counts[0]>counts[1] # Win (player has more able Pokémon)
return 2 if counts[0]<counts[1] # Loss (foe has more able Pokémon)
return 1 if hpTotals[0]>hpTotals[1] # Win (player has a bigger average HP %)
return 2 if hpTotals[0]<hpTotals[1] # Loss (foe has a bigger average HP %)
return 1 if counts[0] > counts[1] # Win (player has more able Pokémon)
return 2 if counts[0] < counts[1] # Loss (foe has more able Pokémon)
return 1 if hpTotals[0] > hpTotals[1] # Win (player has a bigger average HP %)
return 2 if hpTotals[0] < hpTotals[1] # Loss (foe has a bigger average HP %)
return 5 # Draw
end

View File

@@ -12,42 +12,42 @@ class Battle
p1 = pbParty(0)
@battlers.each do |b|
next unless b && b.opposes? # Can only gain Exp from fainted foes
next if b.participants.length==0
next if b.participants.length == 0
next unless b.fainted? || b.captured
# Count the number of participants
numPartic = 0
b.participants.each do |partic|
next unless p1[partic] && p1[partic].able? && pbIsOwner?(0,partic)
next unless p1[partic] && p1[partic].able? && pbIsOwner?(0, partic)
numPartic += 1
end
# Find which Pokémon have an Exp Share
expShare = []
if !expAll
eachInTeam(0,0) do |pkmn,i|
eachInTeam(0, 0) do |pkmn, i|
next if !pkmn.able?
next if !pkmn.hasItem?(:EXPSHARE) && GameData::Item.try_get(@initialItems[0][i]) != :EXPSHARE
expShare.push(i)
end
end
# Calculate EV and Exp gains for the participants
if numPartic>0 || expShare.length>0 || expAll
if numPartic > 0 || expShare.length > 0 || expAll
# Gain EVs and Exp for participants
eachInTeam(0,0) do |pkmn,i|
eachInTeam(0, 0) do |pkmn, i|
next if !pkmn.able?
next unless b.participants.include?(i) || expShare.include?(i)
pbGainEVsOne(i,b)
pbGainExpOne(i,b,numPartic,expShare,expAll)
pbGainEVsOne(i, b)
pbGainExpOne(i, b, numPartic, expShare, expAll)
end
# Gain EVs and Exp for all other Pokémon because of Exp All
if expAll
showMessage = true
eachInTeam(0,0) do |pkmn,i|
eachInTeam(0, 0) do |pkmn, i|
next if !pkmn.able?
next if b.participants.include?(i) || expShare.include?(i)
pbDisplayPaused(_INTL("Your party Pokémon in waiting also got Exp. Points!")) if showMessage
showMessage = false
pbGainEVsOne(i,b)
pbGainExpOne(i,b,numPartic,expShare,expAll,false)
pbGainEVsOne(i, b)
pbGainExpOne(i, b, numPartic, expShare, expAll, false)
end
end
end
@@ -56,7 +56,7 @@ class Battle
end
end
def pbGainEVsOne(idxParty,defeatedBattler)
def pbGainEVsOne(idxParty, defeatedBattler)
pkmn = pbParty(0)[idxParty] # The Pokémon gaining EVs from defeatedBattler
evYield = defeatedBattler.pokemon.evYield
# Num of effort points pkmn already has
@@ -67,7 +67,7 @@ class Battle
Battle::ItemEffects.triggerEVGainModifier(@initialItems[0][idxParty], pkmn, evYield)
end
# Double EV gain because of Pokérus
if pkmn.pokerusStage>=1 # Infected or cured
if pkmn.pokerusStage >= 1 # Infected or cured
evYield.each_key { |stat| evYield[stat] *= 2 }
end
# Gain EVs for each stat in turn
@@ -89,11 +89,11 @@ class Battle
end
end
def pbGainExpOne(idxParty,defeatedBattler,numPartic,expShare,expAll,showMessages = true)
def pbGainExpOne(idxParty, defeatedBattler, numPartic, expShare, expAll, showMessages = true)
pkmn = pbParty(0)[idxParty] # The Pokémon gaining Exp from defeatedBattler
growth_rate = pkmn.growth_rate
# Don't bother calculating if gainer is already at max Exp
if pkmn.exp>=growth_rate.maximum_exp
if pkmn.exp >= growth_rate.maximum_exp
pkmn.calc_stats # To ensure new EVs still have an effect
return
end
@@ -102,30 +102,30 @@ class Battle
level = defeatedBattler.level
# Main Exp calculation
exp = 0
a = level*defeatedBattler.pokemon.base_exp
if expShare.length>0 && (isPartic || hasExpShare)
if numPartic==0 # No participants, all Exp goes to Exp Share holders
a = level * defeatedBattler.pokemon.base_exp
if expShare.length > 0 && (isPartic || hasExpShare)
if numPartic == 0 # No participants, all Exp goes to Exp Share holders
exp = a / (Settings::SPLIT_EXP_BETWEEN_GAINERS ? expShare.length : 1)
elsif Settings::SPLIT_EXP_BETWEEN_GAINERS # Gain from participating and/or Exp Share
exp = a/(2*numPartic) if isPartic
exp += a/(2*expShare.length) if hasExpShare
exp = a / (2 * numPartic) if isPartic
exp += a / (2 * expShare.length) if hasExpShare
else # Gain from participating and/or Exp Share (Exp not split)
exp = (isPartic) ? a : a/2
exp = (isPartic) ? a : a / 2
end
elsif isPartic # Participated in battle, no Exp Shares held by anyone
exp = a / (Settings::SPLIT_EXP_BETWEEN_GAINERS ? numPartic : 1)
elsif expAll # Didn't participate in battle, gaining Exp due to Exp All
# NOTE: Exp All works like the Exp Share from Gen 6+, not like the Exp All
# from Gen 1, i.e. Exp isn't split between all Pokémon gaining it.
exp = a/2
exp = a / 2
end
return if exp<=0
return if exp <= 0
# Pokémon gain more Exp from trainer battles
exp = (exp*1.5).floor if trainerBattle?
exp = (exp * 1.5).floor if trainerBattle?
# Scale the gained Exp based on the gainer's level (or not)
if Settings::SCALED_EXP_FORMULA
exp /= 5
levelAdjust = (2*level+10.0)/(pkmn.level+level+10.0)
levelAdjust = (2 * level + 10.0) / (pkmn.level + level + 10.0)
levelAdjust = levelAdjust**5
levelAdjust = Math.sqrt(levelAdjust)
exp *= levelAdjust
@@ -139,19 +139,19 @@ class Battle
(pkmn.owner.language != 0 && pkmn.owner.language != pbPlayer.language))
if isOutsider
if pkmn.owner.language != 0 && pkmn.owner.language != pbPlayer.language
exp = (exp*1.7).floor
exp = (exp * 1.7).floor
else
exp = (exp*1.5).floor
exp = (exp * 1.5).floor
end
end
# Exp. Charm increases Exp gained
exp = exp * 3 / 2 if $bag.has?(:EXPCHARM)
# Modify Exp gain based on pkmn's held item
i = Battle::ItemEffects.triggerExpGainModifier(pkmn.item, pkmn, exp)
if i<0
if i < 0
i = Battle::ItemEffects.triggerExpGainModifier(@initialItems[0][idxParty], pkmn, exp)
end
exp = i if i>=0
exp = i if i >= 0
# Boost Exp gained with high affection
if Settings::AFFECTION_EFFECTS && @internalBattle && pkmn.affection_level >= 4 && !pkmn.mega?
exp = exp * 6 / 5
@@ -159,22 +159,22 @@ class Battle
end
# Make sure Exp doesn't exceed the maximum
expFinal = growth_rate.add_exp(pkmn.exp, exp)
expGained = expFinal-pkmn.exp
return if expGained<=0
expGained = expFinal - pkmn.exp
return if expGained <= 0
# "Exp gained" message
if showMessages
if isOutsider
pbDisplayPaused(_INTL("{1} got a boosted {2} Exp. Points!",pkmn.name,expGained))
pbDisplayPaused(_INTL("{1} got a boosted {2} Exp. Points!", pkmn.name, expGained))
else
pbDisplayPaused(_INTL("{1} got {2} Exp. Points!",pkmn.name,expGained))
pbDisplayPaused(_INTL("{1} got {2} Exp. Points!", pkmn.name, expGained))
end
end
curLevel = pkmn.level
newLevel = growth_rate.level_from_exp(expFinal)
if newLevel<curLevel
if newLevel < curLevel
debugInfo = "Levels: #{curLevel}->#{newLevel} | Exp: #{pkmn.exp}->#{expFinal} | gain: #{expGained}"
raise _INTL("{1}'s new level is less than its\r\ncurrent level, which shouldn't happen.\r\n[Debug: {2}]",
pkmn.name,debugInfo)
pkmn.name, debugInfo)
end
# Give Exp
if pkmn.shadowPokemon?
@@ -191,12 +191,12 @@ class Battle
# EXP Bar animation
levelMinExp = growth_rate.minimum_exp_for_level(curLevel)
levelMaxExp = growth_rate.minimum_exp_for_level(curLevel + 1)
tempExp2 = (levelMaxExp<expFinal) ? levelMaxExp : expFinal
tempExp2 = (levelMaxExp < expFinal) ? levelMaxExp : expFinal
pkmn.exp = tempExp2
@scene.pbEXPBar(battler,levelMinExp,levelMaxExp,tempExp1,tempExp2)
@scene.pbEXPBar(battler, levelMinExp, levelMaxExp, tempExp1, tempExp2)
tempExp1 = tempExp2
curLevel += 1
if curLevel>newLevel
if curLevel > newLevel
# Gained all the Exp now, end the animation
pkmn.calc_stats
battler.pbUpdate(false) if battler
@@ -204,7 +204,7 @@ class Battle
break
end
# Levelled up
pbCommonAnimation("LevelUp",battler) if battler
pbCommonAnimation("LevelUp", battler) if battler
oldTotalHP = pkmn.totalhp
oldAttack = pkmn.attack
oldDefense = pkmn.defense
@@ -217,19 +217,19 @@ class Battle
pkmn.calc_stats
battler.pbUpdate(false) if battler
@scene.pbRefreshOne(battler.index) if battler
pbDisplayPaused(_INTL("{1} grew to Lv. {2}!",pkmn.name,curLevel))
@scene.pbLevelUp(pkmn,battler,oldTotalHP,oldAttack,oldDefense,
oldSpAtk,oldSpDef,oldSpeed)
pbDisplayPaused(_INTL("{1} grew to Lv. {2}!", pkmn.name, curLevel))
@scene.pbLevelUp(pkmn, battler, oldTotalHP, oldAttack, oldDefense,
oldSpAtk, oldSpDef, oldSpeed)
# Learn all moves learned at this level
moveList = pkmn.getMoveList
moveList.each { |m| pbLearnMove(idxParty,m[1]) if m[0]==curLevel }
moveList.each { |m| pbLearnMove(idxParty, m[1]) if m[0] == curLevel }
end
end
#=============================================================================
# Learning a move
#=============================================================================
def pbLearnMove(idxParty,newMove)
def pbLearnMove(idxParty, newMove)
pkmn = pbParty(0)[idxParty]
return if !pkmn
pkmnName = pkmn.name
@@ -240,7 +240,7 @@ class Battle
# Pokémon has space for the new move; just learn it
if pkmn.numMoves < Pokemon::MAX_MOVES
pkmn.learn_move(newMove)
pbDisplay(_INTL("{1} learned {2}!",pkmnName,moveName)) { pbSEPlay("Pkmn move learnt") }
pbDisplay(_INTL("{1} learned {2}!", pkmnName, moveName)) { pbSEPlay("Pkmn move learnt") }
if battler
battler.moves.push(Move.from_pokemon_move(self, pkmn.moves.last))
battler.pbCheckFormOnMovesetChange
@@ -252,18 +252,18 @@ class Battle
pkmnName, moveName, pkmn.numMoves.to_word))
if pbDisplayConfirm(_INTL("Should {1} forget a move to learn {2}?", pkmnName, moveName))
loop do
forgetMove = @scene.pbForgetMove(pkmn,newMove)
if forgetMove>=0
forgetMove = @scene.pbForgetMove(pkmn, newMove)
if forgetMove >= 0
oldMoveName = pkmn.moves[forgetMove].name
pkmn.moves[forgetMove] = Pokemon::Move.new(newMove) # Replaces current/total PP
battler.moves[forgetMove] = Move.from_pokemon_move(self, pkmn.moves[forgetMove]) if battler
pbDisplayPaused(_INTL("1, 2, and... ... ... Ta-da!")) { pbSEPlay("Battle ball drop") }
pbDisplayPaused(_INTL("{1} forgot how to use {2}. And...",pkmnName,oldMoveName))
pbDisplay(_INTL("{1} learned {2}!",pkmnName,moveName)) { pbSEPlay("Pkmn move learnt") }
pbDisplayPaused(_INTL("{1} forgot how to use {2}. And...", pkmnName, oldMoveName))
pbDisplay(_INTL("{1} learned {2}!", pkmnName, moveName)) { pbSEPlay("Pkmn move learnt") }
battler.pbCheckFormOnMovesetChange if battler
break
elsif pbDisplayConfirm(_INTL("Give up on learning {1}?",moveName))
pbDisplay(_INTL("{1} did not learn {2}.",pkmnName,moveName))
elsif pbDisplayConfirm(_INTL("Give up on learning {1}?", moveName))
pbDisplay(_INTL("{1} did not learn {2}.", pkmnName, moveName))
break
end
end

View File

@@ -2,30 +2,30 @@ class Battle
#=============================================================================
# Choosing a move/target
#=============================================================================
def pbCanChooseMove?(idxBattler,idxMove,showMessages,sleepTalk = false)
def pbCanChooseMove?(idxBattler, idxMove, showMessages, sleepTalk = false)
battler = @battlers[idxBattler]
move = battler.moves[idxMove]
return false unless move
if move.pp==0 && move.total_pp>0 && !sleepTalk
if move.pp == 0 && move.total_pp > 0 && !sleepTalk
pbDisplayPaused(_INTL("There's no PP left for this move!")) if showMessages
return false
end
if battler.effects[PBEffects::Encore]>0
if battler.effects[PBEffects::Encore] > 0
idxEncoredMove = battler.pbEncoredMoveIndex
return false if idxEncoredMove>=0 && idxMove!=idxEncoredMove
return false if idxEncoredMove >= 0 && idxMove != idxEncoredMove
end
return battler.pbCanChooseMove?(move,true,showMessages,sleepTalk)
return battler.pbCanChooseMove?(move, true, showMessages, sleepTalk)
end
def pbCanChooseAnyMove?(idxBattler,sleepTalk = false)
def pbCanChooseAnyMove?(idxBattler, sleepTalk = false)
battler = @battlers[idxBattler]
battler.eachMoveWithIndex do |m,i|
next if m.pp==0 && m.total_pp>0 && !sleepTalk
if battler.effects[PBEffects::Encore]>0
battler.eachMoveWithIndex do |m, i|
next if m.pp == 0 && m.total_pp > 0 && !sleepTalk
if battler.effects[PBEffects::Encore] > 0
idxEncoredMove = battler.pbEncoredMoveIndex
next if idxEncoredMove>=0 && i!=idxEncoredMove
next if idxEncoredMove >= 0 && i != idxEncoredMove
end
next if !battler.pbCanChooseMove?(m,true,false,sleepTalk)
next if !battler.pbCanChooseMove?(m, true, false, sleepTalk)
return true
end
return false
@@ -33,7 +33,7 @@ class Battle
# Called when the Pokémon is Encored, or if it can't use any of its moves.
# Makes the Pokémon use the Encored move (if Encored), or Struggle.
def pbAutoChooseMove(idxBattler,showMessages = true)
def pbAutoChooseMove(idxBattler, showMessages = true)
battler = @battlers[idxBattler]
if battler.fainted?
pbClearChoice(idxBattler)
@@ -41,7 +41,7 @@ class Battle
end
# Encore
idxEncoredMove = battler.pbEncoredMoveIndex
if idxEncoredMove>=0 && pbCanChooseMove?(idxBattler,idxEncoredMove,false)
if idxEncoredMove >= 0 && pbCanChooseMove?(idxBattler, idxEncoredMove, false)
encoreMove = battler.moves[idxEncoredMove]
@choices[idxBattler][0] = :UseMove # "Use move"
@choices[idxBattler][1] = idxEncoredMove # Index of move to be used
@@ -50,15 +50,15 @@ class Battle
return true if singleBattle?
if pbOwnedByPlayer?(idxBattler)
if showMessages
pbDisplayPaused(_INTL("{1} has to use {2}!",battler.name,encoreMove.name))
pbDisplayPaused(_INTL("{1} has to use {2}!", battler.name, encoreMove.name))
end
return pbChooseTarget(battler,encoreMove)
return pbChooseTarget(battler, encoreMove)
end
return true
end
# Struggle
if pbOwnedByPlayer?(idxBattler) && showMessages
pbDisplayPaused(_INTL("{1} has no moves left!",battler.name))
pbDisplayPaused(_INTL("{1} has no moves left!", battler.name))
end
@choices[idxBattler][0] = :UseMove # "Use move"
@choices[idxBattler][1] = -1 # Index of move to be used
@@ -67,10 +67,10 @@ class Battle
return true
end
def pbRegisterMove(idxBattler,idxMove,showMessages = true)
def pbRegisterMove(idxBattler, idxMove, showMessages = true)
battler = @battlers[idxBattler]
move = battler.moves[idxMove]
return false if !pbCanChooseMove?(idxBattler,idxMove,showMessages)
return false if !pbCanChooseMove?(idxBattler, idxMove, showMessages)
@choices[idxBattler][0] = :UseMove # "Use move"
@choices[idxBattler][1] = idxMove # Index of move to be used
@choices[idxBattler][2] = move # Battle::Move object
@@ -78,54 +78,54 @@ class Battle
return true
end
def pbChoseMove?(idxBattler,moveID)
def pbChoseMove?(idxBattler, moveID)
return false if !@battlers[idxBattler] || @battlers[idxBattler].fainted?
if @choices[idxBattler][0]==:UseMove && @choices[idxBattler][1]
if @choices[idxBattler][0] == :UseMove && @choices[idxBattler][1]
return @choices[idxBattler][2].id == moveID
end
return false
end
def pbChoseMoveFunctionCode?(idxBattler,code)
def pbChoseMoveFunctionCode?(idxBattler, code)
return false if @battlers[idxBattler].fainted?
if @choices[idxBattler][0]==:UseMove && @choices[idxBattler][1]
if @choices[idxBattler][0] == :UseMove && @choices[idxBattler][1]
return @choices[idxBattler][2].function == code
end
return false
end
def pbRegisterTarget(idxBattler,idxTarget)
def pbRegisterTarget(idxBattler, idxTarget)
@choices[idxBattler][3] = idxTarget # Set target of move
end
# Returns whether the idxTarget will be targeted by a move with target_data
# used by a battler in idxUser.
def pbMoveCanTarget?(idxUser,idxTarget,target_data)
def pbMoveCanTarget?(idxUser, idxTarget, target_data)
return false if target_data.num_targets == 0
case target_data.id
when :NearAlly
return false if opposes?(idxUser,idxTarget)
return false if !nearBattlers?(idxUser,idxTarget)
return false if opposes?(idxUser, idxTarget)
return false if !nearBattlers?(idxUser, idxTarget)
when :UserOrNearAlly
return true if idxUser==idxTarget
return false if opposes?(idxUser,idxTarget)
return false if !nearBattlers?(idxUser,idxTarget)
return true if idxUser == idxTarget
return false if opposes?(idxUser, idxTarget)
return false if !nearBattlers?(idxUser, idxTarget)
when :AllAllies
return false if idxUser == idxTarget
return false if opposes?(idxUser, idxTarget)
when :UserAndAllies
return false if opposes?(idxUser,idxTarget)
return false if opposes?(idxUser, idxTarget)
when :NearFoe, :RandomNearFoe, :AllNearFoes
return false if !opposes?(idxUser,idxTarget)
return false if !nearBattlers?(idxUser,idxTarget)
return false if !opposes?(idxUser, idxTarget)
return false if !nearBattlers?(idxUser, idxTarget)
when :Foe
return false if !opposes?(idxUser,idxTarget)
return false if !opposes?(idxUser, idxTarget)
when :AllFoes
return false if !opposes?(idxUser,idxTarget)
return false if !opposes?(idxUser, idxTarget)
when :NearOther, :AllNearOthers
return false if !nearBattlers?(idxUser,idxTarget)
return false if !nearBattlers?(idxUser, idxTarget)
when :Other
return false if idxUser==idxTarget
return false if idxUser == idxTarget
end
return true
end
@@ -133,14 +133,14 @@ class Battle
#=============================================================================
# Turn order calculation (priority)
#=============================================================================
def pbCalculatePriority(fullCalc = false,indexArray = nil)
def pbCalculatePriority(fullCalc = false, indexArray = nil)
needRearranging = false
if fullCalc
@priorityTrickRoom = (@field.effects[PBEffects::TrickRoom]>0)
@priorityTrickRoom = (@field.effects[PBEffects::TrickRoom] > 0)
# Recalculate everything from scratch
randomOrder = Array.new(maxBattlerIndex+1) { |i| i }
(randomOrder.length-1).times do |i| # Can't use shuffle! here
r = i+pbRandom(randomOrder.length-i)
randomOrder = Array.new(maxBattlerIndex + 1) { |i| i }
(randomOrder.length - 1).times do |i| # Can't use shuffle! here
r = i + pbRandom(randomOrder.length - i)
randomOrder[i], randomOrder[r] = randomOrder[r], randomOrder[i]
end
@priority.clear
@@ -148,10 +148,10 @@ class Battle
b = @battlers[i]
next if !b
# [battler, speed, sub-priority, priority, tie-breaker order]
bArray = [b,b.pbSpeed,0,0,randomOrder[i]]
if @choices[b.index][0]==:UseMove || @choices[b.index][0]==:Shift
bArray = [b, b.pbSpeed, 0, 0, randomOrder[i]]
if @choices[b.index][0] == :UseMove || @choices[b.index][0] == :Shift
# Calculate move's priority
if @choices[b.index][0]==:UseMove
if @choices[b.index][0] == :UseMove
move = @choices[b.index][2]
pri = move.pbPriority(b)
if b.abilityActive?
@@ -168,7 +168,7 @@ class Battle
# Abilities (Stall)
if b.abilityActive?
newSubPri = Battle::AbilityEffects.triggerPriorityBracketChange(b.ability, b, subPri, self)
if subPri!=newSubPri
if subPri != newSubPri
subPri = newSubPri
b.effects[PBEffects::PriorityAbility] = true
b.effects[PBEffects::PriorityItem] = false
@@ -177,7 +177,7 @@ class Battle
# Items (Quick Claw, Custap Berry, Lagging Tail, Full Incense)
if b.itemActive?
newSubPri = Battle::ItemEffects.triggerPriorityBracketChange(b.item, b, subPri, self)
if subPri!=newSubPri
if subPri != newSubPri
subPri = newSubPri
b.effects[PBEffects::PriorityAbility] = false
b.effects[PBEffects::PriorityItem] = true
@@ -189,9 +189,9 @@ class Battle
end
needRearranging = true
else
if (@field.effects[PBEffects::TrickRoom]>0)!=@priorityTrickRoom
if (@field.effects[PBEffects::TrickRoom] > 0) != @priorityTrickRoom
needRearranging = true
@priorityTrickRoom = (@field.effects[PBEffects::TrickRoom]>0)
@priorityTrickRoom = (@field.effects[PBEffects::TrickRoom] > 0)
end
# Just recheck all battler speeds
@priority.each do |orderArray|
@@ -199,24 +199,24 @@ class Battle
next if indexArray && !indexArray.include?(orderArray[0].index)
oldSpeed = orderArray[1]
orderArray[1] = orderArray[0].pbSpeed
needRearranging = true if orderArray[1]!=oldSpeed
needRearranging = true if orderArray[1] != oldSpeed
end
end
# Reorder the priority array
if needRearranging
@priority.sort! { |a,b|
if a[3]!=b[3]
@priority.sort! { |a, b|
if a[3] != b[3]
# Sort by priority (highest value first)
b[3]<=>a[3]
elsif a[2]!=b[2]
b[3] <=> a[3]
elsif a[2] != b[2]
# Sort by sub-priority (highest value first)
b[2]<=>a[2]
b[2] <=> a[2]
elsif @priorityTrickRoom
# Sort by speed (lowest first), and use tie-breaker if necessary
(a[1]==b[1]) ? b[4]<=>a[4] : a[1]<=>b[1]
(a[1] == b[1]) ? b[4] <=> a[4] : a[1] <=> b[1]
else
# Sort by speed (highest first), and use tie-breaker if necessary
(a[1]==b[1]) ? b[4]<=>a[4] : b[1]<=>a[1]
(a[1] == b[1]) ? b[4] <=> a[4] : b[1] <=> a[1]
end
}
# Write the priority order to the debug log
@@ -236,8 +236,8 @@ class Battle
if onlySpeedSort
# Sort battlers by their speed stats and tie-breaker order only.
tempArray = []
@priority.each { |pArray| tempArray.push([pArray[0],pArray[1],pArray[4]]) }
tempArray.sort! { |a,b| (a[1]==b[1]) ? b[2]<=>a[2] : b[1]<=>a[1] }
@priority.each { |pArray| tempArray.push([pArray[0], pArray[1], pArray[4]]) }
tempArray.sort! { |a, b| (a[1] == b[1]) ? b[2] <=> a[2] : b[1] <=> a[1] }
tempArray.each { |tArray| ret.push(tArray[0]) }
else
# Sort battlers by priority, sub-priority and their speed. Ties are

View File

@@ -6,18 +6,18 @@ class Battle
# battle.
# NOTE: Messages are only shown while in the party screen when choosing a
# command for the next round.
def pbCanSwitchLax?(idxBattler,idxParty,partyScene = nil)
return true if idxParty<0
def pbCanSwitchLax?(idxBattler, idxParty, partyScene = nil)
return true if idxParty < 0
party = pbParty(idxBattler)
return false if idxParty>=party.length
return false if idxParty >= party.length
return false if !party[idxParty]
if party[idxParty].egg?
partyScene.pbDisplay(_INTL("An Egg can't battle!")) if partyScene
return false
end
if !pbIsOwner?(idxBattler,idxParty)
if !pbIsOwner?(idxBattler, idxParty)
if partyScene
owner = pbGetOwnerFromPartyIndex(idxBattler,idxParty)
owner = pbGetOwnerFromPartyIndex(idxBattler, idxParty)
partyScene.pbDisplay(_INTL("You can't switch {1}'s Pokémon with one of yours!",
owner.name))
end
@@ -28,7 +28,7 @@ class Battle
party[idxParty].name)) if partyScene
return false
end
if pbFindBattler(idxParty,idxBattler)
if pbFindBattler(idxParty, idxBattler)
partyScene.pbDisplay(_INTL("{1} is already in battle!",
party[idxParty].name)) if partyScene
return false
@@ -40,13 +40,13 @@ class Battle
# switch out (and that its replacement at party index idxParty can switch in).
# NOTE: Messages are only shown while in the party screen when choosing a
# command for the next round.
def pbCanSwitch?(idxBattler,idxParty = -1,partyScene = nil)
def pbCanSwitch?(idxBattler, idxParty = -1, partyScene = nil)
# Check whether party Pokémon can switch in
return false if !pbCanSwitchLax?(idxBattler,idxParty,partyScene)
return false if !pbCanSwitchLax?(idxBattler, idxParty, partyScene)
# Make sure another battler isn't already choosing to switch to the party
# Pokémon
allSameSideBattlers(idxBattler).each do |b|
next if choices[b.index][0]!=:SwitchOut || choices[b.index][1]!=idxParty
next if choices[b.index][0] != :SwitchOut || choices[b.index][1] != idxParty
partyScene.pbDisplay(_INTL("{1} has already been selected.",
pbParty(idxBattler)[idxParty].name)) if partyScene
return false
@@ -69,7 +69,7 @@ class Battle
return true if Settings::MORE_TYPE_EFFECTS && battler.pbHasType?(:GHOST)
# Other certain trapping effects
if battler.trappedInBattle?
partyScene.pbDisplay(_INTL("{1} can't be switched out!",battler.pbThis)) if partyScene
partyScene.pbDisplay(_INTL("{1} can't be switched out!", battler.pbThis)) if partyScene
return false
end
# Trapping abilities/items
@@ -77,15 +77,15 @@ class Battle
next if !b.abilityActive?
if Battle::AbilityEffects.triggerTrappingByTarget(b.ability, battler, b, self)
partyScene.pbDisplay(_INTL("{1}'s {2} prevents switching!",
b.pbThis,b.abilityName)) if partyScene
b.pbThis, b.abilityName)) if partyScene
return false
end
end
allOtherSideBattlers(idxBattler).each do |b|
next if !b.itemActive?
if Battle::ItemEffects.triggerTrappingByTarget(b.item,battler,b,self)
if Battle::ItemEffects.triggerTrappingByTarget(b.item, battler, b, self)
partyScene.pbDisplay(_INTL("{1}'s {2} prevents switching!",
b.pbThis,b.itemName)) if partyScene
b.pbThis, b.itemName)) if partyScene
return false
end
end
@@ -93,14 +93,14 @@ class Battle
end
def pbCanChooseNonActive?(idxBattler)
pbParty(idxBattler).each_with_index do |_pkmn,i|
return true if pbCanSwitchLax?(idxBattler,i)
pbParty(idxBattler).each_with_index do |_pkmn, i|
return true if pbCanSwitchLax?(idxBattler, i)
end
return false
end
def pbRegisterSwitch(idxBattler,idxParty)
return false if !pbCanSwitch?(idxBattler,idxParty)
def pbRegisterSwitch(idxBattler, idxParty)
return false if !pbCanSwitch?(idxBattler, idxParty)
@choices[idxBattler][0] = :SwitchOut
@choices[idxBattler][1] = idxParty # Party index of Pokémon to switch in
@choices[idxBattler][2] = nil
@@ -113,16 +113,16 @@ class Battle
#=============================================================================
# Open party screen and potentially choose a Pokémon to switch with. Used in
# all instances where the party screen is opened.
def pbPartyScreen(idxBattler,checkLaxOnly = false,canCancel = false,shouldRegister = false)
def pbPartyScreen(idxBattler, checkLaxOnly = false, canCancel = false, shouldRegister = false)
ret = -1
@scene.pbPartyScreen(idxBattler,canCancel) { |idxParty,partyScene|
@scene.pbPartyScreen(idxBattler, canCancel) { |idxParty, partyScene|
if checkLaxOnly
next false if !pbCanSwitchLax?(idxBattler,idxParty,partyScene)
next false if !pbCanSwitchLax?(idxBattler, idxParty, partyScene)
else
next false if !pbCanSwitch?(idxBattler,idxParty,partyScene)
next false if !pbCanSwitch?(idxBattler, idxParty, partyScene)
end
if shouldRegister
next false if idxParty<0 || !pbRegisterSwitch(idxBattler,idxParty)
next false if idxParty < 0 || !pbRegisterSwitch(idxBattler, idxParty)
end
ret = idxParty
next true
@@ -132,9 +132,9 @@ class Battle
# For choosing a replacement Pokémon when prompted in the middle of other
# things happening (U-turn, Baton Pass, in def pbEORSwitch).
def pbSwitchInBetween(idxBattler,checkLaxOnly = false,canCancel = false)
return pbPartyScreen(idxBattler,checkLaxOnly,canCancel) if pbOwnedByPlayer?(idxBattler)
return @battleAI.pbDefaultChooseNewEnemy(idxBattler,pbParty(idxBattler))
def pbSwitchInBetween(idxBattler, checkLaxOnly = false, canCancel = false)
return pbPartyScreen(idxBattler, checkLaxOnly, canCancel) if pbOwnedByPlayer?(idxBattler)
return @battleAI.pbDefaultChooseNewEnemy(idxBattler, pbParty(idxBattler))
end
#=============================================================================
@@ -143,10 +143,10 @@ class Battle
# General switching method that checks if any Pokémon need to be sent out and,
# if so, does. Called at the end of each round.
def pbEORSwitch(favorDraws = false)
return if @decision>0 && !favorDraws
return if @decision==5 && favorDraws
return if @decision > 0 && !favorDraws
return if @decision == 5 && favorDraws
pbJudge
return if @decision>0
return if @decision > 0
# Check through each fainted battler to see if that spot can be filled.
switched = []
loop do
@@ -162,9 +162,9 @@ class Battle
# NOTE: The player is only offered the chance to switch their own
# Pokémon when an opponent replaces a fainted Pokémon in single
# battles. In double battles, etc. there is no such offer.
if @internalBattle && @switchStyle && trainerBattle? && pbSideSize(0)==1 &&
if @internalBattle && @switchStyle && trainerBattle? && pbSideSize(0) == 1 &&
opposes?(idxBattler) && !@battlers[0].fainted? && !switched.include?(0) &&
pbCanChooseNonActive?(0) && @battlers[0].effects[PBEffects::Outrage]==0
pbCanChooseNonActive?(0) && @battlers[0].effects[PBEffects::Outrage] == 0
idxPartyForName = idxPartyNew
enemyParty = pbParty(idxBattler)
if enemyParty[idxPartyNew].ability == :ILLUSION && !pbCheckGlobalAbility(:NEUTRALIZINGGAS)
@@ -173,82 +173,82 @@ class Battle
end
if pbDisplayConfirm(_INTL("{1} is about to send in {2}. Will you switch your Pokémon?",
opponent.full_name, enemyParty[idxPartyForName].name))
idxPlayerPartyNew = pbSwitchInBetween(0,false,true)
if idxPlayerPartyNew>=0
idxPlayerPartyNew = pbSwitchInBetween(0, false, true)
if idxPlayerPartyNew >= 0
pbMessageOnRecall(@battlers[0])
pbRecallAndReplace(0,idxPlayerPartyNew)
pbRecallAndReplace(0, idxPlayerPartyNew)
switched.push(0)
end
end
end
pbRecallAndReplace(idxBattler,idxPartyNew)
pbRecallAndReplace(idxBattler, idxPartyNew)
switched.push(idxBattler)
elsif trainerBattle? # Player switches in in a trainer battle
idxPlayerPartyNew = pbGetReplacementPokemonIndex(idxBattler) # Owner chooses
pbRecallAndReplace(idxBattler,idxPlayerPartyNew)
pbRecallAndReplace(idxBattler, idxPlayerPartyNew)
switched.push(idxBattler)
else # Player's Pokémon has fainted in a wild battle
switch = false
if !pbDisplayConfirm(_INTL("Use next Pokémon?"))
switch = (pbRun(idxBattler,true)<=0)
switch = (pbRun(idxBattler, true) <= 0)
else
switch = true
end
if switch
idxPlayerPartyNew = pbGetReplacementPokemonIndex(idxBattler) # Owner chooses
pbRecallAndReplace(idxBattler,idxPlayerPartyNew)
pbRecallAndReplace(idxBattler, idxPlayerPartyNew)
switched.push(idxBattler)
end
end
end
break if switched.length==0
break if switched.length == 0
pbOnBattlerEnteringBattle(switched)
end
end
def pbGetReplacementPokemonIndex(idxBattler,random = false)
def pbGetReplacementPokemonIndex(idxBattler, random = false)
if random
choices = [] # Find all Pokémon that can switch in
eachInTeamFromBattlerIndex(idxBattler) do |_pkmn,i|
choices.push(i) if pbCanSwitchLax?(idxBattler,i)
eachInTeamFromBattlerIndex(idxBattler) do |_pkmn, i|
choices.push(i) if pbCanSwitchLax?(idxBattler, i)
end
return -1 if choices.length==0
return -1 if choices.length == 0
return choices[pbRandom(choices.length)]
else
return pbSwitchInBetween(idxBattler,true)
return pbSwitchInBetween(idxBattler, true)
end
end
# Actually performs the recalling and sending out in all situations.
def pbRecallAndReplace(idxBattler,idxParty,randomReplacement = false,batonPass = false)
def pbRecallAndReplace(idxBattler, idxParty, randomReplacement = false, batonPass = false)
@scene.pbRecall(idxBattler) if !@battlers[idxBattler].fainted?
@battlers[idxBattler].pbAbilitiesOnSwitchOut # Inc. primordial weather check
@scene.pbShowPartyLineup(idxBattler&1) if pbSideSize(idxBattler)==1
pbMessagesOnReplace(idxBattler,idxParty) if !randomReplacement
pbReplace(idxBattler,idxParty,batonPass)
@scene.pbShowPartyLineup(idxBattler & 1) if pbSideSize(idxBattler) == 1
pbMessagesOnReplace(idxBattler, idxParty) if !randomReplacement
pbReplace(idxBattler, idxParty, batonPass)
end
def pbMessageOnRecall(battler)
if battler.pbOwnedByPlayer?
if battler.hp<=battler.totalhp/4
pbDisplayBrief(_INTL("Good job, {1}! Come back!",battler.name))
elsif battler.hp<=battler.totalhp/2
pbDisplayBrief(_INTL("OK, {1}! Come back!",battler.name))
elsif battler.turnCount>=5
pbDisplayBrief(_INTL("{1}, that's enough! Come back!",battler.name))
elsif battler.turnCount>=2
pbDisplayBrief(_INTL("{1}, come back!",battler.name))
if battler.hp <= battler.totalhp / 4
pbDisplayBrief(_INTL("Good job, {1}! Come back!", battler.name))
elsif battler.hp <= battler.totalhp / 2
pbDisplayBrief(_INTL("OK, {1}! Come back!", battler.name))
elsif battler.turnCount >= 5
pbDisplayBrief(_INTL("{1}, that's enough! Come back!", battler.name))
elsif battler.turnCount >= 2
pbDisplayBrief(_INTL("{1}, come back!", battler.name))
else
pbDisplayBrief(_INTL("{1}, switch out! Come back!",battler.name))
pbDisplayBrief(_INTL("{1}, switch out! Come back!", battler.name))
end
else
owner = pbGetOwnerName(battler.index)
pbDisplayBrief(_INTL("{1} withdrew {2}!",owner,battler.name))
pbDisplayBrief(_INTL("{1} withdrew {2}!", owner, battler.name))
end
end
# Only called from def pbRecallAndReplace and Battle Arena's def pbSwitch.
def pbMessagesOnReplace(idxBattler,idxParty)
def pbMessagesOnReplace(idxBattler, idxParty)
party = pbParty(idxBattler)
newPkmnName = party[idxParty].name
if party[idxParty].ability == :ILLUSION && !pbCheckGlobalAbility(:NEUTRALIZINGGAS)
@@ -257,45 +257,45 @@ class Battle
end
if pbOwnedByPlayer?(idxBattler)
opposing = @battlers[idxBattler].pbDirectOpposing
if opposing.fainted? || opposing.hp==opposing.totalhp
pbDisplayBrief(_INTL("You're in charge, {1}!",newPkmnName))
elsif opposing.hp>=opposing.totalhp/2
pbDisplayBrief(_INTL("Go for it, {1}!",newPkmnName))
elsif opposing.hp>=opposing.totalhp/4
pbDisplayBrief(_INTL("Just a little more! Hang in there, {1}!",newPkmnName))
if opposing.fainted? || opposing.hp == opposing.totalhp
pbDisplayBrief(_INTL("You're in charge, {1}!", newPkmnName))
elsif opposing.hp >= opposing.totalhp / 2
pbDisplayBrief(_INTL("Go for it, {1}!", newPkmnName))
elsif opposing.hp >= opposing.totalhp / 4
pbDisplayBrief(_INTL("Just a little more! Hang in there, {1}!", newPkmnName))
else
pbDisplayBrief(_INTL("Your opponent's weak! Get 'em, {1}!",newPkmnName))
pbDisplayBrief(_INTL("Your opponent's weak! Get 'em, {1}!", newPkmnName))
end
else
owner = pbGetOwnerFromBattlerIndex(idxBattler)
pbDisplayBrief(_INTL("{1} sent out {2}!",owner.full_name,newPkmnName))
pbDisplayBrief(_INTL("{1} sent out {2}!", owner.full_name, newPkmnName))
end
end
# Only called from def pbRecallAndReplace above and Battle Arena's def
# pbSwitch.
def pbReplace(idxBattler,idxParty,batonPass = false)
def pbReplace(idxBattler, idxParty, batonPass = false)
party = pbParty(idxBattler)
idxPartyOld = @battlers[idxBattler].pokemonIndex
# Initialise the new Pokémon
@battlers[idxBattler].pbInitialize(party[idxParty],idxParty,batonPass)
@battlers[idxBattler].pbInitialize(party[idxParty], idxParty, batonPass)
# Reorder the party for this battle
partyOrder = pbPartyOrder(idxBattler)
partyOrder[idxParty],partyOrder[idxPartyOld] = partyOrder[idxPartyOld],partyOrder[idxParty]
partyOrder[idxParty], partyOrder[idxPartyOld] = partyOrder[idxPartyOld], partyOrder[idxParty]
# Send out the new Pokémon
pbSendOut([[idxBattler,party[idxParty]]])
pbCalculatePriority(false,[idxBattler]) if Settings::RECALCULATE_TURN_ORDER_AFTER_SPEED_CHANGES
pbSendOut([[idxBattler, party[idxParty]]])
pbCalculatePriority(false, [idxBattler]) if Settings::RECALCULATE_TURN_ORDER_AFTER_SPEED_CHANGES
end
# Called from def pbReplace above and at the start of battle.
# sendOuts is an array; each element is itself an array: [idxBattler,pkmn]
def pbSendOut(sendOuts,startBattle = false)
def pbSendOut(sendOuts, startBattle = false)
sendOuts.each { |b| @peer.pbOnEnteringBattle(self, @battlers[b[0]], b[1]) }
@scene.pbSendOutBattlers(sendOuts,startBattle)
@scene.pbSendOutBattlers(sendOuts, startBattle)
sendOuts.each do |b|
@scene.pbResetMoveIndex(b[0])
pbSetSeen(@battlers[b[0]])
@usedInBattle[b[0]&1][b[0]/2] = true
@usedInBattle[b[0] & 1][b[0] / 2] = true
end
end

View File

@@ -2,13 +2,13 @@ class Battle
#=============================================================================
# Choosing to use an item
#=============================================================================
def pbCanUseItemOnPokemon?(item,pkmn,battler,scene,showMessages = true)
def pbCanUseItemOnPokemon?(item, pkmn, battler, scene, showMessages = true)
if !pkmn || pkmn.egg?
scene.pbDisplay(_INTL("It won't have any effect.")) if showMessages
return false
end
# Embargo
if battler && battler.effects[PBEffects::Embargo]>0
if battler && battler.effects[PBEffects::Embargo] > 0
scene.pbDisplay(_INTL("Embargo's effect prevents the item's use on {1}!",
battler.pbThis(true))) if showMessages
return false
@@ -24,7 +24,7 @@ class Battle
return false
end
def pbRegisterItem(idxBattler,item,idxTarget = nil,idxMove = nil)
def pbRegisterItem(idxBattler, item, idxTarget = nil, idxMove = nil)
# Register for use of item on a Pokémon in the party
@choices[idxBattler][0] = :UseItem
@choices[idxBattler][1] = item # ID of item to be used
@@ -32,14 +32,14 @@ class Battle
@choices[idxBattler][3] = idxMove # Index of move to recharge (Ethers)
# Delete the item from the Bag. If it turns out it will have no effect, it
# will be re-added to the Bag later.
pbConsumeItemInBag(item,idxBattler)
pbConsumeItemInBag(item, idxBattler)
return true
end
#=============================================================================
# Using an item
#=============================================================================
def pbConsumeItemInBag(item,idxBattler)
def pbConsumeItemInBag(item, idxBattler)
return if !item
return if !GameData::Item.get(item).consumed_after_use?
if pbOwnedByPlayer?(idxBattler)
@@ -52,7 +52,7 @@ class Battle
end
end
def pbReturnUnusedItemToBag(item,idxBattler)
def pbReturnUnusedItemToBag(item, idxBattler)
return if !item
return if !GameData::Item.get(item).consumed_after_use?
if pbOwnedByPlayer?(idxBattler)
@@ -67,41 +67,41 @@ class Battle
end
end
def pbUseItemMessage(item,trainerName)
def pbUseItemMessage(item, trainerName)
itemName = GameData::Item.get(item).name
if itemName.starts_with_vowel?
pbDisplayBrief(_INTL("{1} used an {2}.",trainerName,itemName))
pbDisplayBrief(_INTL("{1} used an {2}.", trainerName, itemName))
else
pbDisplayBrief(_INTL("{1} used a {2}.",trainerName,itemName))
pbDisplayBrief(_INTL("{1} used a {2}.", trainerName, itemName))
end
end
# Uses an item on a Pokémon in the trainer's party.
def pbUseItemOnPokemon(item,idxParty,userBattler)
def pbUseItemOnPokemon(item, idxParty, userBattler)
trainerName = pbGetOwnerName(userBattler.index)
pbUseItemMessage(item,trainerName)
pbUseItemMessage(item, trainerName)
pkmn = pbParty(userBattler.index)[idxParty]
battler = pbFindBattler(idxParty,userBattler.index)
battler = pbFindBattler(idxParty, userBattler.index)
ch = @choices[userBattler.index]
if ItemHandlers.triggerCanUseInBattle(item,pkmn,battler,ch[3],true,self,@scene,false)
ItemHandlers.triggerBattleUseOnPokemon(item,pkmn,battler,ch,@scene)
if ItemHandlers.triggerCanUseInBattle(item, pkmn, battler, ch[3], true, self, @scene, false)
ItemHandlers.triggerBattleUseOnPokemon(item, pkmn, battler, ch, @scene)
ch[1] = nil # Delete item from choice
return
end
pbDisplay(_INTL("But it had no effect!"))
# Return unused item to Bag
pbReturnUnusedItemToBag(item,userBattler.index)
pbReturnUnusedItemToBag(item, userBattler.index)
end
# Uses an item on a Pokémon in battle that belongs to the trainer.
def pbUseItemOnBattler(item,idxParty,userBattler)
def pbUseItemOnBattler(item, idxParty, userBattler)
trainerName = pbGetOwnerName(userBattler.index)
pbUseItemMessage(item,trainerName)
battler = pbFindBattler(idxParty,userBattler.index)
pbUseItemMessage(item, trainerName)
battler = pbFindBattler(idxParty, userBattler.index)
ch = @choices[userBattler.index]
if battler
if ItemHandlers.triggerCanUseInBattle(item,battler.pokemon,battler,ch[3],true,self,@scene,false)
ItemHandlers.triggerBattleUseOnBattler(item,battler,@scene)
if ItemHandlers.triggerCanUseInBattle(item, battler.pokemon, battler, ch[3], true, self, @scene, false)
ItemHandlers.triggerBattleUseOnBattler(item, battler, @scene)
ch[1] = nil # Delete item from choice
battler.pbItemOnStatDropped
return
@@ -112,31 +112,31 @@ class Battle
pbDisplay(_INTL("But it's not where this item can be used!"))
end
# Return unused item to Bag
pbReturnUnusedItemToBag(item,userBattler.index)
pbReturnUnusedItemToBag(item, userBattler.index)
end
# Uses a Poké Ball in battle directly.
def pbUsePokeBallInBattle(item,idxBattler,userBattler)
idxBattler = userBattler.index if idxBattler<0
def pbUsePokeBallInBattle(item, idxBattler, userBattler)
idxBattler = userBattler.index if idxBattler < 0
battler = @battlers[idxBattler]
ItemHandlers.triggerUseInBattle(item,battler,self)
ItemHandlers.triggerUseInBattle(item, battler, self)
@choices[userBattler.index][1] = nil # Delete item from choice
end
# Uses an item in battle directly.
def pbUseItemInBattle(item,idxBattler,userBattler)
def pbUseItemInBattle(item, idxBattler, userBattler)
trainerName = pbGetOwnerName(userBattler.index)
pbUseItemMessage(item,trainerName)
battler = (idxBattler<0) ? userBattler : @battlers[idxBattler]
pbUseItemMessage(item, trainerName)
battler = (idxBattler < 0) ? userBattler : @battlers[idxBattler]
pkmn = battler.pokemon
ch = @choices[userBattler.index]
if ItemHandlers.triggerCanUseInBattle(item,pkmn,battler,ch[3],true,self,@scene,false)
ItemHandlers.triggerUseInBattle(item,battler,self)
if ItemHandlers.triggerCanUseInBattle(item, pkmn, battler, ch[3], true, self, @scene, false)
ItemHandlers.triggerUseInBattle(item, battler, self)
ch[1] = nil # Delete item from choice
return
end
pbDisplay(_INTL("But it had no effect!"))
# Return unused item to Bag
pbReturnUnusedItemToBag(item,userBattler.index)
pbReturnUnusedItemToBag(item, userBattler.index)
end
end

View File

@@ -27,7 +27,7 @@ class Battle
# 1: Succeeded at fleeing, battle will end
# duringBattle is true for replacing a fainted Pokémon during the End Of Round
# phase, and false for choosing the Run command.
def pbRun(idxBattler,duringBattle = false)
def pbRun(idxBattler, duringBattle = false)
battler = @battlers[idxBattler]
if battler.opposes?
return 0 if trainerBattle?
@@ -50,7 +50,7 @@ class Battle
pbDisplayPaused(_INTL("No! There's no running from a Trainer battle!"))
elsif pbDisplayConfirm(_INTL("Would you like to forfeit the match and quit now?"))
pbSEPlay("Battle flee")
pbDisplay(_INTL("{1} forfeited the match!",self.pbPlayer.name))
pbDisplay(_INTL("{1} forfeited the match!", self.pbPlayer.name))
@decision = 3
return 1
end
@@ -77,7 +77,7 @@ class Battle
# Abilities that guarantee escape
if battler.abilityActive?
if Battle::AbilityEffects.triggerCertainEscapeFromBattle(battler.ability, battler)
pbShowAbilitySplash(battler,true)
pbShowAbilitySplash(battler, true)
pbHideAbilitySplash(battler)
pbSEPlay("Battle flee")
pbDisplayPaused(_INTL("You got away safely!"))
@@ -89,7 +89,7 @@ class Battle
if battler.itemActive?
if Battle::ItemEffects.triggerCertainEscapeFromBattle(battler.item, battler)
pbSEPlay("Battle flee")
pbDisplayPaused(_INTL("{1} fled using its {2}!", battler.pbThis,battler.itemName))
pbDisplayPaused(_INTL("{1} fled using its {2}!", battler.pbThis, battler.itemName))
@decision = 3
return 1
end
@@ -103,14 +103,14 @@ class Battle
allOtherSideBattlers(idxBattler).each do |b|
next if !b.abilityActive?
if Battle::AbilityEffects.triggerTrappingByTarget(b.ability, battler, b, self)
pbDisplayPaused(_INTL("{1} prevents escape with {2}!",b.pbThis,b.abilityName))
pbDisplayPaused(_INTL("{1} prevents escape with {2}!", b.pbThis, b.abilityName))
return 0
end
end
allOtherSideBattlers(idxBattler).each do |b|
next if !b.itemActive?
if Battle::ItemEffects.triggerTrappingByTarget(b.item, battler, b, self)
pbDisplayPaused(_INTL("{1} prevents escape with {2}!",b.pbThis,b.itemName))
pbDisplayPaused(_INTL("{1} prevents escape with {2}!", b.pbThis, b.itemName))
return 0
end
end
@@ -123,16 +123,16 @@ class Battle
speedEnemy = 1
allOtherSideBattlers(idxBattler).each do |b|
speed = b.speed
speedEnemy = speed if speedEnemy<speed
speedEnemy = speed if speedEnemy < speed
end
# Compare speeds and perform fleeing calculation
if speedPlayer>speedEnemy
if speedPlayer > speedEnemy
rate = 256
else
rate = (speedPlayer*128)/speedEnemy
rate += @runCommand*30
rate = (speedPlayer * 128) / speedEnemy
rate += @runCommand * 30
end
if rate>=256 || @battleAI.pbAIRandom(256)<rate
if rate >= 256 || @battleAI.pbAIRandom(256) < rate
pbSEPlay("Battle flee")
pbDisplayPaused(_INTL("You got away safely!"))
@decision = 3

View File

@@ -3,18 +3,18 @@ class Battle
# Shifting a battler to another position in a battle larger than double
#=============================================================================
def pbCanShift?(idxBattler)
return false if pbSideSize(0)<=2 && pbSideSize(1)<=2 # Double battle or smaller
return false if pbSideSize(0) <= 2 && pbSideSize(1) <= 2 # Double battle or smaller
idxOther = -1
case pbSideSize(idxBattler)
when 1
return false # Only one battler on that side
when 2
idxOther = (idxBattler+2)%4
idxOther = (idxBattler + 2) % 4
when 3
return false if idxBattler==2 || idxBattler==3 # In middle spot already
idxOther = ((idxBattler%2)==0) ? 2 : 3
return false if idxBattler == 2 || idxBattler == 3 # In middle spot already
idxOther = ((idxBattler % 2) == 0) ? 2 : 3
end
return false if pbGetOwnerIndexFromBattlerIndex(idxBattler)!=pbGetOwnerIndexFromBattlerIndex(idxOther)
return false if pbGetOwnerIndexFromBattlerIndex(idxBattler) != pbGetOwnerIndexFromBattlerIndex(idxOther)
return true
end
@@ -38,20 +38,20 @@ class Battle
def pbCall(idxBattler)
battler = @battlers[idxBattler]
trainerName = pbGetOwnerName(idxBattler)
pbDisplay(_INTL("{1} called {2}!",trainerName,battler.pbThis(true)))
pbDisplay(_INTL("{1}!",battler.name))
pbDisplay(_INTL("{1} called {2}!", trainerName, battler.pbThis(true)))
pbDisplay(_INTL("{1}!", battler.name))
if battler.shadowPokemon?
if battler.inHyperMode?
battler.pokemon.hyper_mode = false
battler.pokemon.change_heart_gauge("call")
pbDisplay(_INTL("{1} came to its senses from the Trainer's call!",battler.pbThis))
pbDisplay(_INTL("{1} came to its senses from the Trainer's call!", battler.pbThis))
else
pbDisplay(_INTL("But nothing happened!"))
end
elsif battler.status == :SLEEP
battler.pbCureStatus
elsif battler.pbCanRaiseStatStage?(:ACCURACY,battler)
battler.pbRaiseStatStage(:ACCURACY,1,battler)
elsif battler.pbCanRaiseStatStage?(:ACCURACY, battler)
battler.pbRaiseStatStage(:ACCURACY, 1, battler)
battler.pbItemOnStatDropped
else
pbDisplay(_INTL("But nothing happened!"))
@@ -85,11 +85,11 @@ class Battle
return false if !@battlers[idxBattler].hasMega?
return false if @battlers[idxBattler].wild?
return true if $DEBUG && Input.press?(Input::CTRL)
return false if @battlers[idxBattler].effects[PBEffects::SkyDrop]>=0
return false if @battlers[idxBattler].effects[PBEffects::SkyDrop] >= 0
return false if !pbHasMegaRing?(idxBattler)
side = @battlers[idxBattler].idxOwnSide
owner = pbGetOwnerIndexFromBattlerIndex(idxBattler)
return @megaEvolution[side][owner]==-1
return @megaEvolution[side][owner] == -1
end
def pbRegisterMegaEvolution(idxBattler)
@@ -101,13 +101,13 @@ class Battle
def pbUnregisterMegaEvolution(idxBattler)
side = @battlers[idxBattler].idxOwnSide
owner = pbGetOwnerIndexFromBattlerIndex(idxBattler)
@megaEvolution[side][owner] = -1 if @megaEvolution[side][owner]==idxBattler
@megaEvolution[side][owner] = -1 if @megaEvolution[side][owner] == idxBattler
end
def pbToggleRegisteredMegaEvolution(idxBattler)
side = @battlers[idxBattler].idxOwnSide
owner = pbGetOwnerIndexFromBattlerIndex(idxBattler)
if @megaEvolution[side][owner]==idxBattler
if @megaEvolution[side][owner] == idxBattler
@megaEvolution[side][owner] = -1
else
@megaEvolution[side][owner] = idxBattler
@@ -117,7 +117,7 @@ class Battle
def pbRegisteredMegaEvolution?(idxBattler)
side = @battlers[idxBattler].idxOwnSide
owner = pbGetOwnerIndexFromBattlerIndex(idxBattler)
return @megaEvolution[side][owner]==idxBattler
return @megaEvolution[side][owner] == idxBattler
end
#=============================================================================
@@ -137,28 +137,28 @@ class Battle
# Mega Evolve
case battler.pokemon.megaMessage
when 1 # Rayquaza
pbDisplay(_INTL("{1}'s fervent wish has reached {2}!",trainerName,battler.pbThis))
pbDisplay(_INTL("{1}'s fervent wish has reached {2}!", trainerName, battler.pbThis))
else
pbDisplay(_INTL("{1}'s {2} is reacting to {3}'s {4}!",
battler.pbThis,battler.itemName,trainerName,pbGetMegaRingName(idxBattler)))
battler.pbThis, battler.itemName, trainerName, pbGetMegaRingName(idxBattler)))
end
pbCommonAnimation("MegaEvolution",battler)
pbCommonAnimation("MegaEvolution", battler)
battler.pokemon.makeMega
battler.form = battler.pokemon.form
battler.pbUpdate(true)
@scene.pbChangePokemon(battler,battler.pokemon)
@scene.pbChangePokemon(battler, battler.pokemon)
@scene.pbRefreshOne(idxBattler)
pbCommonAnimation("MegaEvolution2",battler)
pbCommonAnimation("MegaEvolution2", battler)
megaName = battler.pokemon.megaName
megaName = _INTL("Mega {1}", battler.pokemon.speciesName) if nil_or_empty?(megaName)
pbDisplay(_INTL("{1} has Mega Evolved into {2}!",battler.pbThis,megaName))
pbDisplay(_INTL("{1} has Mega Evolved into {2}!", battler.pbThis, megaName))
side = battler.idxOwnSide
owner = pbGetOwnerIndexFromBattlerIndex(idxBattler)
@megaEvolution[side][owner] = -2
if battler.isSpecies?(:GENGAR) && battler.mega?
battler.effects[PBEffects::Telekinesis] = 0
end
pbCalculatePriority(false,[idxBattler]) if Settings::RECALCULATE_TURN_ORDER_AFTER_MEGA_EVOLUTION
pbCalculatePriority(false, [idxBattler]) if Settings::RECALCULATE_TURN_ORDER_AFTER_MEGA_EVOLUTION
# Trigger ability
battler.pbOnLosingAbility(old_ability)
battler.pbTriggerAbilityOnGainingIt
@@ -172,20 +172,20 @@ class Battle
return if !battler || !battler.pokemon || battler.fainted?
return if !battler.hasPrimal? || battler.primal?
if battler.isSpecies?(:KYOGRE)
pbCommonAnimation("PrimalKyogre",battler)
pbCommonAnimation("PrimalKyogre", battler)
elsif battler.isSpecies?(:GROUDON)
pbCommonAnimation("PrimalGroudon",battler)
pbCommonAnimation("PrimalGroudon", battler)
end
battler.pokemon.makePrimal
battler.form = battler.pokemon.form
battler.pbUpdate(true)
@scene.pbChangePokemon(battler,battler.pokemon)
@scene.pbChangePokemon(battler, battler.pokemon)
@scene.pbRefreshOne(idxBattler)
if battler.isSpecies?(:KYOGRE)
pbCommonAnimation("PrimalKyogre2",battler)
pbCommonAnimation("PrimalKyogre2", battler)
elsif battler.isSpecies?(:GROUDON)
pbCommonAnimation("PrimalGroudon2",battler)
pbCommonAnimation("PrimalGroudon2", battler)
end
pbDisplay(_INTL("{1}'s Primal Reversion!\nIt reverted to its primal form!",battler.pbThis))
pbDisplay(_INTL("{1}'s Primal Reversion!\nIt reverted to its primal form!", battler.pbThis))
end
end

View File

@@ -25,8 +25,8 @@ class Battle
#=============================================================================
# Use main command menu (Fight/Pokémon/Bag/Run)
#=============================================================================
def pbCommandMenu(idxBattler,firstAction)
return @scene.pbCommandMenu(idxBattler,firstAction)
def pbCommandMenu(idxBattler, firstAction)
return @scene.pbCommandMenu(idxBattler, firstAction)
end
#=============================================================================
@@ -42,11 +42,11 @@ class Battle
def pbCanShowFightMenu?(idxBattler)
battler = @battlers[idxBattler]
# Encore
return false if battler.effects[PBEffects::Encore]>0
return false if battler.effects[PBEffects::Encore] > 0
# No moves that can be chosen (will Struggle instead)
usable = false
battler.eachMoveWithIndex do |_m,i|
next if !pbCanChooseMove?(idxBattler,i,false)
battler.eachMoveWithIndex do |_m, i|
next if !pbCanChooseMove?(idxBattler, i, false)
usable = true
break
end
@@ -64,7 +64,7 @@ class Battle
return true if pbAutoFightMenu(idxBattler)
# Regular move selection
ret = false
@scene.pbFightMenu(idxBattler,pbCanMegaEvolve?(idxBattler)) { |cmd|
@scene.pbFightMenu(idxBattler, pbCanMegaEvolve?(idxBattler)) { |cmd|
case cmd
when -1 # Cancel
when -2 # Toggle Mega Evolution
@@ -75,11 +75,11 @@ class Battle
pbRegisterShift(idxBattler)
ret = true
else # Chose a move to use
next false if cmd<0 || !@battlers[idxBattler].moves[cmd] ||
next false if cmd < 0 || !@battlers[idxBattler].moves[cmd] ||
!@battlers[idxBattler].moves[cmd].id
next false if !pbRegisterMove(idxBattler,cmd)
next false if !pbRegisterMove(idxBattler, cmd)
next false if !singleBattle? &&
!pbChooseTarget(@battlers[idxBattler],@battlers[idxBattler].moves[cmd])
!pbChooseTarget(@battlers[idxBattler], @battlers[idxBattler].moves[cmd])
ret = true
end
next true
@@ -89,36 +89,36 @@ class Battle
def pbAutoFightMenu(idxBattler); return false; end
def pbChooseTarget(battler,move)
def pbChooseTarget(battler, move)
target_data = move.pbTarget(battler)
idxTarget = @scene.pbChooseTarget(battler.index,target_data)
return false if idxTarget<0
pbRegisterTarget(battler.index,idxTarget)
idxTarget = @scene.pbChooseTarget(battler.index, target_data)
return false if idxTarget < 0
pbRegisterTarget(battler.index, idxTarget)
return true
end
def pbItemMenu(idxBattler,firstAction)
def pbItemMenu(idxBattler, firstAction)
if !@internalBattle
pbDisplay(_INTL("Items can't be used here."))
return false
end
ret = false
@scene.pbItemMenu(idxBattler,firstAction) { |item,useType,idxPkmn,idxMove,itemScene|
@scene.pbItemMenu(idxBattler, firstAction) { |item, useType, idxPkmn, idxMove, itemScene|
next false if !item
battler = pkmn = nil
case useType
when 1, 2 # Use on Pokémon/Pokémon's move
next false if !ItemHandlers.hasBattleUseOnPokemon(item)
battler = pbFindBattler(idxPkmn,idxBattler)
battler = pbFindBattler(idxPkmn, idxBattler)
pkmn = pbParty(idxBattler)[idxPkmn]
next false if !pbCanUseItemOnPokemon?(item,pkmn,battler,itemScene)
next false if !pbCanUseItemOnPokemon?(item, pkmn, battler, itemScene)
when 3 # Use on battler
next false if !ItemHandlers.hasBattleUseOnBattler(item)
battler = pbFindBattler(idxPkmn,idxBattler)
battler = pbFindBattler(idxPkmn, idxBattler)
pkmn = battler.pokemon if battler
next false if !pbCanUseItemOnPokemon?(item,pkmn,battler,itemScene)
next false if !pbCanUseItemOnPokemon?(item, pkmn, battler, itemScene)
when 4 # Poké Balls
next false if idxPkmn<0
next false if idxPkmn < 0
battler = @battlers[idxPkmn]
pkmn = battler.pokemon if battler
when 5 # No target (Poké Doll, Guard Spec., Launcher items)
@@ -129,8 +129,8 @@ class Battle
end
next false if !pkmn
next false if !ItemHandlers.triggerCanUseInBattle(item,
pkmn,battler,idxMove,firstAction,self,itemScene)
next false if !pbRegisterItem(idxBattler,item,idxPkmn,idxMove)
pkmn, battler, idxMove, firstAction, self, itemScene)
next false if !pbRegisterItem(idxBattler, item, idxPkmn, idxMove)
ret = true
next true
}
@@ -140,16 +140,16 @@ class Battle
def pbPartyMenu(idxBattler)
ret = -1
if @debug
ret = @battleAI.pbDefaultChooseNewEnemy(idxBattler,pbParty(idxBattler))
ret = @battleAI.pbDefaultChooseNewEnemy(idxBattler, pbParty(idxBattler))
else
ret = pbPartyScreen(idxBattler,false,true,true)
ret = pbPartyScreen(idxBattler, false, true, true)
end
return ret>=0
return ret >= 0
end
def pbRunMenu(idxBattler)
# Regardless of succeeding or failing to run, stop choosing actions
return pbRun(idxBattler)!=0
return pbRun(idxBattler) != 0
end
def pbCallMenu(idxBattler)
@@ -172,19 +172,19 @@ class Battle
def pbCommandPhase
@scene.pbBeginCommandPhase
# Reset choices if commands can be shown
@battlers.each_with_index do |b,i|
@battlers.each_with_index do |b, i|
next if !b
pbClearChoice(i) if pbCanShowCommands?(i)
end
# Reset choices to perform Mega Evolution if it wasn't done somehow
for side in 0...2
@megaEvolution[side].each_with_index do |megaEvo,i|
@megaEvolution[side][i] = -1 if megaEvo>=0
@megaEvolution[side].each_with_index do |megaEvo, i|
@megaEvolution[side][i] = -1 if megaEvo >= 0
end
end
# Choose actions for the round (player first, then AI)
pbCommandPhaseLoop(true) # Player chooses their actions
return if @decision!=0 # Battle ended, stop choosing actions
return if @decision != 0 # Battle ended, stop choosing actions
pbCommandPhaseLoop(false) # AI chooses their actions
end
@@ -194,11 +194,11 @@ class Battle
actioned = []
idxBattler = -1
loop do
break if @decision!=0 # Battle ended, stop choosing actions
break if @decision != 0 # Battle ended, stop choosing actions
idxBattler += 1
break if idxBattler>=@battlers.length
next if !@battlers[idxBattler] || pbOwnedByPlayer?(idxBattler)!=isPlayer
next if @choices[idxBattler][0]!=:None # Action is forced, can't choose one
break if idxBattler >= @battlers.length
next if !@battlers[idxBattler] || pbOwnedByPlayer?(idxBattler) != isPlayer
next if @choices[idxBattler][0] != :None # Action is forced, can't choose one
next if !pbCanShowCommands?(idxBattler) # Action is forced, can't choose one
# AI controls this battler
if @controlPlayer || !pbOwnedByPlayer?(idxBattler)
@@ -209,17 +209,17 @@ class Battle
actioned.push(idxBattler)
commandsEnd = false # Whether to cancel choosing all other actions this round
loop do
cmd = pbCommandMenu(idxBattler,actioned.length==1)
cmd = pbCommandMenu(idxBattler, actioned.length == 1)
# If being Sky Dropped, can't do anything except use a move
if cmd>0 && @battlers[idxBattler].effects[PBEffects::SkyDrop]>=0
pbDisplay(_INTL("Sky Drop won't let {1} go!",@battlers[idxBattler].pbThis(true)))
if cmd > 0 && @battlers[idxBattler].effects[PBEffects::SkyDrop] >= 0
pbDisplay(_INTL("Sky Drop won't let {1} go!", @battlers[idxBattler].pbThis(true)))
next
end
case cmd
when 0 # Fight
break if pbFightMenu(idxBattler)
when 1 # Bag
if pbItemMenu(idxBattler,actioned.length==1)
if pbItemMenu(idxBattler, actioned.length == 1)
commandsEnd = true if pbItemUsesAllActions?(@choices[idxBattler][1])
break
end
@@ -240,10 +240,10 @@ class Battle
pbDebugMenu
next
when -1 # Go back to previous battler's action choice
next if actioned.length<=1
next if actioned.length <= 1
actioned.pop # Forget this battler was done
idxBattler = actioned.last-1
pbCancelChoice(idxBattler+1) # Clear the previous battler's choice
idxBattler = actioned.last - 1
pbCancelChoice(idxBattler + 1) # Clear the previous battler's choice
actioned.pop # Forget the previous battler was done
break
end

View File

@@ -15,7 +15,7 @@ class Battle
def pbAttackPhaseCall
pbPriority.each do |b|
next unless @choices[b.index][0]==:Call && !b.fainted?
next unless @choices[b.index][0] == :Call && !b.fainted?
b.lastMoveFailed = false # Counts as a successful move for Stomping Tantrum
pbCall(b.index)
end
@@ -25,31 +25,31 @@ class Battle
@switching = true
pbPriority.each do |b|
next if b.fainted? || !b.opposes?(idxSwitcher) # Shouldn't hit an ally
next if b.movedThisRound? || !pbChoseMoveFunctionCode?(b.index,"PursueSwitchingFoe")
next if b.movedThisRound? || !pbChoseMoveFunctionCode?(b.index, "PursueSwitchingFoe")
# Check whether Pursuit can be used
next unless pbMoveCanTarget?(b.index,idxSwitcher,@choices[b.index][2].pbTarget(b))
next unless pbCanChooseMove?(b.index,@choices[b.index][1],false)
next unless pbMoveCanTarget?(b.index, idxSwitcher, @choices[b.index][2].pbTarget(b))
next unless pbCanChooseMove?(b.index, @choices[b.index][1], false)
next if b.status == :SLEEP || b.status == :FROZEN
next if b.effects[PBEffects::SkyDrop]>=0
next if b.effects[PBEffects::SkyDrop] >= 0
next if b.hasActiveAbility?(:TRUANT) && b.effects[PBEffects::Truant]
# Mega Evolve
if !b.wild?
owner = pbGetOwnerIndexFromBattlerIndex(b.index)
pbMegaEvolve(b.index) if @megaEvolution[b.idxOwnSide][owner]==b.index
pbMegaEvolve(b.index) if @megaEvolution[b.idxOwnSide][owner] == b.index
end
# Use Pursuit
@choices[b.index][3] = idxSwitcher # Change Pursuit's target
if b.pbProcessTurn(@choices[b.index],false)
if b.pbProcessTurn(@choices[b.index], false)
b.effects[PBEffects::Pursuit] = true
end
break if @decision>0 || @battlers[idxSwitcher].fainted?
break if @decision > 0 || @battlers[idxSwitcher].fainted?
end
@switching = false
end
def pbAttackPhaseSwitch
pbPriority.each do |b|
next unless @choices[b.index][0]==:SwitchOut && !b.fainted?
next unless @choices[b.index][0] == :SwitchOut && !b.fainted?
idxNewPkmn = @choices[b.index][1] # Party index of Pokémon to switch to
b.lastMoveFailed = false # Counts as a successful move for Stomping Tantrum
@lastMoveUser = b.index
@@ -57,13 +57,13 @@ class Battle
pbMessageOnRecall(b)
# Pursuit interrupts switching
pbPursuit(b.index)
return if @decision>0
return if @decision > 0
# Switch Pokémon
allBattlers.each do |b|
b.droppedBelowHalfHP = false
b.statsDropped = false
end
pbRecallAndReplace(b.index,idxNewPkmn)
pbRecallAndReplace(b.index, idxNewPkmn)
pbOnBattlerEnteringBattle(b.index, true)
end
end
@@ -94,9 +94,9 @@ class Battle
def pbAttackPhaseMegaEvolution
pbPriority.each do |b|
next if b.wild?
next unless @choices[b.index][0]==:UseMove && !b.fainted?
next unless @choices[b.index][0] == :UseMove && !b.fainted?
owner = pbGetOwnerIndexFromBattlerIndex(b.index)
next if @megaEvolution[b.idxOwnSide][owner]!=b.index
next if @megaEvolution[b.idxOwnSide][owner] != b.index
pbMegaEvolve(b.index)
end
end
@@ -104,7 +104,7 @@ class Battle
def pbAttackPhaseMoves
# Show charging messages (Focus Punch)
pbPriority.each do |b|
next unless @choices[b.index][0]==:UseMove && !b.fainted?
next unless @choices[b.index][0] == :UseMove && !b.fainted?
next if b.movedThisRound?
@choices[b.index][2].pbDisplayChargeMessage(b)
end
@@ -115,28 +115,28 @@ class Battle
advance = false
priority.each do |b|
next unless b.effects[PBEffects::MoveNext] && !b.fainted?
next unless @choices[b.index][0]==:UseMove || @choices[b.index][0]==:Shift
next unless @choices[b.index][0] == :UseMove || @choices[b.index][0] == :Shift
next if b.movedThisRound?
advance = b.pbProcessTurn(@choices[b.index])
break if advance
end
return if @decision>0
return if @decision > 0
next if advance
# Regular priority order
priority.each do |b|
next if b.effects[PBEffects::Quash]>0 || b.fainted?
next unless @choices[b.index][0]==:UseMove || @choices[b.index][0]==:Shift
next if b.effects[PBEffects::Quash] > 0 || b.fainted?
next unless @choices[b.index][0] == :UseMove || @choices[b.index][0] == :Shift
next if b.movedThisRound?
advance = b.pbProcessTurn(@choices[b.index])
break if advance
end
return if @decision>0
return if @decision > 0
next if advance
# Quashed
if Settings::MECHANICS_GENERATION >= 8
priority.each do |b|
next unless b.effects[PBEffects::Quash] > 0 && !b.fainted?
next unless @choices[b.index][0]==:UseMove || @choices[b.index][0]==:Shift
next unless @choices[b.index][0] == :UseMove || @choices[b.index][0] == :Shift
next if b.movedThisRound?
advance = b.pbProcessTurn(@choices[b.index])
break if advance
@@ -147,9 +147,9 @@ class Battle
quashLevel += 1
moreQuash = false
priority.each do |b|
moreQuash = true if b.effects[PBEffects::Quash]>quashLevel
next unless b.effects[PBEffects::Quash]==quashLevel && !b.fainted?
next unless @choices[b.index][0]==:UseMove || @choices[b.index][0]==:Shift
moreQuash = true if b.effects[PBEffects::Quash] > quashLevel
next unless b.effects[PBEffects::Quash] == quashLevel && !b.fainted?
next unless @choices[b.index][0] == :UseMove || @choices[b.index][0] == :Shift
next if b.movedThisRound?
advance = b.pbProcessTurn(@choices[b.index])
break
@@ -157,12 +157,12 @@ class Battle
break if advance || !moreQuash
end
end
return if @decision>0
return if @decision > 0
next if advance
# Check for all done
priority.each do |b|
if !b.fainted? && !b.movedThisRound?
advance = true if @choices[b.index][0]==:UseMove || @choices[b.index][0]==:Shift
advance = true if @choices[b.index][0] == :UseMove || @choices[b.index][0] == :Shift
end
break if advance
end
@@ -178,15 +178,15 @@ class Battle
def pbAttackPhase
@scene.pbBeginAttackPhase
# Reset certain effects
@battlers.each_with_index do |b,i|
@battlers.each_with_index do |b, i|
next if !b
b.turnCount += 1 if !b.fainted?
@successStates[i].clear
if @choices[i][0]!=:UseMove && @choices[i][0]!=:Shift && @choices[i][0]!=:SwitchOut
if @choices[i][0] != :UseMove && @choices[i][0] != :Shift && @choices[i][0] != :SwitchOut
b.effects[PBEffects::DestinyBond] = false
b.effects[PBEffects::Grudge] = false
end
b.effects[PBEffects::Rage] = false if !pbChoseMoveFunctionCode?(i,"StartRaiseUserAtk1WhenDamaged")
b.effects[PBEffects::Rage] = false if !pbChoseMoveFunctionCode?(i, "StartRaiseUserAtk1WhenDamaged")
end
PBDebug.log("")
# Calculate move order for this round
@@ -195,9 +195,9 @@ class Battle
pbAttackPhasePriorityChangeMessages
pbAttackPhaseCall
pbAttackPhaseSwitch
return if @decision>0
return if @decision > 0
pbAttackPhaseItems
return if @decision>0
return if @decision > 0
pbAttackPhaseMegaEvolution
pbAttackPhaseMoves
end

View File

@@ -2,27 +2,27 @@ class Battle
#=============================================================================
# Decrement effect counters
#=============================================================================
def pbEORCountDownBattlerEffect(priority,effect)
def pbEORCountDownBattlerEffect(priority, effect)
priority.each do |b|
next if b.fainted? || b.effects[effect]==0
next if b.fainted? || b.effects[effect] == 0
b.effects[effect] -= 1
yield b if block_given? && b.effects[effect]==0
yield b if block_given? && b.effects[effect] == 0
end
end
def pbEORCountDownSideEffect(side,effect,msg)
if @sides[side].effects[effect]>0
def pbEORCountDownSideEffect(side, effect, msg)
if @sides[side].effects[effect] > 0
@sides[side].effects[effect] -= 1
pbDisplay(msg) if @sides[side].effects[effect]==0
pbDisplay(msg) if @sides[side].effects[effect] == 0
end
end
def pbEORCountDownFieldEffect(effect,msg)
if @field.effects[effect]>0
def pbEORCountDownFieldEffect(effect, msg)
if @field.effects[effect] > 0
@field.effects[effect] -= 1
if @field.effects[effect]==0
if @field.effects[effect] == 0
pbDisplay(msg)
if effect==PBEffects::MagicRoom
if effect == PBEffects::MagicRoom
pbPriority(true).each { |b| b.pbItemTerrainStatBoostCheck }
end
end
@@ -36,9 +36,9 @@ class Battle
# NOTE: Primordial weather doesn't need to be checked here, because if it
# could wear off here, it will have worn off already.
# Count down weather duration
@field.weatherDuration -= 1 if @field.weatherDuration>0
@field.weatherDuration -= 1 if @field.weatherDuration > 0
# Weather wears off
if @field.weatherDuration==0
if @field.weatherDuration == 0
case @field.weather
when :Sun then pbDisplay(_INTL("The sunlight faded."))
when :Rain then pbDisplay(_INTL("The rain stopped."))
@@ -50,7 +50,7 @@ class Battle
# Check for form changes caused by the weather changing
allBattlers.each { |b| b.pbCheckFormOnWeatherChange }
# Start up the default weather
pbStartWeather(nil,@field.defaultWeather) if @field.defaultWeather != :None
pbStartWeather(nil, @field.defaultWeather) if @field.defaultWeather != :None
return if @field.weather == :None
end
# Weather continues
@@ -77,23 +77,23 @@ class Battle
case b.effectiveWeather
when :Sandstorm
next if !b.takesSandstormDamage?
pbDisplay(_INTL("{1} is buffeted by the sandstorm!",b.pbThis))
pbDisplay(_INTL("{1} is buffeted by the sandstorm!", b.pbThis))
@scene.pbDamageAnimation(b)
b.pbReduceHP(b.totalhp/16,false)
b.pbReduceHP(b.totalhp / 16, false)
b.pbItemHPHealCheck
b.pbFaint if b.fainted?
when :Hail
next if !b.takesHailDamage?
pbDisplay(_INTL("{1} is buffeted by the hail!",b.pbThis))
pbDisplay(_INTL("{1} is buffeted by the hail!", b.pbThis))
@scene.pbDamageAnimation(b)
b.pbReduceHP(b.totalhp/16,false)
b.pbReduceHP(b.totalhp / 16, false)
b.pbItemHPHealCheck
b.pbFaint if b.fainted?
when :ShadowSky
next if !b.takesShadowSkyDamage?
pbDisplay(_INTL("{1} is hurt by the shadow sky!",b.pbThis))
pbDisplay(_INTL("{1} is hurt by the shadow sky!", b.pbThis))
@scene.pbDamageAnimation(b)
b.pbReduceHP(b.totalhp/16,false)
b.pbReduceHP(b.totalhp / 16, false)
b.pbItemHPHealCheck
b.pbFaint if b.fainted?
end
@@ -105,7 +105,7 @@ class Battle
#=============================================================================
def pbEORTerrain
# Count down terrain duration
@field.terrainDuration -= 1 if @field.terrainDuration>0
@field.terrainDuration -= 1 if @field.terrainDuration > 0
# Terrain wears off
if @field.terrain != :None && @field.terrainDuration == 0
case @field.terrain
@@ -149,7 +149,7 @@ class Battle
if !singleBattle?
swaps = [] # Each element is an array of two battler indices to swap
for side in 0...2
next if pbSideSize(side)==1 # Only battlers on sides of size 2+ need to move
next if pbSideSize(side) == 1 # Only battlers on sides of size 2+ need to move
# Check if any battler on this side is near any battler on the other side
anyNear = false
allSameSideBattlers(side).each do |b|
@@ -170,25 +170,25 @@ class Battle
# Get the position to move to
pos = -1
case pbSideSize(side)
when 2 then pos = [2,3,0,1][b.index] # The unoccupied position
when 3 then pos = (side==0) ? 2 : 3 # The centre position
when 2 then pos = [2, 3, 0, 1][b.index] # The unoccupied position
when 3 then pos = (side == 0) ? 2 : 3 # The centre position
end
next if pos<0
next if pos < 0
# Can't move if the same trainer doesn't control both positions
idxOwner = pbGetOwnerIndexFromBattlerIndex(b.index)
next if pbGetOwnerIndexFromBattlerIndex(pos)!=idxOwner
swaps.push([b.index,pos])
next if pbGetOwnerIndexFromBattlerIndex(pos) != idxOwner
swaps.push([b.index, pos])
end
end
# Move battlers around
swaps.each do |pair|
next if pbSideSize(pair[0])==2 && swaps.length>1
next if !pbSwapBattlers(pair[0],pair[1])
next if pbSideSize(pair[0]) == 2 && swaps.length > 1
next if !pbSwapBattlers(pair[0], pair[1])
case pbSideSize(side)
when 2
pbDisplay(_INTL("{1} moved across!",@battlers[pair[1]].pbThis))
pbDisplay(_INTL("{1} moved across!", @battlers[pair[1]].pbThis))
when 3
pbDisplay(_INTL("{1} moved to the center!",@battlers[pair[1]].pbThis))
pbDisplay(_INTL("{1} moved to the center!", @battlers[pair[1]].pbThis))
end
end
end
@@ -207,36 +207,36 @@ class Battle
# Weather
pbEORWeather(priority)
# Future Sight/Doom Desire
@positions.each_with_index do |pos,idxPos|
next if !pos || pos.effects[PBEffects::FutureSightCounter]==0
@positions.each_with_index do |pos, idxPos|
next if !pos || pos.effects[PBEffects::FutureSightCounter] == 0
pos.effects[PBEffects::FutureSightCounter] -= 1
next if pos.effects[PBEffects::FutureSightCounter]>0
next if pos.effects[PBEffects::FutureSightCounter] > 0
next if !@battlers[idxPos] || @battlers[idxPos].fainted? # No target
moveUser = nil
allBattlers.each do |b|
next if b.opposes?(pos.effects[PBEffects::FutureSightUserIndex])
next if b.pokemonIndex!=pos.effects[PBEffects::FutureSightUserPartyIndex]
next if b.pokemonIndex != pos.effects[PBEffects::FutureSightUserPartyIndex]
moveUser = b
break
end
next if moveUser && moveUser.index==idxPos # Target is the user
next if moveUser && moveUser.index == idxPos # Target is the user
if !moveUser # User isn't in battle, get it from the party
party = pbParty(pos.effects[PBEffects::FutureSightUserIndex])
pkmn = party[pos.effects[PBEffects::FutureSightUserPartyIndex]]
if pkmn && pkmn.able?
moveUser = Battler.new(self,pos.effects[PBEffects::FutureSightUserIndex])
moveUser.pbInitDummyPokemon(pkmn,pos.effects[PBEffects::FutureSightUserPartyIndex])
moveUser = Battler.new(self, pos.effects[PBEffects::FutureSightUserIndex])
moveUser.pbInitDummyPokemon(pkmn, pos.effects[PBEffects::FutureSightUserPartyIndex])
end
end
next if !moveUser # User is fainted
move = pos.effects[PBEffects::FutureSightMove]
pbDisplay(_INTL("{1} took the {2} attack!",@battlers[idxPos].pbThis,
pbDisplay(_INTL("{1} took the {2} attack!", @battlers[idxPos].pbThis,
GameData::Move.get(move).name))
# NOTE: Future Sight failing against the target here doesn't count towards
# Stomping Tantrum.
userLastMoveFailed = moveUser.lastMoveFailed
@futureSight = true
moveUser.pbUseMoveSimple(move,idxPos)
moveUser.pbUseMoveSimple(move, idxPos)
@futureSight = false
moveUser.lastMoveFailed = userLastMoveFailed
@battlers[idxPos].pbFaint if @battlers[idxPos].fainted?
@@ -246,20 +246,20 @@ class Battle
pos.effects[PBEffects::FutureSightUserPartyIndex] = -1
end
# Wish
@positions.each_with_index do |pos,idxPos|
next if !pos || pos.effects[PBEffects::Wish]==0
@positions.each_with_index do |pos, idxPos|
next if !pos || pos.effects[PBEffects::Wish] == 0
pos.effects[PBEffects::Wish] -= 1
next if pos.effects[PBEffects::Wish]>0
next if pos.effects[PBEffects::Wish] > 0
next if !@battlers[idxPos] || !@battlers[idxPos].canHeal?
wishMaker = pbThisEx(idxPos,pos.effects[PBEffects::WishMaker])
wishMaker = pbThisEx(idxPos, pos.effects[PBEffects::WishMaker])
@battlers[idxPos].pbRecoverHP(pos.effects[PBEffects::WishAmount])
pbDisplay(_INTL("{1}'s wish came true!",wishMaker))
pbDisplay(_INTL("{1}'s wish came true!", wishMaker))
end
# Sea of Fire damage (Fire Pledge + Grass Pledge combination)
for side in 0...2
next if sides[side].effects[PBEffects::SeaOfFire]==0
@battle.pbCommonAnimation("SeaOfFire") if side==0
@battle.pbCommonAnimation("SeaOfFireOpp") if side==1
next if sides[side].effects[PBEffects::SeaOfFire] == 0
@battle.pbCommonAnimation("SeaOfFire") if side == 0
@battle.pbCommonAnimation("SeaOfFireOpp") if side == 1
priority.each do |b|
next if b.opposes?(side)
next if !b.takesIndirectDamage? || b.pbHasType?(:FIRE)
@@ -275,8 +275,8 @@ class Battle
# Grassy Terrain (healing)
if @field.terrain == :Grassy && b.affectedByTerrain? && b.canHeal?
PBDebug.log("[Lingering effect] Grassy Terrain heals #{b.pbThis(true)}")
b.pbRecoverHP(b.totalhp/16)
pbDisplay(_INTL("{1}'s HP was restored.",b.pbThis))
b.pbRecoverHP(b.totalhp / 16)
pbDisplay(_INTL("{1}'s HP was restored.", b.pbThis))
end
# Healer, Hydration, Shed Skin
Battle::AbilityEffects.triggerEndOfRoundHealing(b.ability, b, self) if b.abilityActive?
@@ -309,27 +309,27 @@ class Battle
priority.each do |b|
next if !b.effects[PBEffects::AquaRing]
next if !b.canHeal?
hpGain = b.totalhp/16
hpGain = (hpGain*1.3).floor if b.hasActiveItem?(:BIGROOT)
hpGain = b.totalhp / 16
hpGain = (hpGain * 1.3).floor if b.hasActiveItem?(:BIGROOT)
b.pbRecoverHP(hpGain)
pbDisplay(_INTL("Aqua Ring restored {1}'s HP!",b.pbThis(true)))
pbDisplay(_INTL("Aqua Ring restored {1}'s HP!", b.pbThis(true)))
end
# Ingrain
priority.each do |b|
next if !b.effects[PBEffects::Ingrain]
next if !b.canHeal?
hpGain = b.totalhp/16
hpGain = (hpGain*1.3).floor if b.hasActiveItem?(:BIGROOT)
hpGain = b.totalhp / 16
hpGain = (hpGain * 1.3).floor if b.hasActiveItem?(:BIGROOT)
b.pbRecoverHP(hpGain)
pbDisplay(_INTL("{1} absorbed nutrients with its roots!",b.pbThis))
pbDisplay(_INTL("{1} absorbed nutrients with its roots!", b.pbThis))
end
# Leech Seed
priority.each do |b|
next if b.effects[PBEffects::LeechSeed]<0
next if b.effects[PBEffects::LeechSeed] < 0
next if !b.takesIndirectDamage?
recipient = @battlers[b.effects[PBEffects::LeechSeed]]
next if !recipient || recipient.fainted?
pbCommonAnimation("LeechSeed",recipient,b)
pbCommonAnimation("LeechSeed", recipient, b)
b.pbTakeEffectDamage(b.totalhp / 8) { |hp_lost|
recipient.pbRecoverHPFromDrain(hp_lost, b,
_INTL("{1}'s health is sapped by Leech Seed!", b.pbThis))
@@ -339,38 +339,38 @@ class Battle
end
# Damage from Hyper Mode (Shadow Pokémon)
priority.each do |b|
next if !b.inHyperMode? || @choices[b.index][0]!=:UseMove
hpLoss = b.totalhp/24
next if !b.inHyperMode? || @choices[b.index][0] != :UseMove
hpLoss = b.totalhp / 24
@scene.pbDamageAnimation(b)
b.pbReduceHP(hpLoss,false)
pbDisplay(_INTL("The Hyper Mode attack hurts {1}!",b.pbThis(true)))
b.pbReduceHP(hpLoss, false)
pbDisplay(_INTL("The Hyper Mode attack hurts {1}!", b.pbThis(true)))
b.pbFaint if b.fainted?
end
# Damage from poisoning
priority.each do |b|
next if b.fainted?
next if b.status != :POISON
if b.statusCount>0
if b.statusCount > 0
b.effects[PBEffects::Toxic] += 1
b.effects[PBEffects::Toxic] = 16 if b.effects[PBEffects::Toxic]>16
b.effects[PBEffects::Toxic] = 16 if b.effects[PBEffects::Toxic] > 16
end
if b.hasActiveAbility?(:POISONHEAL)
if b.canHeal?
anim_name = GameData::Status.get(:POISON).animation
pbCommonAnimation(anim_name, b) if anim_name
pbShowAbilitySplash(b)
b.pbRecoverHP(b.totalhp/8)
b.pbRecoverHP(b.totalhp / 8)
if Scene::USE_ABILITY_SPLASH
pbDisplay(_INTL("{1}'s HP was restored.",b.pbThis))
pbDisplay(_INTL("{1}'s HP was restored.", b.pbThis))
else
pbDisplay(_INTL("{1}'s {2} restored its HP.",b.pbThis,b.abilityName))
pbDisplay(_INTL("{1}'s {2} restored its HP.", b.pbThis, b.abilityName))
end
pbHideAbilitySplash(b)
end
elsif b.takesIndirectDamage?
b.droppedBelowHalfHP = false
dmg = (b.statusCount==0) ? b.totalhp/8 : b.totalhp*b.effects[PBEffects::Toxic]/16
b.pbContinueStatus { b.pbReduceHP(dmg,false) }
dmg = (b.statusCount == 0) ? b.totalhp / 8 : b.totalhp * b.effects[PBEffects::Toxic] / 16
b.pbContinueStatus { b.pbReduceHP(dmg, false) }
b.pbItemHPHealCheck
b.pbAbilitiesOnDamageTaken
b.pbFaint if b.fainted?
@@ -381,9 +381,9 @@ class Battle
priority.each do |b|
next if b.status != :BURN || !b.takesIndirectDamage?
b.droppedBelowHalfHP = false
dmg = (Settings::MECHANICS_GENERATION >= 7) ? b.totalhp/16 : b.totalhp/8
dmg = (dmg/2.0).round if b.hasActiveAbility?(:HEATPROOF)
b.pbContinueStatus { b.pbReduceHP(dmg,false) }
dmg = (Settings::MECHANICS_GENERATION >= 7) ? b.totalhp / 16 : b.totalhp / 8
dmg = (dmg / 2.0).round if b.hasActiveAbility?(:HEATPROOF)
b.pbContinueStatus { b.pbReduceHP(dmg, false) }
b.pbItemHPHealCheck
b.pbAbilitiesOnDamageTaken
b.pbFaint if b.fainted?
@@ -406,11 +406,11 @@ class Battle
end
# Trapping attacks (Bind/Clamp/Fire Spin/Magma Storm/Sand Tomb/Whirlpool/Wrap)
priority.each do |b|
next if b.fainted? || b.effects[PBEffects::Trapping]==0
next if b.fainted? || b.effects[PBEffects::Trapping] == 0
b.effects[PBEffects::Trapping] -= 1
moveName = GameData::Move.get(b.effects[PBEffects::TrappingMove]).name
if b.effects[PBEffects::Trapping]==0
pbDisplay(_INTL("{1} was freed from {2}!",b.pbThis,moveName))
if b.effects[PBEffects::Trapping] == 0
pbDisplay(_INTL("{1} was freed from {2}!", b.pbThis, moveName))
else
case b.effects[PBEffects::TrappingMove]
when :BIND then pbCommonAnimation("Bind", b)
@@ -423,9 +423,9 @@ class Battle
else pbCommonAnimation("Wrap", b)
end
if b.takesIndirectDamage?
hpLoss = (Settings::MECHANICS_GENERATION >= 6) ? b.totalhp/8 : b.totalhp/16
hpLoss = (Settings::MECHANICS_GENERATION >= 6) ? b.totalhp / 8 : b.totalhp / 16
if @battlers[b.effects[PBEffects::TrappingUser]].hasActiveItem?(:BINDINGBAND)
hpLoss = (Settings::MECHANICS_GENERATION >= 6) ? b.totalhp/6 : b.totalhp/8
hpLoss = (Settings::MECHANICS_GENERATION >= 6) ? b.totalhp / 6 : b.totalhp / 8
end
@scene.pbDamageAnimation(b)
b.pbTakeEffectDamage(hpLoss, false) { |hp_lost|
@@ -443,18 +443,18 @@ class Battle
b.pbItemOnStatDropped
end
# Taunt
pbEORCountDownBattlerEffect(priority,PBEffects::Taunt) { |battler|
pbDisplay(_INTL("{1}'s taunt wore off!",battler.pbThis))
pbEORCountDownBattlerEffect(priority, PBEffects::Taunt) { |battler|
pbDisplay(_INTL("{1}'s taunt wore off!", battler.pbThis))
}
# Encore
priority.each do |b|
next if b.fainted? || b.effects[PBEffects::Encore]==0
next if b.fainted? || b.effects[PBEffects::Encore] == 0
idxEncoreMove = b.pbEncoredMoveIndex
if idxEncoreMove>=0
if idxEncoreMove >= 0
b.effects[PBEffects::Encore] -= 1
if b.effects[PBEffects::Encore]==0 || b.moves[idxEncoreMove].pp==0
if b.effects[PBEffects::Encore] == 0 || b.moves[idxEncoreMove].pp == 0
b.effects[PBEffects::Encore] = 0
pbDisplay(_INTL("{1}'s encore ended!",b.pbThis))
pbDisplay(_INTL("{1}'s encore ended!", b.pbThis))
end
else
PBDebug.log("[End of effect] #{b.pbThis}'s encore ended (encored move no longer known)")
@@ -463,29 +463,29 @@ class Battle
end
end
# Disable/Cursed Body
pbEORCountDownBattlerEffect(priority,PBEffects::Disable) { |battler|
pbEORCountDownBattlerEffect(priority, PBEffects::Disable) { |battler|
battler.effects[PBEffects::DisableMove] = nil
pbDisplay(_INTL("{1} is no longer disabled!",battler.pbThis))
pbDisplay(_INTL("{1} is no longer disabled!", battler.pbThis))
}
# Magnet Rise
pbEORCountDownBattlerEffect(priority,PBEffects::MagnetRise) { |battler|
pbDisplay(_INTL("{1}'s electromagnetism wore off!",battler.pbThis))
pbEORCountDownBattlerEffect(priority, PBEffects::MagnetRise) { |battler|
pbDisplay(_INTL("{1}'s electromagnetism wore off!", battler.pbThis))
}
# Telekinesis
pbEORCountDownBattlerEffect(priority,PBEffects::Telekinesis) { |battler|
pbDisplay(_INTL("{1} was freed from the telekinesis!",battler.pbThis))
pbEORCountDownBattlerEffect(priority, PBEffects::Telekinesis) { |battler|
pbDisplay(_INTL("{1} was freed from the telekinesis!", battler.pbThis))
}
# Heal Block
pbEORCountDownBattlerEffect(priority,PBEffects::HealBlock) { |battler|
pbDisplay(_INTL("{1}'s Heal Block wore off!",battler.pbThis))
pbEORCountDownBattlerEffect(priority, PBEffects::HealBlock) { |battler|
pbDisplay(_INTL("{1}'s Heal Block wore off!", battler.pbThis))
}
# Embargo
pbEORCountDownBattlerEffect(priority,PBEffects::Embargo) { |battler|
pbDisplay(_INTL("{1} can use items again!",battler.pbThis))
pbEORCountDownBattlerEffect(priority, PBEffects::Embargo) { |battler|
pbDisplay(_INTL("{1} can use items again!", battler.pbThis))
battler.pbItemTerrainStatBoostCheck
}
# Yawn
pbEORCountDownBattlerEffect(priority,PBEffects::Yawn) { |battler|
pbEORCountDownBattlerEffect(priority, PBEffects::Yawn) { |battler|
if battler.pbCanSleepYawn?
PBDebug.log("[Lingering effect] #{battler.pbThis} fell asleep because of Yawn")
battler.pbSleep
@@ -494,59 +494,59 @@ class Battle
# Perish Song
perishSongUsers = []
priority.each do |b|
next if b.fainted? || b.effects[PBEffects::PerishSong]==0
next if b.fainted? || b.effects[PBEffects::PerishSong] == 0
b.effects[PBEffects::PerishSong] -= 1
pbDisplay(_INTL("{1}'s perish count fell to {2}!",b.pbThis,b.effects[PBEffects::PerishSong]))
if b.effects[PBEffects::PerishSong]==0
pbDisplay(_INTL("{1}'s perish count fell to {2}!", b.pbThis, b.effects[PBEffects::PerishSong]))
if b.effects[PBEffects::PerishSong] == 0
perishSongUsers.push(b.effects[PBEffects::PerishSongUser])
b.pbReduceHP(b.hp)
end
b.pbItemHPHealCheck
b.pbFaint if b.fainted?
end
if perishSongUsers.length>0
if perishSongUsers.length > 0
# If all remaining Pokemon fainted by a Perish Song triggered by a single side
if (perishSongUsers.find_all { |idxBattler| opposes?(idxBattler) }.length==perishSongUsers.length) ||
(perishSongUsers.find_all { |idxBattler| !opposes?(idxBattler) }.length==perishSongUsers.length)
if (perishSongUsers.find_all { |idxBattler| opposes?(idxBattler) }.length == perishSongUsers.length) ||
(perishSongUsers.find_all { |idxBattler| !opposes?(idxBattler) }.length == perishSongUsers.length)
pbJudgeCheckpoint(@battlers[perishSongUsers[0]])
end
end
# Check for end of battle
if @decision>0
if @decision > 0
pbGainExp
return
end
for side in 0...2
# Reflect
pbEORCountDownSideEffect(side,PBEffects::Reflect,
_INTL("{1}'s Reflect wore off!",@battlers[side].pbTeam))
pbEORCountDownSideEffect(side, PBEffects::Reflect,
_INTL("{1}'s Reflect wore off!", @battlers[side].pbTeam))
# Light Screen
pbEORCountDownSideEffect(side,PBEffects::LightScreen,
_INTL("{1}'s Light Screen wore off!",@battlers[side].pbTeam))
pbEORCountDownSideEffect(side, PBEffects::LightScreen,
_INTL("{1}'s Light Screen wore off!", @battlers[side].pbTeam))
# Safeguard
pbEORCountDownSideEffect(side,PBEffects::Safeguard,
_INTL("{1} is no longer protected by Safeguard!",@battlers[side].pbTeam))
pbEORCountDownSideEffect(side, PBEffects::Safeguard,
_INTL("{1} is no longer protected by Safeguard!", @battlers[side].pbTeam))
# Mist
pbEORCountDownSideEffect(side,PBEffects::Mist,
_INTL("{1} is no longer protected by mist!",@battlers[side].pbTeam))
pbEORCountDownSideEffect(side, PBEffects::Mist,
_INTL("{1} is no longer protected by mist!", @battlers[side].pbTeam))
# Tailwind
pbEORCountDownSideEffect(side,PBEffects::Tailwind,
_INTL("{1}'s Tailwind petered out!",@battlers[side].pbTeam))
pbEORCountDownSideEffect(side, PBEffects::Tailwind,
_INTL("{1}'s Tailwind petered out!", @battlers[side].pbTeam))
# Lucky Chant
pbEORCountDownSideEffect(side,PBEffects::LuckyChant,
_INTL("{1}'s Lucky Chant wore off!",@battlers[side].pbTeam))
pbEORCountDownSideEffect(side, PBEffects::LuckyChant,
_INTL("{1}'s Lucky Chant wore off!", @battlers[side].pbTeam))
# Pledge Rainbow
pbEORCountDownSideEffect(side,PBEffects::Rainbow,
_INTL("The rainbow on {1}'s side disappeared!",@battlers[side].pbTeam(true)))
pbEORCountDownSideEffect(side, PBEffects::Rainbow,
_INTL("The rainbow on {1}'s side disappeared!", @battlers[side].pbTeam(true)))
# Pledge Sea of Fire
pbEORCountDownSideEffect(side,PBEffects::SeaOfFire,
_INTL("The sea of fire around {1} disappeared!",@battlers[side].pbTeam(true)))
pbEORCountDownSideEffect(side, PBEffects::SeaOfFire,
_INTL("The sea of fire around {1} disappeared!", @battlers[side].pbTeam(true)))
# Pledge Swamp
pbEORCountDownSideEffect(side,PBEffects::Swamp,
_INTL("The swamp around {1} disappeared!",@battlers[side].pbTeam(true)))
pbEORCountDownSideEffect(side, PBEffects::Swamp,
_INTL("The swamp around {1} disappeared!", @battlers[side].pbTeam(true)))
# Aurora Veil
pbEORCountDownSideEffect(side,PBEffects::AuroraVeil,
_INTL("{1}'s Aurora Veil wore off!",@battlers[side].pbTeam(true)))
pbEORCountDownSideEffect(side, PBEffects::AuroraVeil,
_INTL("{1}'s Aurora Veil wore off!", @battlers[side].pbTeam(true)))
end
# Trick Room
pbEORCountDownFieldEffect(PBEffects::TrickRoom,
@@ -572,27 +572,27 @@ class Battle
next if b.fainted?
# Hyper Mode (Shadow Pokémon)
if b.inHyperMode?
if pbRandom(100)<10
if pbRandom(100) < 10
b.pokemon.hyper_mode = false
pbDisplay(_INTL("{1} came to its senses!",b.pbThis))
pbDisplay(_INTL("{1} came to its senses!", b.pbThis))
else
pbDisplay(_INTL("{1} is in Hyper Mode!",b.pbThis))
pbDisplay(_INTL("{1} is in Hyper Mode!", b.pbThis))
end
end
# Uproar
if b.effects[PBEffects::Uproar]>0
if b.effects[PBEffects::Uproar] > 0
b.effects[PBEffects::Uproar] -= 1
if b.effects[PBEffects::Uproar]==0
pbDisplay(_INTL("{1} calmed down.",b.pbThis))
if b.effects[PBEffects::Uproar] == 0
pbDisplay(_INTL("{1} calmed down.", b.pbThis))
else
pbDisplay(_INTL("{1} is making an uproar!",b.pbThis))
pbDisplay(_INTL("{1} is making an uproar!", b.pbThis))
end
end
# Slow Start's end message
if b.effects[PBEffects::SlowStart]>0
if b.effects[PBEffects::SlowStart] > 0
b.effects[PBEffects::SlowStart] -= 1
if b.effects[PBEffects::SlowStart]==0
pbDisplay(_INTL("{1} finally got its act together!",b.pbThis))
if b.effects[PBEffects::SlowStart] == 0
pbDisplay(_INTL("{1} finally got its act together!", b.pbThis))
end
end
# Bad Dreams, Moody, Speed Boost
@@ -603,12 +603,12 @@ class Battle
Battle::AbilityEffects.triggerEndOfRoundGainItem(b.ability, b, self) if b.abilityActive?
end
pbGainExp
return if @decision>0
return if @decision > 0
# Form checks
priority.each { |b| b.pbCheckForm(true) }
# Switch Pokémon in if possible
pbEORSwitch
return if @decision>0
return if @decision > 0
# In battles with at least one side of size 3+, move battlers around if none
# are near to any foes
pbEORShiftDistantBattlers
@@ -617,7 +617,7 @@ class Battle
# Reset/count down battler-specific effects (no messages)
allBattlers.each do |b|
b.effects[PBEffects::BanefulBunker] = false
b.effects[PBEffects::Charge] -= 1 if b.effects[PBEffects::Charge]>0
b.effects[PBEffects::Charge] -= 1 if b.effects[PBEffects::Charge] > 0
b.effects[PBEffects::Counter] = -1
b.effects[PBEffects::CounterTarget] = -1
b.effects[PBEffects::Electrify] = false
@@ -627,12 +627,12 @@ class Battle
b.effects[PBEffects::FocusPunch] = false
b.effects[PBEffects::FollowMe] = 0
b.effects[PBEffects::HelpingHand] = false
b.effects[PBEffects::HyperBeam] -= 1 if b.effects[PBEffects::HyperBeam]>0
b.effects[PBEffects::HyperBeam] -= 1 if b.effects[PBEffects::HyperBeam] > 0
b.effects[PBEffects::KingsShield] = false
b.effects[PBEffects::LaserFocus] -= 1 if b.effects[PBEffects::LaserFocus]>0
if b.effects[PBEffects::LockOn]>0 # Also Mind Reader
b.effects[PBEffects::LaserFocus] -= 1 if b.effects[PBEffects::LaserFocus] > 0
if b.effects[PBEffects::LockOn] > 0 # Also Mind Reader
b.effects[PBEffects::LockOn] -= 1
b.effects[PBEffects::LockOnPos] = -1 if b.effects[PBEffects::LockOn]==0
b.effects[PBEffects::LockOnPos] = -1 if b.effects[PBEffects::LockOn] == 0
end
b.effects[PBEffects::MagicBounce] = false
b.effects[PBEffects::MagicCoat] = false
@@ -649,7 +649,7 @@ class Battle
b.effects[PBEffects::Snatch] = 0
b.effects[PBEffects::SpikyShield] = false
b.effects[PBEffects::Spotlight] = 0
b.effects[PBEffects::ThroatChop] -= 1 if b.effects[PBEffects::ThroatChop]>0
b.effects[PBEffects::ThroatChop] -= 1 if b.effects[PBEffects::ThroatChop] > 0
b.lastHPLost = 0
b.lastHPLostFromFoe = 0
b.droppedBelowHalfHP = false
@@ -677,7 +677,7 @@ class Battle
end
# Reset/count down field-specific effects (no messages)
@field.effects[PBEffects::IonDeluge] = false
@field.effects[PBEffects::FairyLock] -= 1 if @field.effects[PBEffects::FairyLock]>0
@field.effects[PBEffects::FairyLock] -= 1 if @field.effects[PBEffects::FairyLock] > 0
@field.effects[PBEffects::FusionBolt] = false
@field.effects[PBEffects::FusionFlare] = false
@endOfRound = false

View File

@@ -82,14 +82,14 @@ class Battle::Battler
end
def defense
return @spdef if @battle.field.effects[PBEffects::WonderRoom]>0
return @spdef if @battle.field.effects[PBEffects::WonderRoom] > 0
return @defense
end
attr_writer :defense
def spdef
return @defense if @battle.field.effects[PBEffects::WonderRoom]>0
return @defense if @battle.field.effects[PBEffects::WonderRoom] > 0
return @spdef
end
@@ -102,7 +102,7 @@ class Battle::Battler
@pokemon.hp = value.to_i if @pokemon
end
def fainted?; return @hp<=0; end
def fainted?; return @hp <= 0; end
attr_reader :status
@@ -211,12 +211,12 @@ class Battle::Battler
def pbThis(lowerCase = false)
if opposes?
if @battle.trainerBattle?
return lowerCase ? _INTL("the opposing {1}",name) : _INTL("The opposing {1}",name)
return lowerCase ? _INTL("the opposing {1}", name) : _INTL("The opposing {1}", name)
else
return lowerCase ? _INTL("the wild {1}",name) : _INTL("The wild {1}",name)
return lowerCase ? _INTL("the wild {1}", name) : _INTL("The wild {1}", name)
end
elsif !pbOwnedByPlayer?
return lowerCase ? _INTL("the ally {1}",name) : _INTL("The ally {1}",name)
return lowerCase ? _INTL("the ally {1}", name) : _INTL("The ally {1}", name)
end
return name
end
@@ -240,10 +240,10 @@ class Battle::Battler
#=============================================================================
def pbSpeed
return 1 if fainted?
stageMul = [2,2,2,2,2,2, 2, 3,4,5,6,7,8]
stageDiv = [8,7,6,5,4,3, 2, 2,2,2,2,2,2]
stageMul = [2, 2, 2, 2, 2, 2, 2, 3, 4, 5, 6, 7, 8]
stageDiv = [8, 7, 6, 5, 4, 3, 2, 2, 2, 2, 2, 2, 2]
stage = @stages[:SPEED] + 6
speed = @speed*stageMul[stage]/stageDiv[stage]
speed = @speed * stageMul[stage] / stageDiv[stage]
speedMult = 1.0
# Ability effects that alter calculated Speed
if abilityActive?
@@ -254,8 +254,8 @@ class Battle::Battler
speedMult = Battle::ItemEffects.triggerSpeedCalc(self.item, self, speedMult)
end
# Other effects
speedMult *= 2 if pbOwnSide.effects[PBEffects::Tailwind]>0
speedMult /= 2 if pbOwnSide.effects[PBEffects::Swamp]>0
speedMult *= 2 if pbOwnSide.effects[PBEffects::Tailwind] > 0
speedMult /= 2 if pbOwnSide.effects[PBEffects::Swamp] > 0
# Paralysis
if status == :PARALYSIS && !hasActiveAbility?(:QUICKFEET)
speedMult /= (Settings::MECHANICS_GENERATION >= 7) ? 2 : 4
@@ -266,20 +266,20 @@ class Battle::Battler
speedMult *= 1.1
end
# Calculation
return [(speed*speedMult).round,1].max
return [(speed * speedMult).round, 1].max
end
def pbWeight
ret = (@pokemon) ? @pokemon.weight : 500
ret += @effects[PBEffects::WeightChange]
ret = 1 if ret<1
ret = 1 if ret < 1
if abilityActive? && !@battle.moldBreaker
ret = Battle::AbilityEffects.triggerWeightCalc(self.ability, self, ret)
end
if itemActive?
ret = Battle::ItemEffects.triggerWeightCalc(self.item, self, ret)
end
return [ret,1].max
return [ret, 1].max
end
#=============================================================================
@@ -415,10 +415,10 @@ class Battle::Battler
def itemActive?(ignoreFainted = false)
return false if fainted? && !ignoreFainted
return false if @effects[PBEffects::Embargo]>0
return false if @battle.field.effects[PBEffects::MagicRoom]>0
return false if @effects[PBEffects::Embargo] > 0
return false if @battle.field.effects[PBEffects::MagicRoom] > 0
return false if @battle.corrosiveGas[@index % 2][@pokemonIndex]
return false if hasActiveAbility?(:KLUTZ,ignoreFainted)
return false if hasActiveAbility?(:KLUTZ, ignoreFainted)
return true
end
@@ -515,9 +515,9 @@ class Battle::Battler
if showMsg
@battle.pbShowAbilitySplash(self)
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} is unaffected!",pbThis))
@battle.pbDisplay(_INTL("{1} is unaffected!", pbThis))
else
@battle.pbDisplay(_INTL("{1} is unaffected because of its {2}!",pbThis,abilityName))
@battle.pbDisplay(_INTL("{1} is unaffected because of its {2}!", pbThis, abilityName))
end
@battle.pbHideAbilitySplash(self)
end
@@ -531,7 +531,7 @@ class Battle::Battler
return false if pbHasType?(:GROUND) || pbHasType?(:ROCK) || pbHasType?(:STEEL)
return false if inTwoTurnAttack?("TwoTurnAttackInvulnerableUnderground",
"TwoTurnAttackInvulnerableUnderwater")
return false if hasActiveAbility?([:OVERCOAT,:SANDFORCE,:SANDRUSH,:SANDVEIL])
return false if hasActiveAbility?([:OVERCOAT, :SANDFORCE, :SANDRUSH, :SANDVEIL])
return false if hasActiveItem?(:SAFETYGOGGLES)
return true
end
@@ -541,7 +541,7 @@ class Battle::Battler
return false if pbHasType?(:ICE)
return false if inTwoTurnAttack?("TwoTurnAttackInvulnerableUnderground",
"TwoTurnAttackInvulnerableUnderwater")
return false if hasActiveAbility?([:OVERCOAT,:ICEBODY,:SNOWCLOAK])
return false if hasActiveAbility?([:OVERCOAT, :ICEBODY, :SNOWCLOAK])
return false if hasActiveItem?(:SAFETYGOGGLES)
return true
end
@@ -561,7 +561,7 @@ class Battle::Battler
def affectedByPowder?(showMsg = false)
return false if fainted?
if pbHasType?(:GRASS) && Settings::MORE_TYPE_EFFECTS
@battle.pbDisplay(_INTL("{1} is unaffected!",pbThis)) if showMsg
@battle.pbDisplay(_INTL("{1} is unaffected!", pbThis)) if showMsg
return false
end
if Settings::MECHANICS_GENERATION >= 6
@@ -569,9 +569,9 @@ class Battle::Battler
if showMsg
@battle.pbShowAbilitySplash(self)
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} is unaffected!",pbThis))
@battle.pbDisplay(_INTL("{1} is unaffected!", pbThis))
else
@battle.pbDisplay(_INTL("{1} is unaffected because of its {2}!",pbThis,abilityName))
@battle.pbDisplay(_INTL("{1} is unaffected because of its {2}!", pbThis, abilityName))
end
@battle.pbHideAbilitySplash(self)
end
@@ -579,7 +579,7 @@ class Battle::Battler
end
if hasActiveItem?(:SAFETYGOGGLES)
if showMsg
@battle.pbDisplay(_INTL("{1} is unaffected because of its {2}!",pbThis,itemName))
@battle.pbDisplay(_INTL("{1} is unaffected because of its {2}!", pbThis, itemName))
end
return false
end
@@ -588,15 +588,15 @@ class Battle::Battler
end
def canHeal?
return false if fainted? || @hp>=@totalhp
return false if @effects[PBEffects::HealBlock]>0
return false if fainted? || @hp >= @totalhp
return false if @effects[PBEffects::HealBlock] > 0
return true
end
def affectedByContactEffect?(showMsg = false)
return false if fainted?
if hasActiveItem?(:PROTECTIVEPADS)
@battle.pbDisplay(_INTL("{1} protected itself with the {2}!",pbThis,itemName)) if showMsg
@battle.pbDisplay(_INTL("{1} protected itself with the {2}!", pbThis, itemName)) if showMsg
return false
end
return true
@@ -615,23 +615,23 @@ class Battle::Battler
end
def movedThisRound?
return @lastRoundMoved && @lastRoundMoved==@battle.turnCount
return @lastRoundMoved && @lastRoundMoved == @battle.turnCount
end
def usingMultiTurnAttack?
return true if @effects[PBEffects::TwoTurnAttack]
return true if @effects[PBEffects::HyperBeam]>0
return true if @effects[PBEffects::Rollout]>0
return true if @effects[PBEffects::Outrage]>0
return true if @effects[PBEffects::Uproar]>0
return true if @effects[PBEffects::Bide]>0
return true if @effects[PBEffects::HyperBeam] > 0
return true if @effects[PBEffects::Rollout] > 0
return true if @effects[PBEffects::Outrage] > 0
return true if @effects[PBEffects::Uproar] > 0
return true if @effects[PBEffects::Bide] > 0
return false
end
def inTwoTurnAttack?(*arg)
return false if !@effects[PBEffects::TwoTurnAttack]
ttaFunction = GameData::Move.get(@effects[PBEffects::TwoTurnAttack]).function_code
arg.each { |a| return true if a==ttaFunction }
arg.each { |a| return true if a == ttaFunction }
return false
end
@@ -645,10 +645,10 @@ class Battle::Battler
end
def pbEncoredMoveIndex
return -1 if @effects[PBEffects::Encore]==0 || !@effects[PBEffects::EncoreMove]
return -1 if @effects[PBEffects::Encore] == 0 || !@effects[PBEffects::EncoreMove]
ret = -1
eachMoveWithIndex do |m,i|
next if m.id!=@effects[PBEffects::EncoreMove]
eachMoveWithIndex do |m, i|
next if m.id != @effects[PBEffects::EncoreMove]
ret = i
break
end
@@ -656,31 +656,31 @@ class Battle::Battler
end
def initialItem
return @battle.initialItems[@index&1][@pokemonIndex]
return @battle.initialItems[@index & 1][@pokemonIndex]
end
def setInitialItem(value)
item_data = GameData::Item.try_get(value)
new_item = (item_data) ? item_data.id : nil
@battle.initialItems[@index&1][@pokemonIndex] = new_item
@battle.initialItems[@index & 1][@pokemonIndex] = new_item
end
def recycleItem
return @battle.recycleItems[@index&1][@pokemonIndex]
return @battle.recycleItems[@index & 1][@pokemonIndex]
end
def setRecycleItem(value)
item_data = GameData::Item.try_get(value)
new_item = (item_data) ? item_data.id : nil
@battle.recycleItems[@index&1][@pokemonIndex] = new_item
@battle.recycleItems[@index & 1][@pokemonIndex] = new_item
end
def belched?
return @battle.belch[@index&1][@pokemonIndex]
return @battle.belch[@index & 1][@pokemonIndex]
end
def setBelched
@battle.belch[@index&1][@pokemonIndex] = true
@battle.belch[@index & 1][@pokemonIndex] = true
end
#=============================================================================
@@ -689,13 +689,13 @@ class Battle::Battler
# Returns whether the given position belongs to the opposing Pokémon's side.
def opposes?(i = 0)
i = i.index if i.respond_to?("index")
return (@index&1)!=(i&1)
return (@index & 1) != (i & 1)
end
# Returns whether the given position/battler is near to self.
def near?(i)
i = i.index if i.respond_to?("index")
return @battle.nearBattlers?(@index,i)
return @battle.nearBattlers?(@index, i)
end
# Returns whether self is owned by the player.
@@ -710,13 +710,13 @@ class Battle::Battler
# Returns 0 if self is on the player's side, or 1 if self is on the opposing
# side.
def idxOwnSide
return @index&1
return @index & 1
end
# Returns 1 if self is on the player's side, or 0 if self is on the opposing
# side.
def idxOpposingSide
return (@index&1)^1
return (@index & 1) ^ 1
end
# Returns the data structure for this battler's side.
@@ -733,7 +733,7 @@ class Battle::Battler
# Unused
def eachAlly
@battle.battlers.each do |b|
yield b if b && !b.fainted? && !b.opposes?(@index) && b.index!=@index
yield b if b && !b.fainted? && !b.opposes?(@index) && b.index != @index
end
end
@@ -766,6 +766,6 @@ class Battle::Battler
@battle.pbGetOpposingIndicesInOrder(@index).each do |i|
return @battle.battlers[i] if @battle.battlers[i]
end
return @battle.battlers[(@index^1)]
return @battle.battlers[(@index ^ 1)]
end
end

View File

@@ -2,7 +2,7 @@ class Battle::Battler
#=============================================================================
# Creating a battler
#=============================================================================
def initialize(btl,idxBattler)
def initialize(btl, idxBattler)
@battle = btl
@index = idxBattler
@captured = false
@@ -33,7 +33,7 @@ class Battle::Battler
end
# Used by Future Sight only, when Future Sight's user is no longer in battle.
def pbInitDummyPokemon(pkmn,idxParty)
def pbInitDummyPokemon(pkmn, idxParty)
raise _INTL("An egg can't be an active Pokémon.") if pkmn.egg?
@name = pkmn.name
@species = pkmn.species
@@ -57,13 +57,13 @@ class Battle::Battler
@dummy = true
end
def pbInitialize(pkmn,idxParty,batonPass = false)
pbInitPokemon(pkmn,idxParty)
def pbInitialize(pkmn, idxParty, batonPass = false)
pbInitPokemon(pkmn, idxParty)
pbInitEffects(batonPass)
@damageState.reset
end
def pbInitPokemon(pkmn,idxParty)
def pbInitPokemon(pkmn, idxParty)
raise _INTL("An egg can't be an active Pokémon.") if pkmn.egg?
@name = pkmn.name
@species = pkmn.species
@@ -85,8 +85,8 @@ class Battle::Battler
@pokemonIndex = idxParty
@participants = [] # Participants earn Exp. if this battler is defeated
@moves = []
pkmn.moves.each_with_index do |m,i|
@moves[i] = Battle::Move.from_pokemon_move(@battle,m)
pkmn.moves.each_with_index do |m, i|
@moves[i] = Battle::Move.from_pokemon_move(@battle, m)
end
end
@@ -94,10 +94,10 @@ class Battle::Battler
if batonPass
# These effects are passed on if Baton Pass is used, but they need to be
# reapplied
@effects[PBEffects::LaserFocus] = (@effects[PBEffects::LaserFocus]>0) ? 2 : 0
@effects[PBEffects::LockOn] = (@effects[PBEffects::LockOn]>0) ? 2 : 0
@effects[PBEffects::LaserFocus] = (@effects[PBEffects::LaserFocus] > 0) ? 2 : 0
@effects[PBEffects::LockOn] = (@effects[PBEffects::LockOn] > 0) ? 2 : 0
if @effects[PBEffects::PowerTrick]
@attack,@defense = @defense,@attack
@attack, @defense = @defense, @attack
end
# These effects are passed on if Baton Pass is used, but they need to be
# cancelled in certain circumstances anyway
@@ -131,7 +131,7 @@ class Battle::Battler
@effects[PBEffects::Substitute] = 0
@effects[PBEffects::Telekinesis] = 0
end
@fainted = (@hp==0)
@fainted = (@hp == 0)
@lastAttacker = []
@lastFoeAttacker = []
@lastHPLost = 0
@@ -154,7 +154,7 @@ class Battle::Battler
@turnCount = 0
@effects[PBEffects::Attract] = -1
@battle.allBattlers.each do |b| # Other battlers no longer attracted to self
b.effects[PBEffects::Attract] = -1 if b.effects[PBEffects::Attract]==@index
b.effects[PBEffects::Attract] = -1 if b.effects[PBEffects::Attract] == @index
end
@effects[PBEffects::BanefulBunker] = false
@effects[PBEffects::BeakBlast] = false
@@ -204,8 +204,8 @@ class Battle::Battler
end
@effects[PBEffects::KingsShield] = false
@battle.allBattlers.each do |b| # Other battlers lose their lock-on against self
next if b.effects[PBEffects::LockOn]==0
next if b.effects[PBEffects::LockOnPos]!=@index
next if b.effects[PBEffects::LockOn] == 0
next if b.effects[PBEffects::LockOnPos] != @index
b.effects[PBEffects::LockOn] = 0
b.effects[PBEffects::LockOnPos] = -1
end
@@ -213,7 +213,7 @@ class Battle::Battler
@effects[PBEffects::MagicCoat] = false
@effects[PBEffects::MeanLook] = -1
@battle.allBattlers.each do |b| # Other battlers no longer blocked by self
b.effects[PBEffects::MeanLook] = -1 if b.effects[PBEffects::MeanLook]==@index
b.effects[PBEffects::MeanLook] = -1 if b.effects[PBEffects::MeanLook] == @index
end
@effects[PBEffects::MeFirst] = false
@effects[PBEffects::Metronome] = 0
@@ -250,7 +250,7 @@ class Battle::Battler
@effects[PBEffects::Roost] = false
@effects[PBEffects::SkyDrop] = -1
@battle.allBattlers.each do |b| # Other battlers no longer Sky Dropped by self
b.effects[PBEffects::SkyDrop] = -1 if b.effects[PBEffects::SkyDrop]==@index
b.effects[PBEffects::SkyDrop] = -1 if b.effects[PBEffects::SkyDrop] == @index
end
@effects[PBEffects::SlowStart] = 0
@effects[PBEffects::SmackDown] = false
@@ -271,7 +271,7 @@ class Battle::Battler
@effects[PBEffects::TrappingMove] = nil
@effects[PBEffects::TrappingUser] = -1
@battle.allBattlers.each do |b| # Other battlers no longer trapped by self
next if b.effects[PBEffects::TrappingUser]!=@index
next if b.effects[PBEffects::TrappingUser] != @index
b.effects[PBEffects::Trapping] = 0
b.effects[PBEffects::TrappingUser] = -1
end

View File

@@ -2,16 +2,16 @@ class Battle::Battler
#=============================================================================
# Change HP
#=============================================================================
def pbReduceHP(amt,anim = true,registerDamage = true,anyAnim = true)
def pbReduceHP(amt, anim = true, registerDamage = true, anyAnim = true)
amt = amt.round
amt = @hp if amt>@hp
amt = 1 if amt<1 && !fainted?
amt = @hp if amt > @hp
amt = 1 if amt < 1 && !fainted?
oldHP = @hp
self.hp -= amt
PBDebug.log("[HP change] #{pbThis} lost #{amt} HP (#{oldHP}=>#{@hp})") if amt>0
raise _INTL("HP less than 0") if @hp<0
raise _INTL("HP greater than total HP") if @hp>@totalhp
@battle.scene.pbHPChanged(self,oldHP,anim) if anyAnim && amt>0
PBDebug.log("[HP change] #{pbThis} lost #{amt} HP (#{oldHP}=>#{@hp})") if amt > 0
raise _INTL("HP less than 0") if @hp < 0
raise _INTL("HP greater than total HP") if @hp > @totalhp
@battle.scene.pbHPChanged(self, oldHP, anim) if anyAnim && amt > 0
if amt > 0 && registerDamage
@droppedBelowHalfHP = true if @hp < @totalhp / 2 && @hp + amt >= @totalhp / 2
@tookDamageThisRound = true
@@ -19,32 +19,32 @@ class Battle::Battler
return amt
end
def pbRecoverHP(amt,anim = true,anyAnim = true)
def pbRecoverHP(amt, anim = true, anyAnim = true)
amt = amt.round
amt = @totalhp-@hp if amt>@totalhp-@hp
amt = 1 if amt<1 && @hp<@totalhp
amt = @totalhp - @hp if amt > @totalhp - @hp
amt = 1 if amt < 1 && @hp < @totalhp
oldHP = @hp
self.hp += amt
PBDebug.log("[HP change] #{pbThis} gained #{amt} HP (#{oldHP}=>#{@hp})") if amt>0
raise _INTL("HP less than 0") if @hp<0
raise _INTL("HP greater than total HP") if @hp>@totalhp
@battle.scene.pbHPChanged(self,oldHP,anim) if anyAnim && amt>0
PBDebug.log("[HP change] #{pbThis} gained #{amt} HP (#{oldHP}=>#{@hp})") if amt > 0
raise _INTL("HP less than 0") if @hp < 0
raise _INTL("HP greater than total HP") if @hp > @totalhp
@battle.scene.pbHPChanged(self, oldHP, anim) if anyAnim && amt > 0
@droppedBelowHalfHP = false if @hp >= @totalhp / 2
return amt
end
def pbRecoverHPFromDrain(amt,target,msg = nil)
def pbRecoverHPFromDrain(amt, target, msg = nil)
if target.hasActiveAbility?(:LIQUIDOOZE)
@battle.pbShowAbilitySplash(target)
pbReduceHP(amt)
@battle.pbDisplay(_INTL("{1} sucked up the liquid ooze!",pbThis))
@battle.pbDisplay(_INTL("{1} sucked up the liquid ooze!", pbThis))
@battle.pbHideAbilitySplash(target)
pbItemHPHealCheck
else
msg = _INTL("{1} had its energy drained!",target.pbThis) if nil_or_empty?(msg)
msg = _INTL("{1} had its energy drained!", target.pbThis) if nil_or_empty?(msg)
@battle.pbDisplay(msg)
if canHeal?
amt = (amt*1.3).floor if hasActiveItem?(:BIGROOT)
amt = (amt * 1.3).floor if hasActiveItem?(:BIGROOT)
pbRecoverHP(amt)
end
end
@@ -66,7 +66,7 @@ class Battle::Battler
return
end
return if @fainted # Has already fainted properly
@battle.pbDisplayBrief(_INTL("{1} fainted!",pbThis)) if showMessage
@battle.pbDisplayBrief(_INTL("{1} fainted!", pbThis)) if showMessage
PBDebug.log("[Pokémon fainted] #{pbThis} (#{@index})") if !showMessage
@battle.scene.pbFaintBattler(self)
@battle.pbSetDefeated(self) if opposes?
@@ -80,7 +80,7 @@ class Battle::Battler
@pokemon.changeHappiness((badLoss) ? "faintbad" : "faint")
end
# Reset form
@battle.peer.pbOnLeavingBattle(@battle,@pokemon,@battle.usedInBattle[idxOwnSide][@index/2])
@battle.peer.pbOnLeavingBattle(@battle, @pokemon, @battle.usedInBattle[idxOwnSide][@index / 2])
@pokemon.makeUnmega if mega?
@pokemon.makeUnprimal if primal?
# Do other things
@@ -98,26 +98,26 @@ class Battle::Battler
#=============================================================================
# Move PP
#=============================================================================
def pbSetPP(move,pp)
def pbSetPP(move, pp)
move.pp = pp
# No need to care about @effects[PBEffects::Mimic], since Mimic can't copy
# Mimic
if move.realMove && move.id==move.realMove.id && !@effects[PBEffects::Transform]
if move.realMove && move.id == move.realMove.id && !@effects[PBEffects::Transform]
move.realMove.pp = pp
end
end
def pbReducePP(move)
return true if usingMultiTurnAttack?
return true if move.pp<0 # Don't reduce PP for special calls of moves
return true if move.total_pp<=0 # Infinite PP, can always be used
return false if move.pp==0 # Ran out of PP, couldn't reduce
pbSetPP(move,move.pp-1) if move.pp>0
return true if move.pp < 0 # Don't reduce PP for special calls of moves
return true if move.total_pp <= 0 # Infinite PP, can always be used
return false if move.pp == 0 # Ran out of PP, couldn't reduce
pbSetPP(move, move.pp - 1) if move.pp > 0
return true
end
def pbReducePPOther(move)
pbSetPP(move,move.pp-1) if move.pp>0
pbSetPP(move, move.pp - 1) if move.pp > 0
end
#=============================================================================
@@ -150,17 +150,17 @@ class Battle::Battler
#=============================================================================
# Forms
#=============================================================================
def pbChangeForm(newForm,msg)
return if fainted? || @effects[PBEffects::Transform] || @form==newForm
def pbChangeForm(newForm, msg)
return if fainted? || @effects[PBEffects::Transform] || @form == newForm
oldForm = @form
oldDmg = @totalhp-@hp
oldDmg = @totalhp - @hp
self.form = newForm
pbUpdate(true)
@hp = @totalhp-oldDmg
@hp = @totalhp - oldDmg
@effects[PBEffects::WeightChange] = 0 if Settings::MECHANICS_GENERATION >= 6
@battle.scene.pbChangePokemon(self,@pokemon)
@battle.scene.pbChangePokemon(self, @pokemon)
@battle.scene.pbRefreshOne(@index)
@battle.pbDisplay(msg) if msg && msg!=""
@battle.pbDisplay(msg) if msg && msg != ""
PBDebug.log("[Form changed] #{pbThis} changed from form #{oldForm} to form #{newForm}")
@battle.pbSetSeen(self)
end
@@ -169,7 +169,7 @@ class Battle::Battler
return if fainted? || @effects[PBEffects::Transform]
# Shaymin - reverts if frozen
if isSpecies?(:SHAYMIN) && frozen?
pbChangeForm(0,_INTL("{1} transformed!",pbThis))
pbChangeForm(0, _INTL("{1} transformed!", pbThis))
end
end
@@ -179,7 +179,7 @@ class Battle::Battler
if isSpecies?(:KELDEO)
newForm = 0
newForm = 1 if pbHasMove?(:SECRETSWORD)
pbChangeForm(newForm,_INTL("{1} transformed!",pbThis))
pbChangeForm(newForm, _INTL("{1} transformed!", pbThis))
end
end
@@ -194,13 +194,13 @@ class Battle::Battler
when :Rain, :HeavyRain then newForm = 2
when :Hail then newForm = 3
end
if @form!=newForm
@battle.pbShowAbilitySplash(self,true)
if @form != newForm
@battle.pbShowAbilitySplash(self, true)
@battle.pbHideAbilitySplash(self)
pbChangeForm(newForm,_INTL("{1} transformed!",pbThis))
pbChangeForm(newForm, _INTL("{1} transformed!", pbThis))
end
else
pbChangeForm(0,_INTL("{1} transformed!",pbThis))
pbChangeForm(0, _INTL("{1} transformed!", pbThis))
end
end
# Cherrim - Flower Gift
@@ -208,13 +208,13 @@ class Battle::Battler
if hasActiveAbility?(:FLOWERGIFT)
newForm = 0
newForm = 1 if [:Sun, :HarshSun].include?(effectiveWeather)
if @form!=newForm
@battle.pbShowAbilitySplash(self,true)
if @form != newForm
@battle.pbShowAbilitySplash(self, true)
@battle.pbHideAbilitySplash(self)
pbChangeForm(newForm,_INTL("{1} transformed!",pbThis))
pbChangeForm(newForm, _INTL("{1} transformed!", pbThis))
end
else
pbChangeForm(0,_INTL("{1} transformed!",pbThis))
pbChangeForm(0, _INTL("{1} transformed!", pbThis))
end
end
# Eiscue - Ice Face
@@ -233,57 +233,57 @@ class Battle::Battler
pbCheckFormOnWeatherChange if !endOfRound
# Darmanitan - Zen Mode
if isSpecies?(:DARMANITAN) && self.ability == :ZENMODE
if @hp<=@totalhp/2
if @hp <= @totalhp / 2
if (@form % 2) == 0
@battle.pbShowAbilitySplash(self,true)
@battle.pbShowAbilitySplash(self, true)
@battle.pbHideAbilitySplash(self)
pbChangeForm(@form + 1, _INTL("{1} triggered!", abilityName))
end
elsif (@form % 2) != 0
@battle.pbShowAbilitySplash(self,true)
@battle.pbShowAbilitySplash(self, true)
@battle.pbHideAbilitySplash(self)
pbChangeForm(@form - 1, _INTL("{1} triggered!", abilityName))
end
end
# Minior - Shields Down
if isSpecies?(:MINIOR) && self.ability == :SHIELDSDOWN
if @hp>@totalhp/2 # Turn into Meteor form
newForm = (@form>=7) ? @form-7 : @form
if @form!=newForm
@battle.pbShowAbilitySplash(self,true)
if @hp > @totalhp / 2 # Turn into Meteor form
newForm = (@form >= 7) ? @form - 7 : @form
if @form != newForm
@battle.pbShowAbilitySplash(self, true)
@battle.pbHideAbilitySplash(self)
pbChangeForm(newForm,_INTL("{1} deactivated!",abilityName))
pbChangeForm(newForm, _INTL("{1} deactivated!", abilityName))
elsif !endOfRound
@battle.pbDisplay(_INTL("{1} deactivated!",abilityName))
@battle.pbDisplay(_INTL("{1} deactivated!", abilityName))
end
elsif @form<7 # Turn into Core form
@battle.pbShowAbilitySplash(self,true)
elsif @form < 7 # Turn into Core form
@battle.pbShowAbilitySplash(self, true)
@battle.pbHideAbilitySplash(self)
pbChangeForm(@form+7,_INTL("{1} activated!",abilityName))
pbChangeForm(@form + 7, _INTL("{1} activated!", abilityName))
end
end
# Wishiwashi - Schooling
if isSpecies?(:WISHIWASHI) && self.ability == :SCHOOLING
if @level>=20 && @hp>@totalhp/4
if @form!=1
@battle.pbShowAbilitySplash(self,true)
if @level >= 20 && @hp > @totalhp / 4
if @form != 1
@battle.pbShowAbilitySplash(self, true)
@battle.pbHideAbilitySplash(self)
pbChangeForm(1,_INTL("{1} formed a school!",pbThis))
pbChangeForm(1, _INTL("{1} formed a school!", pbThis))
end
elsif @form!=0
@battle.pbShowAbilitySplash(self,true)
elsif @form != 0
@battle.pbShowAbilitySplash(self, true)
@battle.pbHideAbilitySplash(self)
pbChangeForm(0,_INTL("{1} stopped schooling!",pbThis))
pbChangeForm(0, _INTL("{1} stopped schooling!", pbThis))
end
end
# Zygarde - Power Construct
if isSpecies?(:ZYGARDE) && self.ability == :POWERCONSTRUCT && endOfRound
if @hp<=@totalhp/2 && @form<2 # Turn into Complete Forme
newForm = @form+2
if @hp <= @totalhp / 2 && @form < 2 # Turn into Complete Forme
newForm = @form + 2
@battle.pbDisplay(_INTL("You sense the presence of many!"))
@battle.pbShowAbilitySplash(self,true)
@battle.pbShowAbilitySplash(self, true)
@battle.pbHideAbilitySplash(self)
pbChangeForm(newForm,_INTL("{1} transformed into its Complete Forme!",pbThis))
pbChangeForm(newForm, _INTL("{1} transformed into its Complete Forme!", pbThis))
end
end
# Morpeko - Hunger Switch
@@ -311,7 +311,7 @@ class Battle::Battler
@effects[PBEffects::LaserFocus] = target.effects[PBEffects::LaserFocus]
end
@moves.clear
target.moves.each_with_index do |m,i|
target.moves.each_with_index do |m, i|
@moves[i] = Battle::Move.from_pokemon_move(@battle, Pokemon::Move.new(m.id))
@moves[i].pp = 5
@moves[i].total_pp = 5
@@ -320,7 +320,7 @@ class Battle::Battler
@effects[PBEffects::DisableMove] = nil
@effects[PBEffects::WeightChange] = target.effects[PBEffects::WeightChange]
@battle.scene.pbRefreshOne(@index)
@battle.pbDisplay(_INTL("{1} transformed into {2}!",pbThis,target.pbThis(true)))
@battle.pbDisplay(_INTL("{1} transformed into {2}!", pbThis, target.pbThis(true)))
pbOnLosingAbility(oldAbil)
end

View File

@@ -12,7 +12,7 @@ class Battle::Battler
if Battle::AbilityEffects.triggerStatusCheckNonIgnorable(self.ability, self, checkStatus)
return true
end
return @status==checkStatus
return @status == checkStatus
end
def pbHasAnyStatus?
@@ -22,11 +22,11 @@ class Battle::Battler
return @status != :NONE
end
def pbCanInflictStatus?(newStatus,user,showMessages,move = nil,ignoreStatus = false)
def pbCanInflictStatus?(newStatus, user, showMessages, move = nil, ignoreStatus = false)
return false if fainted?
selfInflicted = (user && user.index==@index)
selfInflicted = (user && user.index == @index)
# Already have that status problem
if self.status==newStatus && !ignoreStatus
if self.status == newStatus && !ignoreStatus
if showMessages
msg = ""
case self.status
@@ -42,18 +42,18 @@ class Battle::Battler
end
# Trying to replace a status problem with another one
if self.status != :NONE && !ignoreStatus && !selfInflicted
@battle.pbDisplay(_INTL("It doesn't affect {1}...",pbThis(true))) if showMessages
@battle.pbDisplay(_INTL("It doesn't affect {1}...", pbThis(true))) if showMessages
return false
end
# Trying to inflict a status problem on a Pokémon behind a substitute
if @effects[PBEffects::Substitute]>0 && !(move && move.ignoresSubstitute?(user)) &&
if @effects[PBEffects::Substitute] > 0 && !(move && move.ignoresSubstitute?(user)) &&
!selfInflicted
@battle.pbDisplay(_INTL("It doesn't affect {1}...",pbThis(true))) if showMessages
@battle.pbDisplay(_INTL("It doesn't affect {1}...", pbThis(true))) if showMessages
return false
end
# Weather immunity
if newStatus == :FROZEN && [:Sun, :HarshSun].include?(effectiveWeather)
@battle.pbDisplay(_INTL("It doesn't affect {1}...",pbThis(true))) if showMessages
@battle.pbDisplay(_INTL("It doesn't affect {1}...", pbThis(true))) if showMessages
return false
end
# Terrains immunity
@@ -66,15 +66,15 @@ class Battle::Battler
return false
end
when :Misty
@battle.pbDisplay(_INTL("{1} surrounds itself with misty terrain!",pbThis(true))) if showMessages
@battle.pbDisplay(_INTL("{1} surrounds itself with misty terrain!", pbThis(true))) if showMessages
return false
end
end
# Uproar immunity
if newStatus == :SLEEP && !(hasActiveAbility?(:SOUNDPROOF) && !@battle.moldBreaker)
@battle.allBattlers.each do |b|
next if b.effects[PBEffects::Uproar]==0
@battle.pbDisplay(_INTL("But the uproar kept {1} awake!",pbThis(true))) if showMessages
next if b.effects[PBEffects::Uproar] == 0
@battle.pbDisplay(_INTL("But the uproar kept {1} awake!", pbThis(true))) if showMessages
return false
end
end
@@ -96,7 +96,7 @@ class Battle::Battler
hasImmuneType |= pbHasType?(:ICE)
end
if hasImmuneType
@battle.pbDisplay(_INTL("It doesn't affect {1}...",pbThis(true))) if showMessages
@battle.pbDisplay(_INTL("It doesn't affect {1}...", pbThis(true))) if showMessages
return false
end
# Ability immunity
@@ -133,19 +133,19 @@ class Battle::Battler
case newStatus
when :SLEEP
msg = _INTL("{1} stays awake because of {2}'s {3}!",
pbThis,immAlly.pbThis(true),immAlly.abilityName)
pbThis, immAlly.pbThis(true), immAlly.abilityName)
when :POISON
msg = _INTL("{1} cannot be poisoned because of {2}'s {3}!",
pbThis,immAlly.pbThis(true),immAlly.abilityName)
pbThis, immAlly.pbThis(true), immAlly.abilityName)
when :BURN
msg = _INTL("{1} cannot be burned because of {2}'s {3}!",
pbThis,immAlly.pbThis(true),immAlly.abilityName)
pbThis, immAlly.pbThis(true), immAlly.abilityName)
when :PARALYSIS
msg = _INTL("{1} cannot be paralyzed because of {2}'s {3}!",
pbThis,immAlly.pbThis(true),immAlly.abilityName)
pbThis, immAlly.pbThis(true), immAlly.abilityName)
when :FROZEN
msg = _INTL("{1} cannot be frozen solid because of {2}'s {3}!",
pbThis,immAlly.pbThis(true),immAlly.abilityName)
pbThis, immAlly.pbThis(true), immAlly.abilityName)
end
else
case newStatus
@@ -162,15 +162,15 @@ class Battle::Battler
return false
end
# Safeguard immunity
if pbOwnSide.effects[PBEffects::Safeguard]>0 && !selfInflicted && move &&
if pbOwnSide.effects[PBEffects::Safeguard] > 0 && !selfInflicted && move &&
!(user && user.hasActiveAbility?(:INFILTRATOR))
@battle.pbDisplay(_INTL("{1}'s team is protected by Safeguard!",pbThis)) if showMessages
@battle.pbDisplay(_INTL("{1}'s team is protected by Safeguard!", pbThis)) if showMessages
return false
end
return true
end
def pbCanSynchronizeStatus?(newStatus,target)
def pbCanSynchronizeStatus?(newStatus, target)
return false if fainted?
# Trying to replace a status problem with another one
return false if self.status != :NONE
@@ -204,7 +204,7 @@ class Battle::Battler
return false
end
# Safeguard immunity
if pbOwnSide.effects[PBEffects::Safeguard]>0 &&
if pbOwnSide.effects[PBEffects::Safeguard] > 0 &&
!(user && user.hasActiveAbility?(:INFILTRATOR))
return false
end
@@ -214,7 +214,7 @@ class Battle::Battler
#=============================================================================
# Generalised infliction of status problem
#=============================================================================
def pbInflictStatus(newStatus,newStatusCount = 0,msg = nil,user = nil)
def pbInflictStatus(newStatus, newStatusCount = 0, msg = nil, user = nil)
# Inflict the new status
self.status = newStatus
self.statusCount = newStatusCount
@@ -234,7 +234,7 @@ class Battle::Battler
when :SLEEP
@battle.pbDisplay(_INTL("{1} fell asleep!", pbThis))
when :POISON
if newStatusCount>0
if newStatusCount > 0
@battle.pbDisplay(_INTL("{1} was badly poisoned!", pbThis))
else
@battle.pbDisplay(_INTL("{1} was poisoned!", pbThis))
@@ -304,7 +304,7 @@ class Battle::Battler
# NOTE: Bulbapedia claims that Safeguard shouldn't prevent sleep due to
# drowsiness. I disagree with this too. Compare with the other sided
# effects Misty/Electric Terrain, which do prevent it.
return false if pbOwnSide.effects[PBEffects::Safeguard]>0
return false if pbOwnSide.effects[PBEffects::Safeguard] > 0
return true
end
@@ -438,20 +438,20 @@ class Battle::Battler
#=============================================================================
# Confusion
#=============================================================================
def pbCanConfuse?(user = nil,showMessages = true,move = nil,selfInflicted = false)
def pbCanConfuse?(user = nil, showMessages = true, move = nil, selfInflicted = false)
return false if fainted?
if @effects[PBEffects::Confusion]>0
@battle.pbDisplay(_INTL("{1} is already confused.",pbThis)) if showMessages
if @effects[PBEffects::Confusion] > 0
@battle.pbDisplay(_INTL("{1} is already confused.", pbThis)) if showMessages
return false
end
if @effects[PBEffects::Substitute]>0 && !(move && move.ignoresSubstitute?(user)) &&
if @effects[PBEffects::Substitute] > 0 && !(move && move.ignoresSubstitute?(user)) &&
!selfInflicted
@battle.pbDisplay(_INTL("But it failed!")) if showMessages
return false
end
# Terrains immunity
if affectedByTerrain? && @battle.field.terrain == :Misty && Settings::MECHANICS_GENERATION >= 7
@battle.pbDisplay(_INTL("{1} surrounds itself with misty terrain!",pbThis(true))) if showMessages
@battle.pbDisplay(_INTL("{1} surrounds itself with misty terrain!", pbThis(true))) if showMessages
return false
end
if selfInflicted || !@battle.moldBreaker
@@ -459,31 +459,31 @@ class Battle::Battler
if showMessages
@battle.pbShowAbilitySplash(self)
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} doesn't become confused!",pbThis))
@battle.pbDisplay(_INTL("{1} doesn't become confused!", pbThis))
else
@battle.pbDisplay(_INTL("{1}'s {2} prevents confusion!",pbThis,abilityName))
@battle.pbDisplay(_INTL("{1}'s {2} prevents confusion!", pbThis, abilityName))
end
@battle.pbHideAbilitySplash(self)
end
return false
end
end
if pbOwnSide.effects[PBEffects::Safeguard]>0 && !selfInflicted &&
if pbOwnSide.effects[PBEffects::Safeguard] > 0 && !selfInflicted &&
!(user && user.hasActiveAbility?(:INFILTRATOR))
@battle.pbDisplay(_INTL("{1}'s team is protected by Safeguard!",pbThis)) if showMessages
@battle.pbDisplay(_INTL("{1}'s team is protected by Safeguard!", pbThis)) if showMessages
return false
end
return true
end
def pbCanConfuseSelf?(showMessages)
return pbCanConfuse?(nil,showMessages,nil,true)
return pbCanConfuse?(nil, showMessages, nil, true)
end
def pbConfuse(msg = nil)
@effects[PBEffects::Confusion] = pbConfusionDuration
@battle.pbCommonAnimation("Confusion",self)
msg = _INTL("{1} became confused!",pbThis) if nil_or_empty?(msg)
@battle.pbCommonAnimation("Confusion", self)
msg = _INTL("{1} became confused!", pbThis) if nil_or_empty?(msg)
@battle.pbDisplay(msg)
PBDebug.log("[Lingering effect] #{pbThis}'s confusion count is #{@effects[PBEffects::Confusion]}")
# Confusion cures
@@ -492,7 +492,7 @@ class Battle::Battler
end
def pbConfusionDuration(duration = -1)
duration = 2+@battle.pbRandom(4) if duration<=0
duration = 2 + @battle.pbRandom(4) if duration <= 0
return duration
end
@@ -503,27 +503,27 @@ class Battle::Battler
#=============================================================================
# Attraction
#=============================================================================
def pbCanAttract?(user,showMessages = true)
def pbCanAttract?(user, showMessages = true)
return false if fainted?
return false if !user || user.fainted?
if @effects[PBEffects::Attract]>=0
@battle.pbDisplay(_INTL("{1} is unaffected!",pbThis)) if showMessages
if @effects[PBEffects::Attract] >= 0
@battle.pbDisplay(_INTL("{1} is unaffected!", pbThis)) if showMessages
return false
end
agender = user.gender
ogender = gender
if agender==2 || ogender==2 || agender==ogender
@battle.pbDisplay(_INTL("{1} is unaffected!",pbThis)) if showMessages
if agender == 2 || ogender == 2 || agender == ogender
@battle.pbDisplay(_INTL("{1} is unaffected!", pbThis)) if showMessages
return false
end
if !@battle.moldBreaker
if hasActiveAbility?([:AROMAVEIL,:OBLIVIOUS])
if hasActiveAbility?([:AROMAVEIL, :OBLIVIOUS])
if showMessages
@battle.pbShowAbilitySplash(self)
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} is unaffected!",pbThis))
@battle.pbDisplay(_INTL("{1} is unaffected!", pbThis))
else
@battle.pbDisplay(_INTL("{1}'s {2} prevents romance!",pbThis,abilityName))
@battle.pbDisplay(_INTL("{1}'s {2} prevents romance!", pbThis, abilityName))
end
@battle.pbHideAbilitySplash(self)
end
@@ -534,9 +534,9 @@ class Battle::Battler
if showMessages
@battle.pbShowAbilitySplash(self)
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} is unaffected!",pbThis))
@battle.pbDisplay(_INTL("{1} is unaffected!", pbThis))
else
@battle.pbDisplay(_INTL("{1}'s {2} prevents romance!",b.pbThis,b.abilityName))
@battle.pbDisplay(_INTL("{1}'s {2} prevents romance!", b.pbThis, b.abilityName))
end
@battle.pbHideAbilitySplash(self)
end
@@ -547,14 +547,14 @@ class Battle::Battler
return true
end
def pbAttract(user,msg = nil)
def pbAttract(user, msg = nil)
@effects[PBEffects::Attract] = user.index
@battle.pbCommonAnimation("Attract",self)
msg = _INTL("{1} fell in love!",pbThis) if nil_or_empty?(msg)
@battle.pbCommonAnimation("Attract", self)
msg = _INTL("{1} fell in love!", pbThis) if nil_or_empty?(msg)
@battle.pbDisplay(msg)
# Destiny Knot
if hasActiveItem?(:DESTINYKNOT) && user.pbCanAttract?(self,false)
user.pbAttract(self,_INTL("{1} fell in love from the {2}!",user.pbThis(true),itemName))
if hasActiveItem?(:DESTINYKNOT) && user.pbCanAttract?(self, false)
user.pbAttract(self, _INTL("{1} fell in love from the {2}!", user.pbThis(true), itemName))
end
# Attraction cures
pbItemStatusCureCheck

View File

@@ -3,14 +3,14 @@ class Battle::Battler
# Increase stat stages
#=============================================================================
def statStageAtMax?(stat)
return @stages[stat]>=6
return @stages[stat] >= 6
end
def pbCanRaiseStatStage?(stat,user = nil,move = nil,showFailMsg = false,ignoreContrary = false)
def pbCanRaiseStatStage?(stat, user = nil, move = nil, showFailMsg = false, ignoreContrary = false)
return false if fainted?
# Contrary
if hasActiveAbility?(:CONTRARY) && !ignoreContrary && !@battle.moldBreaker
return pbCanLowerStatStage?(stat,user,move,showFailMsg,true)
return pbCanLowerStatStage?(stat, user, move, showFailMsg, true)
end
# Check the stat stage
if statStageAtMax?(stat)
@@ -21,20 +21,20 @@ class Battle::Battler
return true
end
def pbRaiseStatStageBasic(stat,increment,ignoreContrary = false)
def pbRaiseStatStageBasic(stat, increment, ignoreContrary = false)
if !@battle.moldBreaker
# Contrary
if hasActiveAbility?(:CONTRARY) && !ignoreContrary
return pbLowerStatStageBasic(stat,increment,true)
return pbLowerStatStageBasic(stat, increment, true)
end
# Simple
increment *= 2 if hasActiveAbility?(:SIMPLE)
end
# Change the stat stage
increment = [increment,6-@stages[stat]].min
if increment>0
increment = [increment, 6 - @stages[stat]].min
if increment > 0
stat_name = GameData::Stat.get(stat).name
new = @stages[stat]+increment
new = @stages[stat] + increment
PBDebug.log("[Stat change] #{pbThis}'s #{stat_name}: #{@stages[stat]} -> #{new} (+#{increment})")
@stages[stat] += increment
@statsRaisedThisRound = true
@@ -42,22 +42,22 @@ class Battle::Battler
return increment
end
def pbRaiseStatStage(stat,increment,user,showAnim = true,ignoreContrary = false)
def pbRaiseStatStage(stat, increment, user, showAnim = true, ignoreContrary = false)
# Contrary
if hasActiveAbility?(:CONTRARY) && !ignoreContrary && !@battle.moldBreaker
return pbLowerStatStage(stat,increment,user,showAnim,true)
return pbLowerStatStage(stat, increment, user, showAnim, true)
end
# Perform the stat stage change
increment = pbRaiseStatStageBasic(stat,increment,ignoreContrary)
return false if increment<=0
increment = pbRaiseStatStageBasic(stat, increment, ignoreContrary)
return false if increment <= 0
# Stat up animation and message
@battle.pbCommonAnimation("StatUp",self) if showAnim
@battle.pbCommonAnimation("StatUp", self) if showAnim
arrStatTexts = [
_INTL("{1}'s {2} rose!",pbThis,GameData::Stat.get(stat).name),
_INTL("{1}'s {2} rose sharply!",pbThis,GameData::Stat.get(stat).name),
_INTL("{1}'s {2} rose drastically!",pbThis,GameData::Stat.get(stat).name)
_INTL("{1}'s {2} rose!", pbThis, GameData::Stat.get(stat).name),
_INTL("{1}'s {2} rose sharply!", pbThis, GameData::Stat.get(stat).name),
_INTL("{1}'s {2} rose drastically!", pbThis, GameData::Stat.get(stat).name)
]
@battle.pbDisplay(arrStatTexts[[increment-1,2].min])
@battle.pbDisplay(arrStatTexts[[increment - 1, 2].min])
# Trigger abilities upon stat gain
if abilityActive?
Battle::AbilityEffects.triggerOnStatGain(self.ability, self, stat, user)
@@ -65,30 +65,30 @@ class Battle::Battler
return true
end
def pbRaiseStatStageByCause(stat,increment,user,cause,showAnim = true,ignoreContrary = false)
def pbRaiseStatStageByCause(stat, increment, user, cause, showAnim = true, ignoreContrary = false)
# Contrary
if hasActiveAbility?(:CONTRARY) && !ignoreContrary && !@battle.moldBreaker
return pbLowerStatStageByCause(stat,increment,user,cause,showAnim,true)
return pbLowerStatStageByCause(stat, increment, user, cause, showAnim, true)
end
# Perform the stat stage change
increment = pbRaiseStatStageBasic(stat,increment,ignoreContrary)
return false if increment<=0
increment = pbRaiseStatStageBasic(stat, increment, ignoreContrary)
return false if increment <= 0
# Stat up animation and message
@battle.pbCommonAnimation("StatUp",self) if showAnim
if user.index==@index
@battle.pbCommonAnimation("StatUp", self) if showAnim
if user.index == @index
arrStatTexts = [
_INTL("{1}'s {2} raised its {3}!",pbThis,cause,GameData::Stat.get(stat).name),
_INTL("{1}'s {2} sharply raised its {3}!",pbThis,cause,GameData::Stat.get(stat).name),
_INTL("{1}'s {2} drastically raised its {3}!",pbThis,cause,GameData::Stat.get(stat).name)
_INTL("{1}'s {2} raised its {3}!", pbThis, cause, GameData::Stat.get(stat).name),
_INTL("{1}'s {2} sharply raised its {3}!", pbThis, cause, GameData::Stat.get(stat).name),
_INTL("{1}'s {2} drastically raised its {3}!", pbThis, cause, GameData::Stat.get(stat).name)
]
else
arrStatTexts = [
_INTL("{1}'s {2} raised {3}'s {4}!",user.pbThis,cause,pbThis(true),GameData::Stat.get(stat).name),
_INTL("{1}'s {2} sharply raised {3}'s {4}!",user.pbThis,cause,pbThis(true),GameData::Stat.get(stat).name),
_INTL("{1}'s {2} drastically raised {3}'s {4}!",user.pbThis,cause,pbThis(true),GameData::Stat.get(stat).name)
_INTL("{1}'s {2} raised {3}'s {4}!", user.pbThis, cause, pbThis(true), GameData::Stat.get(stat).name),
_INTL("{1}'s {2} sharply raised {3}'s {4}!", user.pbThis, cause, pbThis(true), GameData::Stat.get(stat).name),
_INTL("{1}'s {2} drastically raised {3}'s {4}!", user.pbThis, cause, pbThis(true), GameData::Stat.get(stat).name)
]
end
@battle.pbDisplay(arrStatTexts[[increment-1,2].min])
@battle.pbDisplay(arrStatTexts[[increment - 1, 2].min])
# Trigger abilities upon stat gain
if abilityActive?
Battle::AbilityEffects.triggerOnStatGain(self.ability, self, stat, user)
@@ -96,15 +96,15 @@ class Battle::Battler
return true
end
def pbRaiseStatStageByAbility(stat,increment,user,splashAnim = true)
def pbRaiseStatStageByAbility(stat, increment, user, splashAnim = true)
return false if fainted?
ret = false
@battle.pbShowAbilitySplash(user) if splashAnim
if pbCanRaiseStatStage?(stat,user,nil,Battle::Scene::USE_ABILITY_SPLASH)
if pbCanRaiseStatStage?(stat, user, nil, Battle::Scene::USE_ABILITY_SPLASH)
if Battle::Scene::USE_ABILITY_SPLASH
ret = pbRaiseStatStage(stat,increment,user)
ret = pbRaiseStatStage(stat, increment, user)
else
ret = pbRaiseStatStageByCause(stat,increment,user,user.abilityName)
ret = pbRaiseStatStageByCause(stat, increment, user, user.abilityName)
end
end
@battle.pbHideAbilitySplash(user) if splashAnim
@@ -115,7 +115,7 @@ class Battle::Battler
# Decrease stat stages
#=============================================================================
def statStageAtMin?(stat)
return @stages[stat]<=-6
return @stages[stat] <= -6
end
def pbCanLowerStatStage?(stat, user = nil, move = nil, showFailMsg = false, ignoreContrary = false, ignoreMirrorArmor = false)
@@ -130,27 +130,27 @@ class Battle::Battler
return true if !statStageAtMin?(stat)
end
end
if !user || user.index!=@index # Not self-inflicted
if @effects[PBEffects::Substitute]>0 && (ignoreMirrorArmor || !(move && move.ignoresSubstitute?(user)))
@battle.pbDisplay(_INTL("{1} is protected by its substitute!",pbThis)) if showFailMsg
if !user || user.index != @index # Not self-inflicted
if @effects[PBEffects::Substitute] > 0 && (ignoreMirrorArmor || !(move && move.ignoresSubstitute?(user)))
@battle.pbDisplay(_INTL("{1} is protected by its substitute!", pbThis)) if showFailMsg
return false
end
if pbOwnSide.effects[PBEffects::Mist]>0 &&
if pbOwnSide.effects[PBEffects::Mist] > 0 &&
!(user && user.hasActiveAbility?(:INFILTRATOR))
@battle.pbDisplay(_INTL("{1} is protected by Mist!",pbThis)) if showFailMsg
@battle.pbDisplay(_INTL("{1} is protected by Mist!", pbThis)) if showFailMsg
return false
end
if abilityActive?
return false if !@battle.moldBreaker && Battle::AbilityEffects.triggerStatLossImmunity(
self.ability,self,stat,@battle,showFailMsg)
self.ability, self, stat, @battle, showFailMsg)
return false if Battle::AbilityEffects.triggerStatLossImmunityNonIgnorable(
self.ability,self,stat,@battle,showFailMsg)
self.ability, self, stat, @battle, showFailMsg)
end
if !@battle.moldBreaker
allAllies.each do |b|
next if !b.abilityActive?
return false if Battle::AbilityEffects.triggerStatLossImmunityFromAlly(
b.ability,b,self,stat,@battle,showFailMsg)
b.ability, b, self, stat, @battle, showFailMsg)
end
end
end
@@ -163,20 +163,20 @@ class Battle::Battler
return true
end
def pbLowerStatStageBasic(stat,increment,ignoreContrary = false)
def pbLowerStatStageBasic(stat, increment, ignoreContrary = false)
if !@battle.moldBreaker
# Contrary
if hasActiveAbility?(:CONTRARY) && !ignoreContrary
return pbRaiseStatStageBasic(stat,increment,true)
return pbRaiseStatStageBasic(stat, increment, true)
end
# Simple
increment *= 2 if hasActiveAbility?(:SIMPLE)
end
# Change the stat stage
increment = [increment,6+@stages[stat]].min
if increment>0
increment = [increment, 6 + @stages[stat]].min
if increment > 0
stat_name = GameData::Stat.get(stat).name
new = @stages[stat]-increment
new = @stages[stat] - increment
PBDebug.log("[Stat change] #{pbThis}'s #{stat_name}: #{@stages[stat]} -> #{new} (-#{increment})")
@stages[stat] -= increment
@statsLoweredThisRound = true
@@ -210,16 +210,16 @@ class Battle::Battler
end
end
# Perform the stat stage change
increment = pbLowerStatStageBasic(stat,increment,ignoreContrary)
return false if increment<=0
increment = pbLowerStatStageBasic(stat, increment, ignoreContrary)
return false if increment <= 0
# Stat down animation and message
@battle.pbCommonAnimation("StatDown",self) if showAnim
@battle.pbCommonAnimation("StatDown", self) if showAnim
arrStatTexts = [
_INTL("{1}'s {2} fell!",pbThis,GameData::Stat.get(stat).name),
_INTL("{1}'s {2} harshly fell!",pbThis,GameData::Stat.get(stat).name),
_INTL("{1}'s {2} severely fell!",pbThis,GameData::Stat.get(stat).name)
_INTL("{1}'s {2} fell!", pbThis, GameData::Stat.get(stat).name),
_INTL("{1}'s {2} harshly fell!", pbThis, GameData::Stat.get(stat).name),
_INTL("{1}'s {2} severely fell!", pbThis, GameData::Stat.get(stat).name)
]
@battle.pbDisplay(arrStatTexts[[increment-1,2].min])
@battle.pbDisplay(arrStatTexts[[increment - 1, 2].min])
# Trigger abilities upon stat loss
if abilityActive?
Battle::AbilityEffects.triggerOnStatLoss(self.ability, self, stat, user)
@@ -250,24 +250,24 @@ class Battle::Battler
end
end
# Perform the stat stage change
increment = pbLowerStatStageBasic(stat,increment,ignoreContrary)
return false if increment<=0
increment = pbLowerStatStageBasic(stat, increment, ignoreContrary)
return false if increment <= 0
# Stat down animation and message
@battle.pbCommonAnimation("StatDown",self) if showAnim
if user.index==@index
@battle.pbCommonAnimation("StatDown", self) if showAnim
if user.index == @index
arrStatTexts = [
_INTL("{1}'s {2} lowered its {3}!",pbThis,cause,GameData::Stat.get(stat).name),
_INTL("{1}'s {2} harshly lowered its {3}!",pbThis,cause,GameData::Stat.get(stat).name),
_INTL("{1}'s {2} severely lowered its {3}!",pbThis,cause,GameData::Stat.get(stat).name)
_INTL("{1}'s {2} lowered its {3}!", pbThis, cause, GameData::Stat.get(stat).name),
_INTL("{1}'s {2} harshly lowered its {3}!", pbThis, cause, GameData::Stat.get(stat).name),
_INTL("{1}'s {2} severely lowered its {3}!", pbThis, cause, GameData::Stat.get(stat).name)
]
else
arrStatTexts = [
_INTL("{1}'s {2} lowered {3}'s {4}!",user.pbThis,cause,pbThis(true),GameData::Stat.get(stat).name),
_INTL("{1}'s {2} harshly lowered {3}'s {4}!",user.pbThis,cause,pbThis(true),GameData::Stat.get(stat).name),
_INTL("{1}'s {2} severely lowered {3}'s {4}!",user.pbThis,cause,pbThis(true),GameData::Stat.get(stat).name)
_INTL("{1}'s {2} lowered {3}'s {4}!", user.pbThis, cause, pbThis(true), GameData::Stat.get(stat).name),
_INTL("{1}'s {2} harshly lowered {3}'s {4}!", user.pbThis, cause, pbThis(true), GameData::Stat.get(stat).name),
_INTL("{1}'s {2} severely lowered {3}'s {4}!", user.pbThis, cause, pbThis(true), GameData::Stat.get(stat).name)
]
end
@battle.pbDisplay(arrStatTexts[[increment-1,2].min])
@battle.pbDisplay(arrStatTexts[[increment - 1, 2].min])
# Trigger abilities upon stat loss
if abilityActive?
Battle::AbilityEffects.triggerOnStatLoss(self.ability, self, stat, user)
@@ -275,15 +275,15 @@ class Battle::Battler
return true
end
def pbLowerStatStageByAbility(stat,increment,user,splashAnim = true,checkContact = false)
def pbLowerStatStageByAbility(stat, increment, user, splashAnim = true, checkContact = false)
ret = false
@battle.pbShowAbilitySplash(user) if splashAnim
if pbCanLowerStatStage?(stat,user,nil,Battle::Scene::USE_ABILITY_SPLASH) &&
if pbCanLowerStatStage?(stat, user, nil, Battle::Scene::USE_ABILITY_SPLASH) &&
(!checkContact || affectedByContactEffect?(Battle::Scene::USE_ABILITY_SPLASH))
if Battle::Scene::USE_ABILITY_SPLASH
ret = pbLowerStatStage(stat,increment,user)
ret = pbLowerStatStage(stat, increment, user)
else
ret = pbLowerStatStageByCause(stat,increment,user,user.abilityName)
ret = pbLowerStatStageByCause(stat, increment, user, user.abilityName)
end
end
@battle.pbHideAbilitySplash(user) if splashAnim
@@ -293,12 +293,12 @@ class Battle::Battler
def pbLowerAttackStatStageIntimidate(user)
return false if fainted?
# NOTE: Substitute intentially blocks Intimidate even if self has Contrary.
if @effects[PBEffects::Substitute]>0
if @effects[PBEffects::Substitute] > 0
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} is protected by its substitute!",pbThis))
@battle.pbDisplay(_INTL("{1} is protected by its substitute!", pbThis))
else
@battle.pbDisplay(_INTL("{1}'s substitute protected it from {2}'s {3}!",
pbThis,user.pbThis(true),user.abilityName))
pbThis, user.pbThis(true), user.abilityName))
end
return false
end
@@ -314,22 +314,22 @@ class Battle::Battler
return false
end
if Battle::Scene::USE_ABILITY_SPLASH
return pbLowerStatStageByAbility(:ATTACK,1,user,false)
return pbLowerStatStageByAbility(:ATTACK, 1, user, false)
end
# NOTE: These checks exist to ensure appropriate messages are shown if
# Intimidate is blocked somehow (i.e. the messages should mention the
# Intimidate ability by name).
if !hasActiveAbility?(:CONTRARY)
if pbOwnSide.effects[PBEffects::Mist]>0
if pbOwnSide.effects[PBEffects::Mist] > 0
@battle.pbDisplay(_INTL("{1} is protected from {2}'s {3} by Mist!",
pbThis,user.pbThis(true),user.abilityName))
pbThis, user.pbThis(true), user.abilityName))
return false
end
if abilityActive?
if Battle::AbilityEffects.triggerStatLossImmunity(self.ability, self, :ATTACK, @battle, false) ||
Battle::AbilityEffects.triggerStatLossImmunityNonIgnorable(self.ability, self, :ATTACK, @battle, false)
@battle.pbDisplay(_INTL("{1}'s {2} prevented {3}'s {4} from working!",
pbThis,abilityName,user.pbThis(true),user.abilityName))
pbThis, abilityName, user.pbThis(true), user.abilityName))
return false
end
end
@@ -337,13 +337,13 @@ class Battle::Battler
next if !b.abilityActive?
if Battle::AbilityEffects.triggerStatLossImmunityFromAlly(b.ability, b, self, :ATTACK, @battle, false)
@battle.pbDisplay(_INTL("{1} is protected from {2}'s {3} by {4}'s {5}!",
pbThis,user.pbThis(true),user.abilityName,b.pbThis(true),b.abilityName))
pbThis, user.pbThis(true), user.abilityName, b.pbThis(true), b.abilityName))
return false
end
end
end
return false if !pbCanLowerStatStage?(:ATTACK,user)
return pbLowerStatStageByCause(:ATTACK,1,user,user.abilityName)
return false if !pbCanLowerStatStage?(:ATTACK, user)
return pbLowerStatStageByCause(:ATTACK, 1, user, user.abilityName)
end
#=============================================================================

View File

@@ -7,7 +7,7 @@ class Battle::Battler
Battle::AbilityEffects.triggerOnSwitchOut(self.ability, self, false)
end
# Reset form
@battle.peer.pbOnLeavingBattle(@battle,@pokemon,@battle.usedInBattle[idxOwnSide][@index/2])
@battle.peer.pbOnLeavingBattle(@battle, @pokemon, @battle.usedInBattle[idxOwnSide][@index / 2])
# Treat self as fainted
@hp = 0
@fainted = true
@@ -77,11 +77,11 @@ class Battle::Battler
next !b.ungainableAbility? &&
![:POWEROFALCHEMY, :RECEIVER, :TRACE].include?(b.ability_id)
}
if choices.length>0
if choices.length > 0
choice = choices[@battle.pbRandom(choices.length)]
@battle.pbShowAbilitySplash(self)
self.ability = choice.ability
@battle.pbDisplay(_INTL("{1} traced {2}'s {3}!",pbThis,choice.pbThis(true),choice.abilityName))
@battle.pbDisplay(_INTL("{1} traced {2}'s {3}!", pbThis, choice.pbThis(true), choice.abilityName))
@battle.pbHideAbilitySplash(self)
if !onSwitchIn && (unstoppableAbility? || abilityActive?)
Battle::AbilityEffects.triggerOnSwitchIn(self.ability, self, @battle)
@@ -227,7 +227,7 @@ class Battle::Battler
self.item = nil
end
def pbConsumeItem(recoverable = true,symbiosis = true,belch = true)
def pbConsumeItem(recoverable = true, symbiosis = true, belch = true)
PBDebug.log("[Item consumed] #{pbThis} consumed its held #{itemName}")
if recoverable
setRecycleItem(@item_id)
@@ -250,10 +250,10 @@ class Battle::Battler
@battle.pbShowAbilitySplash(b)
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} shared its {2} with {3}!",
b.pbThis,b.itemName,pbThis(true)))
b.pbThis, b.itemName, pbThis(true)))
else
@battle.pbDisplay(_INTL("{1}'s {2} let it share its {3} with {4}!",
b.pbThis,b.abilityName,b.itemName,pbThis(true)))
b.pbThis, b.abilityName, b.itemName, pbThis(true)))
end
self.item = b.item
b.item = nil

View File

@@ -2,36 +2,36 @@ class Battle::Battler
#=============================================================================
# Turn processing
#=============================================================================
def pbProcessTurn(choice,tryFlee = true)
def pbProcessTurn(choice, tryFlee = true)
return false if fainted?
# Wild roaming Pokémon always flee if possible
if tryFlee && wild? &&
@battle.rules["alwaysflee"] && @battle.pbCanRun?(@index)
pbBeginTurn(choice)
pbSEPlay("Battle flee")
@battle.pbDisplay(_INTL("{1} fled from battle!",pbThis))
@battle.pbDisplay(_INTL("{1} fled from battle!", pbThis))
@battle.decision = 3
pbEndTurn(choice)
return true
end
# Shift with the battler next to this one
if choice[0]==:Shift
if choice[0] == :Shift
idxOther = -1
case @battle.pbSideSize(@index)
when 2
idxOther = (@index+2)%4
idxOther = (@index + 2) % 4
when 3
if @index!=2 && @index!=3 # If not in middle spot already
idxOther = ((@index%2)==0) ? 2 : 3
if @index != 2 && @index != 3 # If not in middle spot already
idxOther = ((@index % 2) == 0) ? 2 : 3
end
end
if idxOther>=0
@battle.pbSwapBattlers(@index,idxOther)
if idxOther >= 0
@battle.pbSwapBattlers(@index, idxOther)
case @battle.pbSideSize(@index)
when 2
@battle.pbDisplay(_INTL("{1} moved across!",pbThis))
@battle.pbDisplay(_INTL("{1} moved across!", pbThis))
when 3
@battle.pbDisplay(_INTL("{1} moved to the center!",pbThis))
@battle.pbDisplay(_INTL("{1} moved to the center!", pbThis))
end
end
pbBeginTurn(choice)
@@ -40,7 +40,7 @@ class Battle::Battler
return true
end
# If this battler's action for this round wasn't "use a move"
if choice[0]!=:UseMove
if choice[0] != :UseMove
# Clean up effects that end at battler's turn
pbBeginTurn(choice)
pbEndTurn(choice)
@@ -57,7 +57,7 @@ class Battle::Battler
# Use the move
PBDebug.log("[Move usage] #{pbThis} started using #{choice[2].name}")
PBDebug.logonerr {
pbUseMove(choice,choice[2]==@battle.struggle)
pbUseMove(choice, choice[2] == @battle.struggle)
}
@battle.pbJudge
# Update priority order
@@ -77,7 +77,7 @@ class Battle::Battler
@effects[PBEffects::MoveNext] = false
@effects[PBEffects::Quash] = 0
# Encore's effect ends if the encored move is no longer available
if @effects[PBEffects::Encore]>0 && pbEncoredMoveIndex<0
if @effects[PBEffects::Encore] > 0 && pbEncoredMoveIndex < 0
@effects[PBEffects::Encore] = 0
@effects[PBEffects::EncoreMove] = nil
end
@@ -91,8 +91,8 @@ class Battle::Battler
def pbCancelMoves(full_cancel = false)
# Outragers get confused anyway if they are disrupted during their final
# turn of using the move
if @effects[PBEffects::Outrage]==1 && pbCanConfuseSelf?(false) && !full_cancel
pbConfuse(_INTL("{1} became confused due to fatigue!",pbThis))
if @effects[PBEffects::Outrage] == 1 && pbCanConfuseSelf?(false) && !full_cancel
pbConfuse(_INTL("{1} became confused due to fatigue!", pbThis))
end
# Cancel usage of most multi-turn moves
@effects[PBEffects::TwoTurnAttack] = nil
@@ -102,13 +102,13 @@ class Battle::Battler
@effects[PBEffects::Bide] = 0
@currentMove = nil
# Reset counters for moves which increase them when used in succession
@effects[PBEffects::FuryCutter] = 0
@effects[PBEffects::FuryCutter] = 0
end
def pbEndTurn(_choice)
@lastRoundMoved = @battle.turnCount # Done something this round
if !@effects[PBEffects::ChoiceBand] &&
(hasActiveItem?([:CHOICEBAND,:CHOICESPECS,:CHOICESCARF]) ||
(hasActiveItem?([:CHOICEBAND, :CHOICESPECS, :CHOICESCARF]) ||
hasActiveAbility?(:GORILLATACTICS))
if @lastMoveUsed && pbHasMove?(@lastMoveUsed)
@effects[PBEffects::ChoiceBand] = @lastMoveUsed
@@ -117,7 +117,7 @@ class Battle::Battler
end
end
@effects[PBEffects::BeakBlast] = false
@effects[PBEffects::Charge] = 0 if @effects[PBEffects::Charge]==1
@effects[PBEffects::Charge] = 0 if @effects[PBEffects::Charge] == 1
@effects[PBEffects::GemConsumed] = nil
@effects[PBEffects::ShellTrap] = false
@battle.allBattlers.each { |b| b.pbContinualAbilityChecks } # Trace, end primordial weathers
@@ -125,16 +125,16 @@ class Battle::Battler
def pbConfusionDamage(msg)
@damageState.reset
confusionMove = Battle::Move::Confusion.new(@battle,nil)
confusionMove = Battle::Move::Confusion.new(@battle, nil)
confusionMove.calcType = confusionMove.pbCalcType(self) # nil
@damageState.typeMod = confusionMove.pbCalcTypeMod(confusionMove.calcType,self,self) # 8
confusionMove.pbCheckDamageAbsorption(self,self)
confusionMove.pbCalcDamage(self,self)
confusionMove.pbReduceDamage(self,self)
@damageState.typeMod = confusionMove.pbCalcTypeMod(confusionMove.calcType, self, self) # 8
confusionMove.pbCheckDamageAbsorption(self, self)
confusionMove.pbCalcDamage(self, self)
confusionMove.pbReduceDamage(self, self)
self.hp -= @damageState.hpLost
confusionMove.pbAnimateHitAndHPLost(self,[self])
confusionMove.pbAnimateHitAndHPLost(self, [self])
@battle.pbDisplay(msg) # "It hurt itself in its confusion!"
confusionMove.pbRecordDamageLost(self,self)
confusionMove.pbRecordDamageLost(self, self)
confusionMove.pbEndureKOMessage(self)
pbFaint if fainted?
pbItemHPHealCheck
@@ -144,11 +144,11 @@ class Battle::Battler
# Simple "use move" method, used when a move calls another move and for Future
# Sight's attack
#=============================================================================
def pbUseMoveSimple(moveID,target = -1,idxMove = -1,specialUsage = true)
def pbUseMoveSimple(moveID, target = -1, idxMove = -1, specialUsage = true)
choice = []
choice[0] = :UseMove # "Use move"
choice[1] = idxMove # Index of move to be used in user's moveset
if idxMove>=0
if idxMove >= 0
choice[2] = @moves[idxMove]
else
choice[2] = Battle::Move.from_pokemon_move(@battle, Pokemon::Move.new(moveID))
@@ -156,27 +156,27 @@ class Battle::Battler
end
choice[3] = target # Target (-1 means no target yet)
PBDebug.log("[Move usage] #{pbThis} started using the called/simple move #{choice[2].name}")
pbUseMove(choice,specialUsage)
pbUseMove(choice, specialUsage)
end
#=============================================================================
# Master "use move" method
#=============================================================================
def pbUseMove(choice,specialUsage = false)
def pbUseMove(choice, specialUsage = false)
# NOTE: This is intentionally determined before a multi-turn attack can
# set specialUsage to true.
skipAccuracyCheck = (specialUsage && choice[2]!=@battle.struggle)
skipAccuracyCheck = (specialUsage && choice[2] != @battle.struggle)
# Start using the move
pbBeginTurn(choice)
# Force the use of certain moves if they're already being used
if usingMultiTurnAttack?
choice[2] = Battle::Move.from_pokemon_move(@battle, Pokemon::Move.new(@currentMove))
specialUsage = true
elsif @effects[PBEffects::Encore]>0 && choice[1]>=0 &&
elsif @effects[PBEffects::Encore] > 0 && choice[1] >= 0 &&
@battle.pbCanShowCommands?(@index)
idxEncoredMove = pbEncoredMoveIndex
if idxEncoredMove>=0 && @battle.pbCanChooseMove?(@index,idxEncoredMove,false)
if choice[1]!=idxEncoredMove # Change move if battler was Encored mid-round
if idxEncoredMove >= 0 && @battle.pbCanChooseMove?(@index, idxEncoredMove, false)
if choice[1] != idxEncoredMove # Change move if battler was Encored mid-round
choice[1] = idxEncoredMove
choice[2] = @moves[idxEncoredMove]
choice[3] = -1 # No target chosen
@@ -188,7 +188,7 @@ class Battle::Battler
return if !move # if move was not chosen somehow
# Try to use the move (inc. disobedience)
@lastMoveFailed = false
if !pbTryUseMove(choice,move,specialUsage,skipAccuracyCheck)
if !pbTryUseMove(choice, move, specialUsage, skipAccuracyCheck)
@lastMoveUsed = nil
@lastMoveUsedType = nil
if !specialUsage
@@ -205,7 +205,7 @@ class Battle::Battler
# Subtract PP
if !specialUsage
if !pbReducePP(move)
@battle.pbDisplay(_INTL("{1} used {2}!",pbThis,move.name))
@battle.pbDisplay(_INTL("{1} used {2}!", pbThis, move.name))
@battle.pbDisplay(_INTL("But there was no PP left for the move!"))
@lastMoveUsed = nil
@lastMoveUsedType = nil
@@ -220,9 +220,9 @@ class Battle::Battler
# Stance Change
if isSpecies?(:AEGISLASH) && self.ability == :STANCECHANGE
if move.damagingMove?
pbChangeForm(1,_INTL("{1} changed to Blade Forme!",pbThis))
pbChangeForm(1, _INTL("{1} changed to Blade Forme!", pbThis))
elsif move.id == :KINGSSHIELD
pbChangeForm(0,_INTL("{1} changed to Shield Forme!",pbThis))
pbChangeForm(0, _INTL("{1} changed to Shield Forme!", pbThis))
end
end
# Calculate the move's type during this usage
@@ -238,10 +238,10 @@ class Battle::Battler
@effects[PBEffects::TwoTurnAttack] = nil # Cancel use of two-turn attack
end
# Add to counters for moves which increase them when used in succession
move.pbChangeUsageCounters(self,specialUsage)
move.pbChangeUsageCounters(self, specialUsage)
# Charge up Metronome item
if hasActiveItem?(:METRONOME) && !move.callsAnotherMove?
if @lastMoveUsed && @lastMoveUsed==move.id && !@lastMoveFailed
if @lastMoveUsed && @lastMoveUsed == move.id && !@lastMoveFailed
@effects[PBEffects::Metronome] += 1
else
@effects[PBEffects::Metronome] = 0
@@ -259,10 +259,10 @@ class Battle::Battler
@battle.lastMoveUser = @index # For "self KO" battle clause to avoid draws
@battle.successStates[@index].useState = 1 # Battle Arena - assume failure
# Find the default user (self or Snatcher) and target(s)
user = pbFindUser(choice,move)
user = pbChangeUser(choice,move,user)
targets = pbFindTargets(choice,move,user)
targets = pbChangeTargets(move,user,targets)
user = pbFindUser(choice, move)
user = pbChangeUser(choice, move, user)
targets = pbFindTargets(choice, move, user)
targets = pbChangeTargets(move, user, targets)
# Pressure
if !specialUsage
targets.each do |b|
@@ -282,9 +282,9 @@ class Battle::Battler
@battle.pbPriority(true).each do |b|
next if !b || !b.abilityActive?
if Battle::AbilityEffects.triggerMoveBlocking(b.ability, b, user, targets, move, @battle)
@battle.pbDisplayBrief(_INTL("{1} used {2}!",user.pbThis,move.name))
@battle.pbDisplayBrief(_INTL("{1} used {2}!", user.pbThis, move.name))
@battle.pbShowAbilitySplash(b)
@battle.pbDisplay(_INTL("{1} cannot use {2}!",user.pbThis,move.name))
@battle.pbDisplay(_INTL("{1} cannot use {2}!", user.pbThis, move.name))
@battle.pbHideAbilitySplash(b)
user.lastMoveFailed = true
pbCancelMoves
@@ -301,11 +301,11 @@ class Battle::Battler
# Snatch's message (user is the new user, self is the original user)
if move.snatched
@lastMoveFailed = true # Intentionally applies to self, not user
@battle.pbDisplay(_INTL("{1} snatched {2}'s move!",user.pbThis,pbThis(true)))
@battle.pbDisplay(_INTL("{1} snatched {2}'s move!", user.pbThis, pbThis(true)))
end
# "But it failed!" checks
if move.pbMoveFailed?(user,targets)
PBDebug.log(sprintf("[Move failed] In function code %s's def pbMoveFailed?",move.function))
if move.pbMoveFailed?(user, targets)
PBDebug.log(sprintf("[Move failed] In function code %s's def pbMoveFailed?", move.function))
user.lastMoveFailed = true
pbCancelMoves
pbEndTurn(choice)
@@ -313,15 +313,15 @@ class Battle::Battler
end
# Perform set-up actions and display messages
# Messages include Magnitude's number and Pledge moves' "it's a combo!"
move.pbOnStartUse(user,targets)
move.pbOnStartUse(user, targets)
# Self-thawing due to the move
if user.status == :FROZEN && move.thawsUser?
user.pbCureStatus(false)
@battle.pbDisplay(_INTL("{1} melted the ice!",user.pbThis))
@battle.pbDisplay(_INTL("{1} melted the ice!", user.pbThis))
end
# Powder
if user.effects[PBEffects::Powder] && move.calcType == :FIRE
@battle.pbCommonAnimation("Powder",user)
@battle.pbCommonAnimation("Powder", user)
@battle.pbDisplay(_INTL("When the flame touched the powder on the Pokémon, it exploded!"))
user.lastMoveFailed = true
if ![:Rain, :HeavyRain].include?(user.effectiveWeather) && user.takesIndirectDamage?
@@ -361,15 +361,15 @@ class Battle::Battler
@battle.pbShowAbilitySplash(user)
user.pbChangeTypes(move.calcType)
typeName = GameData::Type.get(move.calcType).name
@battle.pbDisplay(_INTL("{1}'s type changed to {2}!",user.pbThis,typeName))
@battle.pbDisplay(_INTL("{1}'s type changed to {2}!", user.pbThis, typeName))
@battle.pbHideAbilitySplash(user)
# NOTE: The GF games say that if Curse is used by a non-Ghost-type
# Pokémon which becomes Ghost-type because of Protean, it should
# target and curse itself. I think this is silly, so I'm making it
# choose a random opponent to curse instead.
if move.function=="CurseTargetOrLowerUserSpd1RaiseUserAtkDef1" && targets.length==0
if move.function == "CurseTargetOrLowerUserSpd1RaiseUserAtkDef1" && targets.length == 0
choice[3] = -1
targets = pbFindTargets(choice,move,user)
targets = pbFindTargets(choice, move, user)
end
end
end
@@ -394,7 +394,7 @@ class Battle::Battler
b.damageState.unaffected = true
end
# Magic Coat/Magic Bounce checks (for moves which don't target Pokémon)
if targets.length==0 && move.statusMove? && move.canMagicCoat?
if targets.length == 0 && move.statusMove? && move.canMagicCoat?
@battle.pbPriority(true).each do |b|
next if b.fainted? || !b.opposes?(user)
next if b.semiInvulnerable?
@@ -411,14 +411,14 @@ class Battle::Battler
end
end
# Get the number of hits
numHits = move.pbNumHits(user,targets)
numHits = move.pbNumHits(user, targets)
# Process each hit in turn
realNumHits = 0
for i in 0...numHits
break if magicCoater>=0 || magicBouncer>=0
success = pbProcessMoveHit(move,user,targets,i,skipAccuracyCheck)
break if magicCoater >= 0 || magicBouncer >= 0
success = pbProcessMoveHit(move, user, targets, i, skipAccuracyCheck)
if !success
if i==0 && targets.length>0
if i == 0 && targets.length > 0
hasFailed = false
targets.each do |t|
next if t.damageState.protected
@@ -439,7 +439,7 @@ class Battle::Battler
end
# Battle Arena only - attack is successful
@battle.successStates[user.index].useState = 2
if targets.length>0
if targets.length > 0
@battle.successStates[user.index].typeMod = 0
targets.each do |b|
next if b.damageState.unaffected
@@ -449,17 +449,17 @@ class Battle::Battler
# Effectiveness message for multi-hit moves
# NOTE: No move is both multi-hit and multi-target, and the messages below
# aren't quite right for such a hypothetical move.
if numHits>1
if numHits > 1
if move.damagingMove?
targets.each do |b|
next if b.damageState.unaffected || b.damageState.substitute
move.pbEffectivenessMessage(user,b,targets.length)
move.pbEffectivenessMessage(user, b, targets.length)
end
end
if realNumHits==1
if realNumHits == 1
@battle.pbDisplay(_INTL("Hit 1 time!"))
elsif realNumHits>1
@battle.pbDisplay(_INTL("Hit {1} times!",realNumHits))
elsif realNumHits > 1
@battle.pbDisplay(_INTL("Hit {1} times!", realNumHits))
end
end
# Magic Coat's bouncing back (move has targets)
@@ -467,38 +467,38 @@ class Battle::Battler
next if b.fainted?
next if !b.damageState.magicCoat && !b.damageState.magicBounce
@battle.pbShowAbilitySplash(b) if b.damageState.magicBounce
@battle.pbDisplay(_INTL("{1} bounced the {2} back!",b.pbThis,move.name))
@battle.pbDisplay(_INTL("{1} bounced the {2} back!", b.pbThis, move.name))
@battle.pbHideAbilitySplash(b) if b.damageState.magicBounce
newChoice = choice.clone
newChoice[3] = user.index
newTargets = pbFindTargets(newChoice,move,b)
newTargets = pbChangeTargets(move,b,newTargets)
success = pbProcessMoveHit(move,b,newTargets,0,false)
newTargets = pbFindTargets(newChoice, move, b)
newTargets = pbChangeTargets(move, b, newTargets)
success = pbProcessMoveHit(move, b, newTargets, 0, false)
b.lastMoveFailed = true if !success
targets.each { |otherB| otherB.pbFaint if otherB && otherB.fainted? }
user.pbFaint if user.fainted?
end
# Magic Coat's bouncing back (move has no targets)
if magicCoater>=0 || magicBouncer>=0
mc = @battle.battlers[(magicCoater>=0) ? magicCoater : magicBouncer]
if magicCoater >= 0 || magicBouncer >= 0
mc = @battle.battlers[(magicCoater >= 0) ? magicCoater : magicBouncer]
if !mc.fainted?
user.lastMoveFailed = true
@battle.pbShowAbilitySplash(mc) if magicBouncer>=0
@battle.pbDisplay(_INTL("{1} bounced the {2} back!",mc.pbThis,move.name))
@battle.pbHideAbilitySplash(mc) if magicBouncer>=0
success = pbProcessMoveHit(move,mc,[],0,false)
@battle.pbShowAbilitySplash(mc) if magicBouncer >= 0
@battle.pbDisplay(_INTL("{1} bounced the {2} back!", mc.pbThis, move.name))
@battle.pbHideAbilitySplash(mc) if magicBouncer >= 0
success = pbProcessMoveHit(move, mc, [], 0, false)
mc.lastMoveFailed = true if !success
targets.each { |b| b.pbFaint if b && b.fainted? }
user.pbFaint if user.fainted?
end
end
# Move-specific effects after all hits
targets.each { |b| move.pbEffectAfterAllHits(user,b) }
targets.each { |b| move.pbEffectAfterAllHits(user, b) }
# Faint if 0 HP
targets.each { |b| b.pbFaint if b && b.fainted? }
user.pbFaint if user.fainted?
# External/general effects after all hits. Eject Button, Shell Bell, etc.
pbEffectsAfterMove(user,targets,move,realNumHits)
pbEffectsAfterMove(user, targets, move, realNumHits)
@battle.allBattlers.each do |b|
b.droppedBelowHalfHP = false
b.statsDropped = false
@@ -511,7 +511,7 @@ class Battle::Battler
# Battle Arena only - update skills
@battle.allBattlers.each { |b| @battle.successStates[b.index].updateSkill }
# Shadow Pokémon triggering Hyper Mode
pbHyperMode if @battle.choices[@index][0]!=:None # Not if self is replaced
pbHyperMode if @battle.choices[@index][0] != :None # Not if self is replaced
# End of move usage
pbEndTurn(choice)
# Instruct
@@ -519,56 +519,56 @@ class Battle::Battler
next if !b.effects[PBEffects::Instruct] || !b.lastMoveUsed
b.effects[PBEffects::Instruct] = false
idxMove = -1
b.eachMoveWithIndex { |m,i| idxMove = i if m.id==b.lastMoveUsed }
next if idxMove<0
b.eachMoveWithIndex { |m, i| idxMove = i if m.id == b.lastMoveUsed }
next if idxMove < 0
oldLastRoundMoved = b.lastRoundMoved
@battle.pbDisplay(_INTL("{1} used the move instructed by {2}!",b.pbThis,user.pbThis(true)))
@battle.pbDisplay(_INTL("{1} used the move instructed by {2}!", b.pbThis, user.pbThis(true)))
b.effects[PBEffects::Instructed] = true
if b.pbCanChooseMove?(@moves[idxMove], false)
PBDebug.logonerr {
b.pbUseMoveSimple(b.lastMoveUsed,b.lastRegularMoveTarget,idxMove,false)
b.pbUseMoveSimple(b.lastMoveUsed, b.lastRegularMoveTarget, idxMove, false)
}
b.lastRoundMoved = oldLastRoundMoved
@battle.pbJudge
return if @battle.decision>0
return if @battle.decision > 0
end
b.effects[PBEffects::Instructed] = false
end
# Dancer
if !@effects[PBEffects::Dancer] && !user.lastMoveFailed && realNumHits>0 &&
!move.snatched && magicCoater<0 && @battle.pbCheckGlobalAbility(:DANCER) &&
if !@effects[PBEffects::Dancer] && !user.lastMoveFailed && realNumHits > 0 &&
!move.snatched && magicCoater < 0 && @battle.pbCheckGlobalAbility(:DANCER) &&
move.danceMove?
dancers = []
@battle.pbPriority(true).each do |b|
dancers.push(b) if b.index!=user.index && b.hasActiveAbility?(:DANCER)
dancers.push(b) if b.index != user.index && b.hasActiveAbility?(:DANCER)
end
while dancers.length>0
while dancers.length > 0
nextUser = dancers.pop
oldLastRoundMoved = nextUser.lastRoundMoved
# NOTE: Petal Dance being used because of Dancer shouldn't lock the
# Dancer into using that move, and shouldn't contribute to its
# turn counter if it's already locked into Petal Dance.
oldOutrage = nextUser.effects[PBEffects::Outrage]
nextUser.effects[PBEffects::Outrage] += 1 if nextUser.effects[PBEffects::Outrage]>0
nextUser.effects[PBEffects::Outrage] += 1 if nextUser.effects[PBEffects::Outrage] > 0
oldCurrentMove = nextUser.currentMove
preTarget = choice[3]
preTarget = user.index if nextUser.opposes?(user) || !nextUser.opposes?(preTarget)
@battle.pbShowAbilitySplash(nextUser,true)
@battle.pbShowAbilitySplash(nextUser, true)
@battle.pbHideAbilitySplash(nextUser)
if !Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} kept the dance going with {2}!",
nextUser.pbThis,nextUser.abilityName))
nextUser.pbThis, nextUser.abilityName))
end
nextUser.effects[PBEffects::Dancer] = true
if nextUser.pbCanChooseMove?(move, false)
PBDebug.logonerr {
nextUser.pbUseMoveSimple(move.id,preTarget)
nextUser.pbUseMoveSimple(move.id, preTarget)
}
nextUser.lastRoundMoved = oldLastRoundMoved
nextUser.effects[PBEffects::Outrage] = oldOutrage
nextUser.currentMove = oldCurrentMove
@battle.pbJudge
return if @battle.decision>0
return if @battle.decision > 0
end
nextUser.effects[PBEffects::Dancer] = false
end
@@ -578,19 +578,19 @@ class Battle::Battler
#=============================================================================
# Attack a single target
#=============================================================================
def pbProcessMoveHit(move,user,targets,hitNum,skipAccuracyCheck)
def pbProcessMoveHit(move, user, targets, hitNum, skipAccuracyCheck)
return false if user.fainted?
# For two-turn attacks being used in a single turn
move.pbInitialEffect(user,targets,hitNum)
move.pbInitialEffect(user, targets, hitNum)
numTargets = 0 # Number of targets that are affected by this hit
# Count a hit for Parental Bond (if it applies)
user.effects[PBEffects::ParentalBond] -= 1 if user.effects[PBEffects::ParentalBond]>0
user.effects[PBEffects::ParentalBond] -= 1 if user.effects[PBEffects::ParentalBond] > 0
# Accuracy check (accuracy/evasion calc)
if hitNum==0 || move.successCheckPerHit?
if hitNum == 0 || move.successCheckPerHit?
targets.each do |b|
b.damageState.missed = false
next if b.damageState.unaffected
if pbSuccessCheckPerHit(move,user,b,skipAccuracyCheck)
if pbSuccessCheckPerHit(move, user, b, skipAccuracyCheck)
numTargets += 1
else
b.damageState.missed = true
@@ -598,10 +598,10 @@ class Battle::Battler
end
end
# If failed against all targets
if targets.length>0 && numTargets==0 && !move.worksWithNoTargets?
if targets.length > 0 && numTargets == 0 && !move.worksWithNoTargets?
targets.each do |b|
next if !b.damageState.missed || b.damageState.magicCoat
pbMissMessage(move,user,b)
pbMissMessage(move, user, b)
if user.itemActive?
Battle::ItemEffects.triggerOnMissingTarget(user.item, user, b, move, hitNum, @battle)
end
@@ -623,25 +623,25 @@ class Battle::Battler
targets.each do |b|
next if b.damageState.unaffected
# Check whether Substitute/Disguise will absorb the damage
move.pbCheckDamageAbsorption(user,b)
move.pbCheckDamageAbsorption(user, b)
# Calculate the damage against b
# pbCalcDamage shows the "eat berry" animation for SE-weakening
# berries, although the message about it comes after the additional
# effect below
move.pbCalcDamage(user,b,targets.length) # Stored in damageState.calcDamage
move.pbCalcDamage(user, b, targets.length) # Stored in damageState.calcDamage
# Lessen damage dealt because of False Swipe/Endure/etc.
move.pbReduceDamage(user,b) # Stored in damageState.hpLost
move.pbReduceDamage(user, b) # Stored in damageState.hpLost
end
end
# Show move animation (for this hit)
move.pbShowAnimation(move.id,user,targets,hitNum)
move.pbShowAnimation(move.id, user, targets, hitNum)
# Type-boosting Gem consume animation/message
if user.effects[PBEffects::GemConsumed] && hitNum==0
if user.effects[PBEffects::GemConsumed] && hitNum == 0
# NOTE: The consume animation and message for Gems are shown now, but the
# actual removal of the item happens in def pbEffectsAfterMove.
@battle.pbCommonAnimation("UseItem",user)
@battle.pbCommonAnimation("UseItem", user)
@battle.pbDisplay(_INTL("The {1} strengthened {2}'s power!",
GameData::Item.get(user.effects[PBEffects::GemConsumed]).name,move.name))
GameData::Item.get(user.effects[PBEffects::GemConsumed]).name, move.name))
end
# Messages about missed target(s) (relevant for multi-target moves only)
if !move.pbRepeatHit?
@@ -659,29 +659,29 @@ class Battle::Battler
# This just changes the HP amounts and does nothing else
targets.each { |b| move.pbInflictHPDamage(b) if !b.damageState.unaffected }
# Animate the hit flashing and HP bar changes
move.pbAnimateHitAndHPLost(user,targets)
move.pbAnimateHitAndHPLost(user, targets)
end
# Self-Destruct/Explosion's damaging and fainting of user
move.pbSelfKO(user) if hitNum==0
move.pbSelfKO(user) if hitNum == 0
user.pbFaint if user.fainted?
if move.pbDamagingMove?
targets.each do |b|
next if b.damageState.unaffected
# NOTE: This method is also used for the OHKO special message.
move.pbHitEffectivenessMessages(user,b,targets.length)
move.pbHitEffectivenessMessages(user, b, targets.length)
# Record data about the hit for various effects' purposes
move.pbRecordDamageLost(user,b)
move.pbRecordDamageLost(user, b)
end
# Close Combat/Superpower's stat-lowering, Flame Burst's splash damage,
# and Incinerate's berry destruction
targets.each do |b|
next if b.damageState.unaffected
move.pbEffectWhenDealingDamage(user,b)
move.pbEffectWhenDealingDamage(user, b)
end
# Ability/item effects such as Static/Rocky Helmet, and Grudge, etc.
targets.each do |b|
next if b.damageState.unaffected
pbEffectsOnMakingHit(move,user,b)
pbEffectsOnMakingHit(move, user, b)
end
# Disguise/Endure/Sturdy/Focus Sash/Focus Band messages
targets.each do |b|
@@ -695,11 +695,11 @@ class Battle::Battler
# because Flame Burst's splash damage affects non-targets)
@battle.pbPriority(true).each { |b| b.pbFaint if b && b.fainted? }
end
@battle.pbJudgeCheckpoint(user,move)
@battle.pbJudgeCheckpoint(user, move)
# Main effect (recoil/drain, etc.)
targets.each do |b|
next if b.damageState.unaffected
move.pbEffectAgainstTarget(user,b)
move.pbEffectAgainstTarget(user, b)
end
move.pbEffectGeneral(user)
targets.each { |b| b.pbFaint if b && b.fainted? }
@@ -707,21 +707,21 @@ class Battle::Battler
# Additional effect
if !user.hasActiveAbility?(:SHEERFORCE)
targets.each do |b|
next if b.damageState.calcDamage==0
chance = move.pbAdditionalEffectChance(user,b)
next if chance<=0
if @battle.pbRandom(100)<chance
move.pbAdditionalEffect(user,b)
next if b.damageState.calcDamage == 0
chance = move.pbAdditionalEffectChance(user, b)
next if chance <= 0
if @battle.pbRandom(100) < chance
move.pbAdditionalEffect(user, b)
end
end
end
# Make the target flinch (because of an item/ability)
targets.each do |b|
next if b.fainted?
next if b.damageState.calcDamage==0 || b.damageState.substitute
chance = move.pbFlinchChance(user,b)
next if chance<=0
if @battle.pbRandom(100)<chance
next if b.damageState.calcDamage == 0 || b.damageState.substitute
chance = move.pbFlinchChance(user, b)
next if chance <= 0
if @battle.pbRandom(100) < chance
PBDebug.log("[Item/ability triggered] #{user.pbThis}'s King's Rock/Razor Fang or Stench")
b.pbFlinch(user)
end
@@ -733,7 +733,7 @@ class Battle::Battler
targets.each do |b|
next if b.damageState.unaffected
next if !b.damageState.berryWeakened
@battle.pbDisplay(_INTL("The {1} weakened the damage to {2}!",b.itemName,b.pbThis(true)))
@battle.pbDisplay(_INTL("The {1} weakened the damage to {2}!", b.itemName, b.pbThis(true)))
b.pbConsumeItem
end
# Steam Engine (goes here because it should be after stat changes caused by

View File

@@ -2,20 +2,20 @@ class Battle::Battler
#=============================================================================
# Get move's user
#=============================================================================
def pbFindUser(_choice,_move)
def pbFindUser(_choice, _move)
return self
end
def pbChangeUser(choice,move,user)
def pbChangeUser(choice, move, user)
# Snatch
move.snatched = false
if move.statusMove? && move.canSnatch?
newUser = nil
strength = 100
@battle.allBattlers.each do |b|
next if b.effects[PBEffects::Snatch]==0 ||
b.effects[PBEffects::Snatch]>=strength
next if b.effects[PBEffects::SkyDrop]>=0
next if b.effects[PBEffects::Snatch] == 0 ||
b.effects[PBEffects::Snatch] >= strength
next if b.effects[PBEffects::SkyDrop] >= 0
newUser = b
strength = b.effects[PBEffects::Snatch]
end
@@ -33,59 +33,59 @@ class Battle::Battler
#=============================================================================
# Get move's default target(s)
#=============================================================================
def pbFindTargets(choice,move,user)
def pbFindTargets(choice, move, user)
preTarget = choice[3] # A target that was already chosen
targets = []
# Get list of targets
case move.pbTarget(user).id # Curse can change its target type
when :NearAlly
targetBattler = (preTarget>=0) ? @battle.battlers[preTarget] : nil
if !pbAddTarget(targets,user,targetBattler,move)
pbAddTargetRandomAlly(targets,user,move)
targetBattler = (preTarget >= 0) ? @battle.battlers[preTarget] : nil
if !pbAddTarget(targets, user, targetBattler, move)
pbAddTargetRandomAlly(targets, user, move)
end
when :UserOrNearAlly
targetBattler = (preTarget>=0) ? @battle.battlers[preTarget] : nil
if !pbAddTarget(targets,user,targetBattler,move,true,true)
pbAddTarget(targets,user,user,move,true,true)
targetBattler = (preTarget >= 0) ? @battle.battlers[preTarget] : nil
if !pbAddTarget(targets, user, targetBattler, move, true, true)
pbAddTarget(targets, user, user, move, true, true)
end
when :AllAllies
@battle.allSameSideBattlers(user.index).each do |b|
pbAddTarget(targets,user,b,move,false,true) if b.index != user.index
pbAddTarget(targets, user, b, move, false, true) if b.index != user.index
end
when :UserAndAllies
pbAddTarget(targets,user,user,move,true,true)
pbAddTarget(targets, user, user, move, true, true)
@battle.allSameSideBattlers(user.index).each { |b| pbAddTarget(targets, user, b, move, false, true) }
when :NearFoe, :NearOther
targetBattler = (preTarget>=0) ? @battle.battlers[preTarget] : nil
if !pbAddTarget(targets,user,targetBattler,move)
if preTarget>=0 && !user.opposes?(preTarget)
pbAddTargetRandomAlly(targets,user,move)
targetBattler = (preTarget >= 0) ? @battle.battlers[preTarget] : nil
if !pbAddTarget(targets, user, targetBattler, move)
if preTarget >= 0 && !user.opposes?(preTarget)
pbAddTargetRandomAlly(targets, user, move)
else
pbAddTargetRandomFoe(targets,user,move)
pbAddTargetRandomFoe(targets, user, move)
end
end
when :RandomNearFoe
pbAddTargetRandomFoe(targets,user,move)
pbAddTargetRandomFoe(targets, user, move)
when :AllNearFoes
@battle.allOtherSideBattlers(user.index).each { |b| pbAddTarget(targets,user,b,move) }
@battle.allOtherSideBattlers(user.index).each { |b| pbAddTarget(targets, user, b, move) }
when :Foe, :Other
targetBattler = (preTarget>=0) ? @battle.battlers[preTarget] : nil
if !pbAddTarget(targets,user,targetBattler,move,false)
if preTarget>=0 && !user.opposes?(preTarget)
pbAddTargetRandomAlly(targets,user,move,false)
targetBattler = (preTarget >= 0) ? @battle.battlers[preTarget] : nil
if !pbAddTarget(targets, user, targetBattler, move, false)
if preTarget >= 0 && !user.opposes?(preTarget)
pbAddTargetRandomAlly(targets, user, move, false)
else
pbAddTargetRandomFoe(targets,user,move,false)
pbAddTargetRandomFoe(targets, user, move, false)
end
end
when :AllFoes
@battle.allOtherSideBattlers(user.index).each { |b| pbAddTarget(targets,user,b,move,false) }
@battle.allOtherSideBattlers(user.index).each { |b| pbAddTarget(targets, user, b, move, false) }
when :AllNearOthers
@battle.allBattlers.each { |b| pbAddTarget(targets, user, b, move) }
when :AllBattlers
@battle.allBattlers.each { |b| pbAddTarget(targets, user, b, move, false, true) }
else
# Used by Counter/Mirror Coat/Metal Burst/Bide
move.pbAddTarget(targets,user) # Move-specific pbAddTarget, not the def below
move.pbAddTarget(targets, user) # Move-specific pbAddTarget, not the def below
end
return targets
end
@@ -93,7 +93,7 @@ class Battle::Battler
#=============================================================================
# Redirect attack to another target
#=============================================================================
def pbChangeTargets(move,user,targets)
def pbChangeTargets(move, user, targets)
target_data = move.pbTarget(user)
return targets if @battle.switching # For Pursuit interrupting a switch
return targets if move.cannotRedirect? || move.targetsPosition?
@@ -106,9 +106,9 @@ class Battle::Battler
newTarget = nil
strength = 100 # Lower strength takes priority
priority.each do |b|
next if b.fainted? || b.effects[PBEffects::SkyDrop]>=0
next if b.effects[PBEffects::Spotlight]==0 ||
b.effects[PBEffects::Spotlight]>=strength
next if b.fainted? || b.effects[PBEffects::SkyDrop] >= 0
next if b.effects[PBEffects::Spotlight] == 0 ||
b.effects[PBEffects::Spotlight] >= strength
next if !b.opposes?(user)
next if nearOnly && !b.near?(user)
newTarget = b
@@ -117,17 +117,17 @@ class Battle::Battler
if newTarget
PBDebug.log("[Move target changed] #{newTarget.pbThis}'s Spotlight made it the target")
targets = []
pbAddTarget(targets,user,newTarget,move,nearOnly)
pbAddTarget(targets, user, newTarget, move, nearOnly)
return targets
end
# Follow Me/Rage Powder (takes priority over Lightning Rod/Storm Drain)
newTarget = nil
strength = 100 # Lower strength takes priority
priority.each do |b|
next if b.fainted? || b.effects[PBEffects::SkyDrop]>=0
next if b.fainted? || b.effects[PBEffects::SkyDrop] >= 0
next if b.effects[PBEffects::RagePowder] && !user.affectedByPowder?
next if b.effects[PBEffects::FollowMe]==0 ||
b.effects[PBEffects::FollowMe]>=strength
next if b.effects[PBEffects::FollowMe] == 0 ||
b.effects[PBEffects::FollowMe] >= strength
next if !b.opposes?(user)
next if nearOnly && !b.near?(user)
newTarget = b
@@ -136,30 +136,30 @@ class Battle::Battler
if newTarget
PBDebug.log("[Move target changed] #{newTarget.pbThis}'s Follow Me/Rage Powder made it the target")
targets = []
pbAddTarget(targets,user,newTarget,move,nearOnly)
pbAddTarget(targets, user, newTarget, move, nearOnly)
return targets
end
# Lightning Rod
targets = pbChangeTargetByAbility(:LIGHTNINGROD,:ELECTRIC,move,user,targets,priority,nearOnly)
targets = pbChangeTargetByAbility(:LIGHTNINGROD, :ELECTRIC, move, user, targets, priority, nearOnly)
# Storm Drain
targets = pbChangeTargetByAbility(:STORMDRAIN,:WATER,move,user,targets,priority,nearOnly)
targets = pbChangeTargetByAbility(:STORMDRAIN, :WATER, move, user, targets, priority, nearOnly)
return targets
end
def pbChangeTargetByAbility(drawingAbility,drawnType,move,user,targets,priority,nearOnly)
def pbChangeTargetByAbility(drawingAbility, drawnType, move, user, targets, priority, nearOnly)
return targets if move.calcType != drawnType
return targets if targets[0].hasActiveAbility?(drawingAbility)
priority.each do |b|
next if b.index==user.index || b.index==targets[0].index
next if b.index == user.index || b.index == targets[0].index
next if !b.hasActiveAbility?(drawingAbility)
next if nearOnly && !b.near?(user)
@battle.pbShowAbilitySplash(b)
targets.clear
pbAddTarget(targets,user,b,move,nearOnly)
pbAddTarget(targets, user, b, move, nearOnly)
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} took the attack!",b.pbThis))
@battle.pbDisplay(_INTL("{1} took the attack!", b.pbThis))
else
@battle.pbDisplay(_INTL("{1} took the attack with its {2}!",b.pbThis,b.abilityName))
@battle.pbDisplay(_INTL("{1} took the attack with its {2}!", b.pbThis, b.abilityName))
end
@battle.pbHideAbilitySplash(b)
break
@@ -170,11 +170,11 @@ class Battle::Battler
#=============================================================================
# Register target
#=============================================================================
def pbAddTarget(targets,user,target,move,nearOnly = true,allowUser = false)
def pbAddTarget(targets, user, target, move, nearOnly = true, allowUser = false)
return false if !target || (target.fainted? && !move.targetsPosition?)
return false if !allowUser && target == user
return false if nearOnly && !user.near?(target) && target != user
targets.each { |b| return true if b.index==target.index } # Already added
targets.each { |b| return true if b.index == target.index } # Already added
targets.push(target)
return true
end
@@ -185,7 +185,7 @@ class Battle::Battler
next if nearOnly && !user.near?(b)
pbAddTarget(choices, user, b, move, nearOnly)
end
if choices.length>0
if choices.length > 0
pbAddTarget(targets, user, choices[@battle.pbRandom(choices.length)], move, nearOnly)
end
end
@@ -196,7 +196,7 @@ class Battle::Battler
next if nearOnly && !user.near?(b)
pbAddTarget(choices, user, b, move, nearOnly)
end
if choices.length>0
if choices.length > 0
pbAddTarget(targets, user, choices[@battle.pbRandom(choices.length)], move, nearOnly)
end
end

View File

@@ -7,35 +7,35 @@ class Battle::Battler
# earlier in the same round (after choosing the command but before using the
# move) or an unusable move may be called by another move such as Metronome.
#=============================================================================
def pbCanChooseMove?(move,commandPhase,showMessages = true,specialUsage = false)
def pbCanChooseMove?(move, commandPhase, showMessages = true, specialUsage = false)
# Disable
if @effects[PBEffects::DisableMove]==move.id && !specialUsage
if @effects[PBEffects::DisableMove] == move.id && !specialUsage
if showMessages
msg = _INTL("{1}'s {2} is disabled!",pbThis,move.name)
msg = _INTL("{1}'s {2} is disabled!", pbThis, move.name)
(commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg)
end
return false
end
# Heal Block
if @effects[PBEffects::HealBlock]>0 && move.healingMove?
if @effects[PBEffects::HealBlock] > 0 && move.healingMove?
if showMessages
msg = _INTL("{1} can't use {2} because of Heal Block!",pbThis,move.name)
msg = _INTL("{1} can't use {2} because of Heal Block!", pbThis, move.name)
(commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg)
end
return false
end
# Gravity
if @battle.field.effects[PBEffects::Gravity]>0 && move.unusableInGravity?
if @battle.field.effects[PBEffects::Gravity] > 0 && move.unusableInGravity?
if showMessages
msg = _INTL("{1} can't use {2} because of gravity!",pbThis,move.name)
msg = _INTL("{1} can't use {2} because of gravity!", pbThis, move.name)
(commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg)
end
return false
end
# Throat Chop
if @effects[PBEffects::ThroatChop]>0 && move.soundMove?
if @effects[PBEffects::ThroatChop] > 0 && move.soundMove?
if showMessages
msg = _INTL("{1} can't use {2} because of Throat Chop!",pbThis,move.name)
msg = _INTL("{1} can't use {2} because of Throat Chop!", pbThis, move.name)
(commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg)
end
return false
@@ -46,7 +46,7 @@ class Battle::Battler
choiced_move_name = GameData::Move.get(@effects[PBEffects::ChoiceBand]).name
if hasActiveItem?([:CHOICEBAND, :CHOICESPECS, :CHOICESCARF])
if showMessages
msg = _INTL("The {1} only allows the use of {2}!",itemName, choiced_move_name)
msg = _INTL("The {1} only allows the use of {2}!", itemName, choiced_move_name)
(commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg)
end
return false
@@ -59,18 +59,18 @@ class Battle::Battler
end
end
# Taunt
if @effects[PBEffects::Taunt]>0 && move.statusMove?
if @effects[PBEffects::Taunt] > 0 && move.statusMove?
if showMessages
msg = _INTL("{1} can't use {2} after the taunt!",pbThis,move.name)
msg = _INTL("{1} can't use {2} after the taunt!", pbThis, move.name)
(commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg)
end
return false
end
# Torment
if @effects[PBEffects::Torment] && !@effects[PBEffects::Instructed] &&
@lastMoveUsed && move.id==@lastMoveUsed && move.id!=@battle.struggle.id
@lastMoveUsed && move.id == @lastMoveUsed && move.id != @battle.struggle.id
if showMessages
msg = _INTL("{1} can't use the same move twice in a row due to the torment!",pbThis)
msg = _INTL("{1} can't use the same move twice in a row due to the torment!", pbThis)
(commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg)
end
return false
@@ -78,7 +78,7 @@ class Battle::Battler
# Imprison
if @battle.allOtherSideBattlers(@index).any? { |b| b.effects[PBEffects::Imprison] && b.pbHasMove?(move.id) }
if showMessages
msg = _INTL("{1} can't use its sealed {2}!",pbThis,move.name)
msg = _INTL("{1} can't use its sealed {2}!", pbThis, move.name)
(commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg)
end
return false
@@ -94,7 +94,7 @@ class Battle::Battler
return false
end
# Belch
return false if !move.pbCanChooseMove?(self,commandPhase,showMessages)
return false if !move.pbCanChooseMove?(self, commandPhase, showMessages)
return true
end
@@ -105,7 +105,7 @@ class Battle::Battler
# use a different move in disobedience), or false if attack stops.
def pbObedienceCheck?(choice)
return true if usingMultiTurnAttack?
return true if choice[0]!=:UseMove
return true if choice[0] != :UseMove
return true if !@battle.internalBattle
return true if !@battle.pbOwnedByPlayer?(@index)
disobedient = false
@@ -115,61 +115,61 @@ class Battle::Battler
badgeLevel = 10 * (@battle.pbPlayer.badge_count + 1)
badgeLevel = GameData::GrowthRate.max_level if @battle.pbPlayer.badge_count >= 8
if @level > badgeLevel
a = ((@level+badgeLevel)*@battle.pbRandom(256)/256).floor
disobedient |= (a>=badgeLevel)
a = ((@level + badgeLevel) * @battle.pbRandom(256) / 256).floor
disobedient |= (a >= badgeLevel)
end
end
disobedient |= !pbHyperModeObedience(choice[2])
return true if !disobedient
# Pokémon is disobedient; make it do something else
return pbDisobey(choice,badgeLevel)
return pbDisobey(choice, badgeLevel)
end
def pbDisobey(choice,badgeLevel)
def pbDisobey(choice, badgeLevel)
move = choice[2]
PBDebug.log("[Disobedience] #{pbThis} disobeyed")
@effects[PBEffects::Rage] = false
# Do nothing if using Snore/Sleep Talk
if @status == :SLEEP && move.usableWhenAsleep?
@battle.pbDisplay(_INTL("{1} ignored orders and kept sleeping!",pbThis))
@battle.pbDisplay(_INTL("{1} ignored orders and kept sleeping!", pbThis))
return false
end
b = ((@level+badgeLevel)*@battle.pbRandom(256)/256).floor
b = ((@level + badgeLevel) * @battle.pbRandom(256) / 256).floor
# Use another move
if b<badgeLevel
@battle.pbDisplay(_INTL("{1} ignored orders!",pbThis))
if b < badgeLevel
@battle.pbDisplay(_INTL("{1} ignored orders!", pbThis))
return false if !@battle.pbCanShowFightMenu?(@index)
otherMoves = []
eachMoveWithIndex do |_m,i|
next if i==choice[1]
otherMoves.push(i) if @battle.pbCanChooseMove?(@index,i,false)
eachMoveWithIndex do |_m, i|
next if i == choice[1]
otherMoves.push(i) if @battle.pbCanChooseMove?(@index, i, false)
end
return false if otherMoves.length==0 # No other move to use; do nothing
return false if otherMoves.length == 0 # No other move to use; do nothing
newChoice = otherMoves[@battle.pbRandom(otherMoves.length)]
choice[1] = newChoice
choice[2] = @moves[newChoice]
choice[3] = -1
return true
end
c = @level-badgeLevel
c = @level - badgeLevel
r = @battle.pbRandom(256)
# Fall asleep
if r<c && pbCanSleep?(self,false)
pbSleepSelf(_INTL("{1} began to nap!",pbThis))
if r < c && pbCanSleep?(self, false)
pbSleepSelf(_INTL("{1} began to nap!", pbThis))
return false
end
# Hurt self in confusion
r -= c
if r < c && @status != :SLEEP
pbConfusionDamage(_INTL("{1} won't obey! It hurt itself in its confusion!",pbThis))
pbConfusionDamage(_INTL("{1} won't obey! It hurt itself in its confusion!", pbThis))
return false
end
# Show refusal message and do nothing
case @battle.pbRandom(4)
when 0 then @battle.pbDisplay(_INTL("{1} won't obey!",pbThis))
when 1 then @battle.pbDisplay(_INTL("{1} turned away!",pbThis))
when 2 then @battle.pbDisplay(_INTL("{1} is loafing around!",pbThis))
when 3 then @battle.pbDisplay(_INTL("{1} pretended not to notice!",pbThis))
when 0 then @battle.pbDisplay(_INTL("{1} won't obey!", pbThis))
when 1 then @battle.pbDisplay(_INTL("{1} turned away!", pbThis))
when 2 then @battle.pbDisplay(_INTL("{1} is loafing around!", pbThis))
when 3 then @battle.pbDisplay(_INTL("{1} pretended not to notice!", pbThis))
end
return false
end
@@ -179,25 +179,25 @@ class Battle::Battler
# If this returns true, and if PP isn't a problem, the move will be considered
# to have been used (even if it then fails for whatever reason).
#=============================================================================
def pbTryUseMove(choice,move,specialUsage,skipAccuracyCheck)
def pbTryUseMove(choice, move, specialUsage, skipAccuracyCheck)
# Check whether it's possible for self to use the given move
# NOTE: Encore has already changed the move being used, no need to have a
# check for it here.
if !pbCanChooseMove?(move,false,true,specialUsage)
if !pbCanChooseMove?(move, false, true, specialUsage)
@lastMoveFailed = true
return false
end
# Check whether it's possible for self to do anything at all
if @effects[PBEffects::SkyDrop]>=0 # Intentionally no message here
if @effects[PBEffects::SkyDrop] >= 0 # Intentionally no message here
PBDebug.log("[Move failed] #{pbThis} can't use #{move.name} because of being Sky Dropped")
return false
end
if @effects[PBEffects::HyperBeam]>0 # Intentionally before Truant
@battle.pbDisplay(_INTL("{1} must recharge!",pbThis))
if @effects[PBEffects::HyperBeam] > 0 # Intentionally before Truant
@battle.pbDisplay(_INTL("{1} must recharge!", pbThis))
return false
end
if choice[1]==-2 # Battle Palace
@battle.pbDisplay(_INTL("{1} appears incapable of using its power!",pbThis))
if choice[1] == -2 # Battle Palace
@battle.pbDisplay(_INTL("{1} appears incapable of using its power!", pbThis))
return false
end
# Skip checking all applied effects that could make self fail doing something
@@ -206,7 +206,7 @@ class Battle::Battler
case @status
when :SLEEP
self.statusCount -= 1
if @statusCount<=0
if @statusCount <= 0
pbCureStatus
else
pbContinueStatus
@@ -217,7 +217,7 @@ class Battle::Battler
end
when :FROZEN
if !move.thawsUser?
if @battle.pbRandom(100)<20
if @battle.pbRandom(100) < 20
pbCureStatus
else
pbContinueStatus
@@ -233,7 +233,7 @@ class Battle::Battler
@effects[PBEffects::Truant] = !@effects[PBEffects::Truant]
if !@effects[PBEffects::Truant] # True means loafing, but was just inverted
@battle.pbShowAbilitySplash(self)
@battle.pbDisplay(_INTL("{1} is loafing around!",pbThis))
@battle.pbDisplay(_INTL("{1} is loafing around!", pbThis))
@lastMoveFailed = true
@battle.pbHideAbilitySplash(self)
return false
@@ -241,7 +241,7 @@ class Battle::Battler
end
# Flinching
if @effects[PBEffects::Flinch]
@battle.pbDisplay(_INTL("{1} flinched and couldn't move!",pbThis))
@battle.pbDisplay(_INTL("{1} flinched and couldn't move!", pbThis))
if abilityActive?
Battle::AbilityEffects.triggerOnFlinch(self.ability, self, @battle)
end
@@ -249,16 +249,16 @@ class Battle::Battler
return false
end
# Confusion
if @effects[PBEffects::Confusion]>0
if @effects[PBEffects::Confusion] > 0
@effects[PBEffects::Confusion] -= 1
if @effects[PBEffects::Confusion]<=0
if @effects[PBEffects::Confusion] <= 0
pbCureConfusion
@battle.pbDisplay(_INTL("{1} snapped out of its confusion.",pbThis))
@battle.pbDisplay(_INTL("{1} snapped out of its confusion.", pbThis))
else
@battle.pbCommonAnimation("Confusion",self)
@battle.pbDisplay(_INTL("{1} is confused!",pbThis))
@battle.pbCommonAnimation("Confusion", self)
@battle.pbDisplay(_INTL("{1} is confused!", pbThis))
threshold = (Settings::MECHANICS_GENERATION >= 7) ? 33 : 50 # % chance
if @battle.pbRandom(100)<threshold
if @battle.pbRandom(100) < threshold
pbConfusionDamage(_INTL("It hurt itself in its confusion!"))
@lastMoveFailed = true
return false
@@ -267,19 +267,19 @@ class Battle::Battler
end
# Paralysis
if @status == :PARALYSIS
if @battle.pbRandom(100)<25
if @battle.pbRandom(100) < 25
pbContinueStatus
@lastMoveFailed = true
return false
end
end
# Infatuation
if @effects[PBEffects::Attract]>=0
@battle.pbCommonAnimation("Attract",self)
@battle.pbDisplay(_INTL("{1} is in love with {2}!",pbThis,
if @effects[PBEffects::Attract] >= 0
@battle.pbCommonAnimation("Attract", self)
@battle.pbDisplay(_INTL("{1} is in love with {2}!", pbThis,
@battle.battlers[@effects[PBEffects::Attract]].pbThis(true)))
if @battle.pbRandom(100)<50
@battle.pbDisplay(_INTL("{1} is immobilized by love!",pbThis))
if @battle.pbRandom(100) < 50
@battle.pbDisplay(_INTL("{1} is immobilized by love!", pbThis))
@lastMoveFailed = true
return false
end
@@ -293,7 +293,7 @@ class Battle::Battler
#=============================================================================
def pbSuccessCheckAgainstTarget(move, user, target, targets)
show_message = move.pbShowFailMessages?(targets)
typeMod = move.pbCalcTypeMod(move.calcType,user,target)
typeMod = move.pbCalcTypeMod(move.calcType, user, target)
target.damageState.typeMod = typeMod
# Two-turn attacks can't fail here in the charging turn
return true if user.effects[PBEffects::TwoTurnAttack]
@@ -301,12 +301,12 @@ class Battle::Battler
return false if move.pbFailsAgainstTarget?(user, target, show_message)
# Immunity to priority moves because of Psychic Terrain
if @battle.field.terrain == :Psychic && target.affectedByTerrain? && target.opposes?(user) &&
@battle.choices[user.index][4]>0 # Move priority saved from pbCalculatePriority
@battle.choices[user.index][4] > 0 # Move priority saved from pbCalculatePriority
@battle.pbDisplay(_INTL("{1} surrounds itself with psychic terrain!", target.pbThis)) if show_message
return false
end
# Crafty Shield
if target.pbOwnSide.effects[PBEffects::CraftyShield] && user.index!=target.index &&
if target.pbOwnSide.effects[PBEffects::CraftyShield] && user.index != target.index &&
move.statusMove? && !move.pbTarget(user).targets_all
if show_message
@battle.pbCommonAnimation("CraftyShield", target)
@@ -318,7 +318,7 @@ class Battle::Battler
end
if !(user.hasActiveAbility?(:UNSEENFIST) && move.contactMove?)
# Wide Guard
if target.pbOwnSide.effects[PBEffects::WideGuard] && user.index!=target.index &&
if target.pbOwnSide.effects[PBEffects::WideGuard] && user.index != target.index &&
move.pbTarget(user).num_targets > 1 &&
(Settings::MECHANICS_GENERATION >= 7 || move.damagingMove?)
if show_message
@@ -332,7 +332,7 @@ class Battle::Battler
if move.canProtectAgainst?
# Quick Guard
if target.pbOwnSide.effects[PBEffects::QuickGuard] &&
@battle.choices[user.index][4]>0 # Move priority saved from pbCalculatePriority
@battle.choices[user.index][4] > 0 # Move priority saved from pbCalculatePriority
if show_message
@battle.pbCommonAnimation("QuickGuard", target)
@battle.pbDisplay(_INTL("Quick Guard protected {1}!", target.pbThis(true)))
@@ -376,8 +376,8 @@ class Battle::Battler
@battle.successStates[user.index].protected = true
if move.pbContactMove?(user) && user.affectedByContactEffect?
@battle.scene.pbDamageAnimation(user)
user.pbReduceHP(user.totalhp/8,false)
@battle.pbDisplay(_INTL("{1} was hurt!",user.pbThis))
user.pbReduceHP(user.totalhp / 8, false)
@battle.pbDisplay(_INTL("{1} was hurt!", user.pbThis))
user.pbItemHPHealCheck
end
return false
@@ -391,14 +391,14 @@ class Battle::Battler
target.damageState.protected = true
@battle.successStates[user.index].protected = true
if move.pbContactMove?(user) && user.affectedByContactEffect?
user.pbPoison(target) if user.pbCanPoison?(target,false)
user.pbPoison(target) if user.pbCanPoison?(target, false)
end
return false
end
# Obstruct
if target.effects[PBEffects::Obstruct] && move.damagingMove?
if show_message
@battle.pbCommonAnimation("Obstruct",target)
@battle.pbCommonAnimation("Obstruct", target)
@battle.pbDisplay(_INTL("{1} protected itself!", target.pbThis))
end
target.damageState.protected = true
@@ -468,11 +468,11 @@ class Battle::Battler
@battle.pbDisplay(_INTL("{1}'s {2} makes Ground moves miss!", target.pbThis, target.itemName)) if show_message
return false
end
if target.effects[PBEffects::MagnetRise]>0
if target.effects[PBEffects::MagnetRise] > 0
@battle.pbDisplay(_INTL("{1} makes Ground moves miss with Magnet Rise!", target.pbThis)) if show_message
return false
end
if target.effects[PBEffects::Telekinesis]>0
if target.effects[PBEffects::Telekinesis] > 0
@battle.pbDisplay(_INTL("{1} makes Ground moves miss with Telekinesis!", target.pbThis)) if show_message
return false
end
@@ -505,8 +505,8 @@ class Battle::Battler
end
end
# Substitute
if target.effects[PBEffects::Substitute]>0 && move.statusMove? &&
!move.ignoresSubstitute?(user) && user.index!=target.index
if target.effects[PBEffects::Substitute] > 0 && move.statusMove? &&
!move.ignoresSubstitute?(user) && user.index != target.index
PBDebug.log("[Target immune] #{target.pbThis} is protected by its Substitute")
@battle.pbDisplay(_INTL("{1} avoided the attack!", target.pbThis(true))) if show_message
return false
@@ -518,14 +518,14 @@ class Battle::Battler
# Per-hit success check against the target.
# Includes semi-invulnerable move use and accuracy calculation.
#=============================================================================
def pbSuccessCheckPerHit(move,user,target,skipAccuracyCheck)
def pbSuccessCheckPerHit(move, user, target, skipAccuracyCheck)
# Two-turn attacks can't fail here in the charging turn
return true if user.effects[PBEffects::TwoTurnAttack]
# Lock-On
return true if user.effects[PBEffects::LockOn]>0 &&
user.effects[PBEffects::LockOnPos]==target.index
return true if user.effects[PBEffects::LockOn] > 0 &&
user.effects[PBEffects::LockOnPos] == target.index
# Toxic
return true if move.pbOverrideSuccessCheckPerHit(user,target)
return true if move.pbOverrideSuccessCheckPerHit(user, target)
miss = false
hitsInvul = false
# No Guard
@@ -534,7 +534,7 @@ class Battle::Battler
# Future Sight
hitsInvul = true if @battle.futureSight
# Helping Hand
hitsInvul = true if move.function=="PowerUpAllyMove"
hitsInvul = true if move.function == "PowerUpAllyMove"
if !hitsInvul
# Semi-invulnerable moves
if target.effects[PBEffects::TwoTurnAttack]
@@ -550,8 +550,8 @@ class Battle::Battler
miss = true
end
end
if target.effects[PBEffects::SkyDrop]>=0 &&
target.effects[PBEffects::SkyDrop]!=user.index
if target.effects[PBEffects::SkyDrop] >= 0 &&
target.effects[PBEffects::SkyDrop] != user.index
miss = true if !move.hitsFlyingTargets?
end
end
@@ -560,7 +560,7 @@ class Battle::Battler
# Called by another move
return true if skipAccuracyCheck
# Accuracy check
return true if move.pbAccuracyCheck(user,target) # Includes Counter/Mirror Coat
return true if move.pbAccuracyCheck(user, target) # Includes Counter/Mirror Coat
end
# Missed
PBDebug.log("[Move failed] Failed pbAccuracyCheck or target is semi-invulnerable")
@@ -570,15 +570,15 @@ class Battle::Battler
#=============================================================================
# Message shown when a move fails the per-hit success check above.
#=============================================================================
def pbMissMessage(move,user,target)
def pbMissMessage(move, user, target)
if target.damageState.affection_missed
@battle.pbDisplay(_INTL("{1} avoided the move in time with your shout!", target.pbThis))
elsif move.pbTarget(user).num_targets > 1
@battle.pbDisplay(_INTL("{1} avoided the attack!",target.pbThis))
@battle.pbDisplay(_INTL("{1} avoided the attack!", target.pbThis))
elsif target.effects[PBEffects::TwoTurnAttack]
@battle.pbDisplay(_INTL("{1} avoided the attack!",target.pbThis))
elsif !move.pbMissMessage(user,target)
@battle.pbDisplay(_INTL("{1}'s attack missed!",user.pbThis))
@battle.pbDisplay(_INTL("{1} avoided the attack!", target.pbThis))
elsif !move.pbMissMessage(user, target)
@battle.pbDisplay(_INTL("{1}'s attack missed!", user.pbThis))
end
end
end

View File

@@ -2,13 +2,13 @@ class Battle::Battler
#=============================================================================
# Effect per hit
#=============================================================================
def pbEffectsOnMakingHit(move,user,target)
if target.damageState.calcDamage>0 && !target.damageState.substitute
def pbEffectsOnMakingHit(move, user, target)
if target.damageState.calcDamage > 0 && !target.damageState.substitute
# Target's ability
if target.abilityActive?(true)
oldHP = user.hp
Battle::AbilityEffects.triggerOnBeingHit(target.ability, user, target, move, @battle)
user.pbItemHPHealCheck if user.hp<oldHP
user.pbItemHPHealCheck if user.hp < oldHP
end
# Cramorant - Gulp Missile
if target.isSpecies?(:CRAMORANT) && target.ability == :GULPMISSILE &&
@@ -39,28 +39,28 @@ class Battle::Battler
if target.itemActive?(true)
oldHP = user.hp
Battle::ItemEffects.triggerOnBeingHit(target.item, user, target, move, @battle)
user.pbItemHPHealCheck if user.hp<oldHP
user.pbItemHPHealCheck if user.hp < oldHP
end
end
if target.opposes?(user)
# Rage
if target.effects[PBEffects::Rage] && !target.fainted?
if target.pbCanRaiseStatStage?(:ATTACK,target)
@battle.pbDisplay(_INTL("{1}'s rage is building!",target.pbThis))
target.pbRaiseStatStage(:ATTACK,1,target)
if target.pbCanRaiseStatStage?(:ATTACK, target)
@battle.pbDisplay(_INTL("{1}'s rage is building!", target.pbThis))
target.pbRaiseStatStage(:ATTACK, 1, target)
end
end
# Beak Blast
if target.effects[PBEffects::BeakBlast]
PBDebug.log("[Lingering effect] #{target.pbThis}'s Beak Blast")
if move.pbContactMove?(user) && user.affectedByContactEffect?
target.pbBurn(user) if target.pbCanBurn?(user,false,self)
target.pbBurn(user) if target.pbCanBurn?(user, false, self)
end
end
# Shell Trap (make the trapper move next if the trap was triggered)
if target.effects[PBEffects::ShellTrap] &&
@battle.choices[target.index][0]==:UseMove && !target.movedThisRound?
if target.damageState.hpLost>0 && !target.damageState.substitute && move.physicalMove?
@battle.choices[target.index][0] == :UseMove && !target.movedThisRound?
if target.damageState.hpLost > 0 && !target.damageState.substitute && move.physicalMove?
target.tookPhysicalHit = true
target.effects[PBEffects::MoveNext] = true
target.effects[PBEffects::Quash] = 0
@@ -70,11 +70,11 @@ class Battle::Battler
if target.effects[PBEffects::Grudge] && target.fainted?
move.pp = 0
@battle.pbDisplay(_INTL("{1}'s {2} lost all of its PP due to the grudge!",
user.pbThis,move.name))
user.pbThis, move.name))
end
# Destiny Bond (recording that it should apply)
if target.effects[PBEffects::DestinyBond] && target.fainted?
if user.effects[PBEffects::DestinyBondTarget]<0
if user.effects[PBEffects::DestinyBondTarget] < 0
user.effects[PBEffects::DestinyBondTarget] = target.index
end
end
@@ -84,7 +84,7 @@ class Battle::Battler
#=============================================================================
# Effects after all hits (i.e. at end of move usage)
#=============================================================================
def pbEffectsAfterMove(user,targets,move,numHits)
def pbEffectsAfterMove(user, targets, move, numHits)
# Defrost
if move.damagingMove?
targets.each do |b|
@@ -101,10 +101,10 @@ class Battle::Battler
# NOTE: Although Destiny Bond is similar to Grudge, they don't apply at
# the same time (although Destiny Bond does check whether it's going
# to trigger at the same time as Grudge).
if user.effects[PBEffects::DestinyBondTarget]>=0 && !user.fainted?
if user.effects[PBEffects::DestinyBondTarget] >= 0 && !user.fainted?
dbName = @battle.battlers[user.effects[PBEffects::DestinyBondTarget]].pbThis
@battle.pbDisplay(_INTL("{1} took its attacker down with it!",dbName))
user.pbReduceHP(user.hp,false)
@battle.pbDisplay(_INTL("{1} took its attacker down with it!", dbName))
user.pbReduceHP(user.hp, false)
user.pbItemHPHealCheck
user.pbFaint
@battle.pbJudgeCheckpoint(user)
@@ -117,15 +117,15 @@ class Battle::Battler
if !user.fainted? && !user.effects[PBEffects::Transform] &&
user.isSpecies?(:GRENINJA) && user.ability == :BATTLEBOND
if !@battle.pbAllFainted?(user.idxOpposingSide) &&
!@battle.battleBond[user.index&1][user.pokemonIndex]
!@battle.battleBond[user.index & 1][user.pokemonIndex]
numFainted = 0
targets.each { |b| numFainted += 1 if b.damageState.fainted }
if numFainted>0 && user.form==1
@battle.battleBond[user.index&1][user.pokemonIndex] = true
@battle.pbDisplay(_INTL("{1} became fully charged due to its bond with its Trainer!",user.pbThis))
@battle.pbShowAbilitySplash(user,true)
if numFainted > 0 && user.form == 1
@battle.battleBond[user.index & 1][user.pokemonIndex] = true
@battle.pbDisplay(_INTL("{1} became fully charged due to its bond with its Trainer!", user.pbThis))
@battle.pbShowAbilitySplash(user, true)
@battle.pbHideAbilitySplash(user)
user.pbChangeForm(2,_INTL("{1} became Ash-Greninja!",user.pbThis))
user.pbChangeForm(2, _INTL("{1} became Ash-Greninja!", user.pbThis))
end
end
end
@@ -165,13 +165,13 @@ class Battle::Battler
# U-turn/Volt Switch/Baton Pass/Parting Shot, Relic Song's form changing,
# Fling/Natural Gift consuming item.
if !switched_battlers.include?(user.index)
move.pbEndOfMoveUsageEffect(user,targets,numHits,switched_battlers)
move.pbEndOfMoveUsageEffect(user, targets, numHits, switched_battlers)
end
# User's ability/item that switches the user out (all negated by Sheer Force)
if !(user.hasActiveAbility?(:SHEERFORCE) && move.addlEffect > 0)
pbEffectsAfterMove3(user, targets, move, numHits, switched_battlers)
end
if numHits>0
if numHits > 0
@battle.allBattlers.each { |b| b.pbItemEndOfMoveCheck }
end
end
@@ -180,7 +180,7 @@ class Battle::Battler
def pbEffectsAfterMove2(user, targets, move, numHits, switched_battlers)
# Target's held item (Eject Button, Red Card, Eject Pack)
@battle.pbPriority(true).each do |b|
if targets.any? { |targetB| targetB.index==b.index }
if targets.any? { |targetB| targetB.index == b.index }
if !b.damageState.unaffected && b.damageState.calcDamage > 0 && b.itemActive?
Battle::ItemEffects.triggerAfterMoveUseFromTarget(b.item, b, user, move, switched_battlers, @battle)
end
@@ -198,7 +198,7 @@ class Battle::Battler
end
# Target's ability (Berserk, Color Change, Emergency Exit, Pickpocket, Wimp Out)
@battle.pbPriority(true).each do |b|
if targets.any? { |targetB| targetB.index==b.index }
if targets.any? { |targetB| targetB.index == b.index }
if !b.damageState.unaffected && !switched_battlers.include?(b.index) && b.abilityActive?
Battle::AbilityEffects.triggerAfterMoveUseFromTarget(b.ability, b, user, move, switched_battlers, @battle)
end

View File

@@ -67,7 +67,7 @@ class Battle::Move
def pbTarget(_user); return GameData::Target.get(@target); end
def total_pp
return @total_pp if @total_pp && @total_pp>0 # Usually undefined
return @total_pp if @total_pp && @total_pp > 0 # Usually undefined
return @realMove.total_pp if @realMove
return 0
end
@@ -75,7 +75,7 @@ class Battle::Move
# NOTE: This method is only ever called while using a move (and also by the
# AI), so using @calcType here is acceptable.
def physicalMove?(thisType = nil)
return (@category==0) if Settings::MOVE_CATEGORY_PER_MOVE
return (@category == 0) if Settings::MOVE_CATEGORY_PER_MOVE
thisType ||= @calcType
thisType ||= @type
return true if !thisType
@@ -85,15 +85,15 @@ class Battle::Move
# NOTE: This method is only ever called while using a move (and also by the
# AI), so using @calcType here is acceptable.
def specialMove?(thisType = nil)
return (@category==1) if Settings::MOVE_CATEGORY_PER_MOVE
return (@category == 1) if Settings::MOVE_CATEGORY_PER_MOVE
thisType ||= @calcType
thisType ||= @type
return false if !thisType
return GameData::Type.get(thisType).special?
end
def damagingMove?; return @category!=2; end
def statusMove?; return @category==2; end
def damagingMove?; return @category != 2; end
def statusMove?; return @category == 2; end
def pbPriority(user); return @priority; end
@@ -135,7 +135,7 @@ class Battle::Move
# Causes perfect accuracy (param=1) and double damage (param=2).
def tramplesMinimize?(_param = 1); return false; end
def nonLethal?(_user,_target); return false; end # For False Swipe
def nonLethal?(_user, _target); return false; end # For False Swipe
def ignoresSubstitute?(user) # user is the Pokémon using this move
if Settings::MECHANICS_GENERATION >= 6

View File

@@ -2,14 +2,14 @@ class Battle::Move
#=============================================================================
# Effect methods per move usage
#=============================================================================
def pbCanChooseMove?(user,commandPhase,showMessages); return true; end # For Belch
def pbCanChooseMove?(user, commandPhase, showMessages); return true; end # For Belch
def pbDisplayChargeMessage(user); end # For Focus Punch/shell Trap/Beak Blast
def pbOnStartUse(user,targets); end
def pbAddTarget(targets,user); end # For Counter, etc. and Bide
def pbOnStartUse(user, targets); end
def pbAddTarget(targets, user); end # For Counter, etc. and Bide
def pbModifyTargets(targets, user); end # For Dragon Darts
# Reset move usage counters (child classes can increment them).
def pbChangeUsageCounters(user,specialUsage)
def pbChangeUsageCounters(user, specialUsage)
user.effects[PBEffects::FuryCutter] = 0
user.effects[PBEffects::ParentalBond] = 0
user.effects[PBEffects::ProtectRate] = 1
@@ -18,11 +18,11 @@ class Battle::Move
end
def pbDisplayUseMessage(user)
@battle.pbDisplayBrief(_INTL("{1} used {2}!",user.pbThis,@name))
@battle.pbDisplayBrief(_INTL("{1} used {2}!", user.pbThis, @name))
end
def pbShowFailMessages?(targets); return true; end
def pbMissMessage(user,target); return false; end
def pbMissMessage(user, target); return false; end
#=============================================================================
#
@@ -42,9 +42,9 @@ class Battle::Move
# The maximum number of hits in a round this move will actually perform. This
# can be 1 for Beat Up, and can be 2 for any moves affected by Parental Bond.
def pbNumHits(user,targets)
def pbNumHits(user, targets)
if user.hasActiveAbility?(:PARENTALBOND) && pbDamagingMove? &&
!chargingTurnMove? && targets.length==1
!chargingTurnMove? && targets.length == 1
# Record that Parental Bond applies, to weaken the second attack
user.effects[PBEffects::ParentalBond] = 3
return 2
@@ -55,29 +55,29 @@ class Battle::Move
#=============================================================================
# Effect methods per hit
#=============================================================================
def pbOverrideSuccessCheckPerHit(user,target); return false; end
def pbOverrideSuccessCheckPerHit(user, target); return false; end
def pbCrashDamage(user); end
def pbInitialEffect(user,targets,hitNum); end
def pbInitialEffect(user, targets, hitNum); end
def pbDesignateTargetsForHit(targets, hitNum); return targets; end # For Dragon Darts
def pbRepeatHit?; return false; end # For Dragon Darts
def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true)
def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true)
return if !showAnimation
if user.effects[PBEffects::ParentalBond]==1
@battle.pbCommonAnimation("ParentalBond",user,targets)
if user.effects[PBEffects::ParentalBond] == 1
@battle.pbCommonAnimation("ParentalBond", user, targets)
else
@battle.pbAnimation(id,user,targets,hitNum)
@battle.pbAnimation(id, user, targets, hitNum)
end
end
def pbSelfKO(user); end
def pbEffectWhenDealingDamage(user,target); end
def pbEffectAgainstTarget(user,target); end
def pbEffectWhenDealingDamage(user, target); end
def pbEffectAgainstTarget(user, target); end
def pbEffectGeneral(user); end
def pbAdditionalEffect(user,target); end
def pbEffectAfterAllHits(user,target); end # Move effects that occur after all hits
def pbAdditionalEffect(user, target); end
def pbEffectAfterAllHits(user, target); end # Move effects that occur after all hits
def pbSwitchOutTargetEffect(user, targets, numHits, switched_battlers); end
def pbEndOfMoveUsageEffect(user,targets,numHits,switchedBattlers); end
def pbEndOfMoveUsageEffect(user, targets, numHits, switchedBattlers); end
#=============================================================================
# Check if target is immune to the move because of its ability
@@ -96,7 +96,7 @@ class Battle::Move
# Move failure checks
#=============================================================================
# Check whether the move fails completely due to move-specific requirements.
def pbMoveFailed?(user,targets); return false; end
def pbMoveFailed?(user, targets); return false; end
# Checks whether the move will be ineffective against the target.
def pbFailsAgainstTarget?(user, target, show_message); return false; end
@@ -114,24 +114,24 @@ class Battle::Move
end
def pbMoveFailedTargetAlreadyMoved?(target, showMessage = true)
if (@battle.choices[target.index][0]!=:UseMove &&
@battle.choices[target.index][0]!=:Shift) || target.movedThisRound?
if (@battle.choices[target.index][0] != :UseMove &&
@battle.choices[target.index][0] != :Shift) || target.movedThisRound?
@battle.pbDisplay(_INTL("But it failed!")) if showMessage
return true
end
return false
end
def pbMoveFailedAromaVeil?(user,target,showMessage = true)
def pbMoveFailedAromaVeil?(user, target, showMessage = true)
return false if @battle.moldBreaker
if target.hasActiveAbility?(:AROMAVEIL)
if showMessage
@battle.pbShowAbilitySplash(target)
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} is unaffected!",target.pbThis))
@battle.pbDisplay(_INTL("{1} is unaffected!", target.pbThis))
else
@battle.pbDisplay(_INTL("{1} is unaffected because of its {2}!",
target.pbThis,target.abilityName))
target.pbThis, target.abilityName))
end
@battle.pbHideAbilitySplash(target)
end
@@ -142,10 +142,10 @@ class Battle::Move
if showMessage
@battle.pbShowAbilitySplash(target)
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} is unaffected!",target.pbThis))
@battle.pbDisplay(_INTL("{1} is unaffected!", target.pbThis))
else
@battle.pbDisplay(_INTL("{1} is unaffected because of {2}'s {3}!",
target.pbThis,b.pbThis(true),b.abilityName))
target.pbThis, b.pbThis(true), b.abilityName))
end
@battle.pbHideAbilitySplash(target)
end
@@ -157,10 +157,10 @@ class Battle::Move
#=============================================================================
# Weaken the damage dealt (doesn't actually change a battler's HP)
#=============================================================================
def pbCheckDamageAbsorption(user,target)
def pbCheckDamageAbsorption(user, target)
# Substitute will take the damage
if target.effects[PBEffects::Substitute]>0 && !ignoresSubstitute?(user) &&
(!user || user.index!=target.index)
if target.effects[PBEffects::Substitute] > 0 && !ignoresSubstitute?(user) &&
(!user || user.index != target.index)
target.damageState.substitute = true
return
end
@@ -172,17 +172,17 @@ class Battle::Move
end
# Disguise will take the damage
if !@battle.moldBreaker && target.isSpecies?(:MIMIKYU) &&
target.form==0 && target.ability == :DISGUISE
target.form == 0 && target.ability == :DISGUISE
target.damageState.disguise = true
return
end
end
def pbReduceDamage(user,target)
def pbReduceDamage(user, target)
damage = target.damageState.calcDamage
# Substitute takes the damage
if target.damageState.substitute
damage = target.effects[PBEffects::Substitute] if damage>target.effects[PBEffects::Substitute]
damage = target.effects[PBEffects::Substitute] if damage > target.effects[PBEffects::Substitute]
target.damageState.hpLost = damage
target.damageState.totalHPLost += damage
return
@@ -190,22 +190,22 @@ class Battle::Move
# Disguise/Ice Face takes the damage
return if target.damageState.disguise || target.damageState.iceFace
# Target takes the damage
if damage>=target.hp
if damage >= target.hp
damage = target.hp
# Survive a lethal hit with 1 HP effects
if nonLethal?(user,target)
if nonLethal?(user, target)
damage -= 1
elsif target.effects[PBEffects::Endure]
target.damageState.endured = true
damage -= 1
elsif damage==target.totalhp
elsif damage == target.totalhp
if target.hasActiveAbility?(:STURDY) && !@battle.moldBreaker
target.damageState.sturdy = true
damage -= 1
elsif target.hasActiveItem?(:FOCUSSASH) && target.hp==target.totalhp
elsif target.hasActiveItem?(:FOCUSSASH) && target.hp == target.totalhp
target.damageState.focusSash = true
damage -= 1
elsif target.hasActiveItem?(:FOCUSBAND) && @battle.pbRandom(100)<10
elsif target.hasActiveItem?(:FOCUSBAND) && @battle.pbRandom(100) < 10
target.damageState.focusBand = true
damage -= 1
elsif Settings::AFFECTION_EFFECTS && @battle.internalBattle &&
@@ -218,7 +218,7 @@ class Battle::Move
end
end
end
damage = 0 if damage<0
damage = 0 if damage < 0
target.damageState.hpLost = damage
target.damageState.totalHPLost += damage
end
@@ -238,14 +238,14 @@ class Battle::Move
# Animate the damage dealt, including lowering the HP
#=============================================================================
# Animate being damaged and losing HP (by a move)
def pbAnimateHitAndHPLost(user,targets)
def pbAnimateHitAndHPLost(user, targets)
# Animate allies first, then foes
animArray = []
for side in 0...2 # side here means "allies first, then foes"
targets.each do |b|
next if b.damageState.unaffected || b.damageState.hpLost==0
next if (side==0 && b.opposes?(user)) || (side==1 && !b.opposes?(user))
oldHP = b.hp+b.damageState.hpLost
next if b.damageState.unaffected || b.damageState.hpLost == 0
next if (side == 0 && b.opposes?(user)) || (side == 1 && !b.opposes?(user))
oldHP = b.hp + b.damageState.hpLost
PBDebug.log("[Move damage] #{b.pbThis} lost #{b.damageState.hpLost} HP (#{oldHP}=>#{b.hp})")
effectiveness = 0
if Effectiveness.resistant?(b.damageState.typeMod)
@@ -253,9 +253,9 @@ class Battle::Move
elsif Effectiveness.super_effective?(b.damageState.typeMod)
effectiveness = 2
end
animArray.push([b,oldHP,effectiveness])
animArray.push([b, oldHP, effectiveness])
end
if animArray.length>0
if animArray.length > 0
@battle.scene.pbHitAndHPLossAnimation(animArray)
animArray.clear
end
@@ -265,27 +265,27 @@ class Battle::Move
#=============================================================================
# Messages upon being hit
#=============================================================================
def pbEffectivenessMessage(user,target,numTargets = 1)
def pbEffectivenessMessage(user, target, numTargets = 1)
return if target.damageState.disguise || target.damageState.iceFace
if Effectiveness.super_effective?(target.damageState.typeMod)
if numTargets>1
@battle.pbDisplay(_INTL("It's super effective on {1}!",target.pbThis(true)))
if numTargets > 1
@battle.pbDisplay(_INTL("It's super effective on {1}!", target.pbThis(true)))
else
@battle.pbDisplay(_INTL("It's super effective!"))
end
elsif Effectiveness.not_very_effective?(target.damageState.typeMod)
if numTargets>1
@battle.pbDisplay(_INTL("It's not very effective on {1}...",target.pbThis(true)))
if numTargets > 1
@battle.pbDisplay(_INTL("It's not very effective on {1}...", target.pbThis(true)))
else
@battle.pbDisplay(_INTL("It's not very effective..."))
end
end
end
def pbHitEffectivenessMessages(user,target,numTargets = 1)
def pbHitEffectivenessMessages(user, target, numTargets = 1)
return if target.damageState.disguise || target.damageState.iceFace
if target.damageState.substitute
@battle.pbDisplay(_INTL("The substitute took damage for {1}!",target.pbThis(true)))
@battle.pbDisplay(_INTL("The substitute took damage for {1}!", target.pbThis(true)))
end
if target.damageState.critical
if $game_temp.party_critical_hits_dealt && user.pbOwnedByPlayer?
@@ -307,12 +307,12 @@ class Battle::Move
end
end
# Effectiveness message, for moves with 1 hit
if !multiHitMove? && user.effects[PBEffects::ParentalBond]==0
pbEffectivenessMessage(user,target,numTargets)
if !multiHitMove? && user.effects[PBEffects::ParentalBond] == 0
pbEffectivenessMessage(user, target, numTargets)
end
if target.damageState.substitute && target.effects[PBEffects::Substitute]==0
if target.damageState.substitute && target.effects[PBEffects::Substitute] == 0
target.effects[PBEffects::Substitute] = 0
@battle.pbDisplay(_INTL("{1}'s substitute faded!",target.pbThis))
@battle.pbDisplay(_INTL("{1}'s substitute faded!", target.pbThis))
end
end
@@ -322,10 +322,10 @@ class Battle::Move
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("Its disguise served it as a decoy!"))
else
@battle.pbDisplay(_INTL("{1}'s disguise served it as a decoy!",target.pbThis))
@battle.pbDisplay(_INTL("{1}'s disguise served it as a decoy!", target.pbThis))
end
@battle.pbHideAbilitySplash(target)
target.pbChangeForm(1,_INTL("{1}'s disguise was busted!",target.pbThis))
target.pbChangeForm(1, _INTL("{1}'s disguise was busted!", target.pbThis))
target.pbReduceHP(target.totalhp / 8, false) if Settings::MECHANICS_GENERATION >= 8
elsif target.damageState.iceFace
@battle.pbShowAbilitySplash(target)
@@ -335,36 +335,36 @@ class Battle::Move
target.pbChangeForm(1, _INTL("{1} transformed!", target.pbThis))
@battle.pbHideAbilitySplash(target)
elsif target.damageState.endured
@battle.pbDisplay(_INTL("{1} endured the hit!",target.pbThis))
@battle.pbDisplay(_INTL("{1} endured the hit!", target.pbThis))
elsif target.damageState.sturdy
@battle.pbShowAbilitySplash(target)
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} endured the hit!",target.pbThis))
@battle.pbDisplay(_INTL("{1} endured the hit!", target.pbThis))
else
@battle.pbDisplay(_INTL("{1} hung on with Sturdy!",target.pbThis))
@battle.pbDisplay(_INTL("{1} hung on with Sturdy!", target.pbThis))
end
@battle.pbHideAbilitySplash(target)
elsif target.damageState.focusSash
@battle.pbCommonAnimation("UseItem",target)
@battle.pbDisplay(_INTL("{1} hung on using its Focus Sash!",target.pbThis))
@battle.pbCommonAnimation("UseItem", target)
@battle.pbDisplay(_INTL("{1} hung on using its Focus Sash!", target.pbThis))
target.pbConsumeItem
elsif target.damageState.focusBand
@battle.pbCommonAnimation("UseItem",target)
@battle.pbDisplay(_INTL("{1} hung on using its Focus Band!",target.pbThis))
@battle.pbCommonAnimation("UseItem", target)
@battle.pbDisplay(_INTL("{1} hung on using its Focus Band!", target.pbThis))
elsif target.damageState.affection_endured
@battle.pbDisplay(_INTL("{1} toughed it out so you wouldn't feel sad!", target.pbThis))
end
end
# Used by Counter/Mirror Coat/Metal Burst/Revenge/Focus Punch/Bide/Assurance.
def pbRecordDamageLost(user,target)
def pbRecordDamageLost(user, target)
damage = target.damageState.hpLost
# NOTE: In Gen 3 where a move's category depends on its type, Hidden Power
# is for some reason countered by Counter rather than Mirror Coat,
# regardless of its calculated type. Hence the following two lines of
# code.
moveType = nil
moveType = :NORMAL if @function=="TypeDependsOnUserIVs" # Hidden Power
moveType = :NORMAL if @function == "TypeDependsOnUserIVs" # Hidden Power
if physicalMove?(moveType)
target.effects[PBEffects::Counter] = damage
target.effects[PBEffects::CounterTarget] = user.index
@@ -372,7 +372,7 @@ class Battle::Move
target.effects[PBEffects::MirrorCoat] = damage
target.effects[PBEffects::MirrorCoatTarget] = user.index
end
if target.effects[PBEffects::Bide]>0
if target.effects[PBEffects::Bide] > 0
target.effects[PBEffects::BideDamage] += damage
target.effects[PBEffects::BideTarget] = user.index
end

View File

@@ -29,7 +29,7 @@ class Battle::Move
#=============================================================================
# Type effectiveness calculation
#=============================================================================
def pbCalcTypeModSingle(moveType,defType,user,target)
def pbCalcTypeModSingle(moveType, defType, user, target)
ret = Effectiveness.calculate_one(moveType, defType)
# Ring Target
if target.hasActiveItem?(:RINGTARGET)
@@ -57,7 +57,7 @@ class Battle::Move
return ret
end
def pbCalcTypeMod(moveType,user,target)
def pbCalcTypeMod(moveType, user, target)
return Effectiveness::NORMAL_EFFECTIVE if !moveType
return Effectiveness::NORMAL_EFFECTIVE if moveType == :GROUND &&
target.pbHasType?(:FLYING) &&
@@ -73,8 +73,8 @@ class Battle::Move
typeMods[0] = Effectiveness::SUPER_EFFECTIVE_ONE
end
else
tTypes.each_with_index do |type,i|
typeMods[i] = pbCalcTypeModSingle(moveType,type,user,target)
tTypes.each_with_index do |type, i|
typeMods[i] = pbCalcTypeModSingle(moveType, type, user, target)
end
end
# Multiply all effectivenesses together
@@ -87,15 +87,15 @@ class Battle::Move
#=============================================================================
# Accuracy check
#=============================================================================
def pbBaseAccuracy(user,target); return @accuracy; end
def pbBaseAccuracy(user, target); return @accuracy; end
# Accuracy calculations for one-hit KO moves are handled elsewhere.
def pbAccuracyCheck(user,target)
def pbAccuracyCheck(user, target)
# "Always hit" effects and "always hit" accuracy
return true if target.effects[PBEffects::Telekinesis]>0
return true if target.effects[PBEffects::Telekinesis] > 0
return true if target.effects[PBEffects::Minimize] && tramplesMinimize?(1)
baseAcc = pbBaseAccuracy(user,target)
return true if baseAcc==0
baseAcc = pbBaseAccuracy(user, target)
return true if baseAcc == 0
# Calculate all multiplier effects
modifiers = {}
modifiers[:base_accuracy] = baseAcc
@@ -103,14 +103,14 @@ class Battle::Move
modifiers[:evasion_stage] = target.stages[:EVASION]
modifiers[:accuracy_multiplier] = 1.0
modifiers[:evasion_multiplier] = 1.0
pbCalcAccuracyModifiers(user,target,modifiers)
pbCalcAccuracyModifiers(user, target, modifiers)
# Check if move can't miss
return true if modifiers[:base_accuracy] == 0
# Calculation
accStage = [[modifiers[:accuracy_stage], -6].max, 6].min + 6
evaStage = [[modifiers[:evasion_stage], -6].max, 6].min + 6
stageMul = [3,3,3,3,3,3, 3, 4,5,6,7,8,9]
stageDiv = [9,8,7,6,5,4, 3, 3,3,3,3,3,3]
stageMul = [3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9]
stageDiv = [9, 8, 7, 6, 5, 4, 3, 3, 3, 3, 3, 3, 3]
accuracy = 100.0 * stageMul[accStage] / stageDiv[accStage]
evasion = 100.0 * stageMul[evaStage] / stageDiv[evaStage]
accuracy = (accuracy * modifiers[:accuracy_multiplier]).round
@@ -128,29 +128,29 @@ class Battle::Move
return r < threshold
end
def pbCalcAccuracyModifiers(user,target,modifiers)
def pbCalcAccuracyModifiers(user, target, modifiers)
# Ability effects that alter accuracy calculation
if user.abilityActive?
Battle::AbilityEffects.triggerAccuracyCalcFromUser(user.ability,
modifiers,user,target,self,@calcType)
modifiers, user, target, self, @calcType)
end
user.allAllies.each do |b|
next if !b.abilityActive?
Battle::AbilityEffects.triggerAccuracyCalcFromAlly(b.ability,
modifiers,user,target,self,@calcType)
modifiers, user, target, self, @calcType)
end
if target.abilityActive? && !@battle.moldBreaker
Battle::AbilityEffects.triggerAccuracyCalcFromTarget(target.ability,
modifiers,user,target,self,@calcType)
modifiers, user, target, self, @calcType)
end
# Item effects that alter accuracy calculation
if user.itemActive?
Battle::ItemEffects.triggerAccuracyCalcFromUser(user.item,
modifiers,user,target,self,@calcType)
modifiers, user, target, self, @calcType)
end
if target.itemActive?
Battle::ItemEffects.triggerAccuracyCalcFromTarget(target.item,
modifiers,user,target,self,@calcType)
modifiers, user, target, self, @calcType)
end
# Other effects, inc. ones that set accuracy_multiplier or evasion_stage to
# specific values
@@ -172,41 +172,41 @@ class Battle::Move
# -1: Never a critical hit.
# 0: Calculate normally.
# 1: Always a critical hit.
def pbCritialOverride(user,target); return 0; end
def pbCritialOverride(user, target); return 0; end
# Returns whether the move will be a critical hit.
def pbIsCritical?(user,target)
return false if target.pbOwnSide.effects[PBEffects::LuckyChant]>0
def pbIsCritical?(user, target)
return false if target.pbOwnSide.effects[PBEffects::LuckyChant] > 0
# Set up the critical hit ratios
ratios = (Settings::NEW_CRITICAL_HIT_RATE_MECHANICS) ? [24,8,2,1] : [16,8,4,3,2]
ratios = (Settings::NEW_CRITICAL_HIT_RATE_MECHANICS) ? [24, 8, 2, 1] : [16, 8, 4, 3, 2]
c = 0
# Ability effects that alter critical hit rate
if c>=0 && user.abilityActive?
if c >= 0 && user.abilityActive?
c = Battle::AbilityEffects.triggerCriticalCalcFromUser(user.ability, user, target, c)
end
if c>=0 && target.abilityActive? && !@battle.moldBreaker
if c >= 0 && target.abilityActive? && !@battle.moldBreaker
c = Battle::AbilityEffects.triggerCriticalCalcFromTarget(target.ability, user, target, c)
end
# Item effects that alter critical hit rate
if c>=0 && user.itemActive?
if c >= 0 && user.itemActive?
c = Battle::ItemEffects.triggerCriticalCalcFromUser(user.item, user, target, c)
end
if c>=0 && target.itemActive?
if c >= 0 && target.itemActive?
c = Battle::ItemEffects.triggerCriticalCalcFromTarget(target.item, user, target, c)
end
return false if c<0
return false if c < 0
# Move-specific "always/never a critical hit" effects
case pbCritialOverride(user,target)
case pbCritialOverride(user, target)
when 1 then return true
when -1 then return false
end
# Other effects
return true if c>50 # Merciless
return true if user.effects[PBEffects::LaserFocus]>0
return true if c > 50 # Merciless
return true if user.effects[PBEffects::LaserFocus] > 0
c += 1 if highCriticalRate?
c += user.effects[PBEffects::FocusEnergy]
c += 1 if user.inHyperMode? && @type == :SHADOW
c = ratios.length-1 if c>=ratios.length
c = ratios.length - 1 if c >= ratios.length
# Calculation
return true if ratios[c] == 1
r = @battle.pbRandom(ratios[c])
@@ -222,49 +222,49 @@ class Battle::Move
#=============================================================================
# Damage calculation
#=============================================================================
def pbBaseDamage(baseDmg,user,target); return baseDmg; end
def pbBaseDamageMultiplier(damageMult,user,target); return damageMult; end
def pbModifyDamage(damageMult,user,target); return damageMult; end
def pbBaseDamage(baseDmg, user, target); return baseDmg; end
def pbBaseDamageMultiplier(damageMult, user, target); return damageMult; end
def pbModifyDamage(damageMult, user, target); return damageMult; end
def pbGetAttackStats(user,target)
def pbGetAttackStats(user, target)
if specialMove?
return user.spatk, user.stages[:SPECIAL_ATTACK]+6
return user.spatk, user.stages[:SPECIAL_ATTACK] + 6
end
return user.attack, user.stages[:ATTACK]+6
return user.attack, user.stages[:ATTACK] + 6
end
def pbGetDefenseStats(user,target)
def pbGetDefenseStats(user, target)
if specialMove?
return target.spdef, target.stages[:SPECIAL_DEFENSE]+6
return target.spdef, target.stages[:SPECIAL_DEFENSE] + 6
end
return target.defense, target.stages[:DEFENSE]+6
return target.defense, target.stages[:DEFENSE] + 6
end
def pbCalcDamage(user,target,numTargets = 1)
def pbCalcDamage(user, target, numTargets = 1)
return if statusMove?
if target.damageState.disguise || target.damageState.iceFace
target.damageState.calcDamage = 1
return
end
stageMul = [2,2,2,2,2,2, 2, 3,4,5,6,7,8]
stageDiv = [8,7,6,5,4,3, 2, 2,2,2,2,2,2]
stageMul = [2, 2, 2, 2, 2, 2, 2, 3, 4, 5, 6, 7, 8]
stageDiv = [8, 7, 6, 5, 4, 3, 2, 2, 2, 2, 2, 2, 2]
# Get the move's type
type = @calcType # nil is treated as physical
# Calculate whether this hit deals critical damage
target.damageState.critical = pbIsCritical?(user,target)
target.damageState.critical = pbIsCritical?(user, target)
# Calcuate base power of move
baseDmg = pbBaseDamage(@baseDamage,user,target)
baseDmg = pbBaseDamage(@baseDamage, user, target)
# Calculate user's attack stat
atk, atkStage = pbGetAttackStats(user,target)
atk, atkStage = pbGetAttackStats(user, target)
if !target.hasActiveAbility?(:UNAWARE) || @battle.moldBreaker
atkStage = 6 if target.damageState.critical && atkStage<6
atk = (atk.to_f*stageMul[atkStage]/stageDiv[atkStage]).floor
atkStage = 6 if target.damageState.critical && atkStage < 6
atk = (atk.to_f * stageMul[atkStage] / stageDiv[atkStage]).floor
end
# Calculate target's defense stat
defense, defStage = pbGetDefenseStats(user,target)
defense, defStage = pbGetDefenseStats(user, target)
if !user.hasActiveAbility?(:UNAWARE)
defStage = 6 if target.damageState.critical && defStage>6
defense = (defense.to_f*stageMul[defStage]/stageDiv[defStage]).floor
defStage = 6 if target.damageState.critical && defStage > 6
defense = (defense.to_f * stageMul[defStage] / stageDiv[defStage]).floor
end
# Calculate all multiplier effects
multipliers = {
@@ -273,17 +273,17 @@ class Battle::Move
:defense_multiplier => 1.0,
:final_damage_multiplier => 1.0
}
pbCalcDamageMultipliers(user,target,numTargets,type,baseDmg,multipliers)
pbCalcDamageMultipliers(user, target, numTargets, type, baseDmg, multipliers)
# Main damage calculation
baseDmg = [(baseDmg * multipliers[:base_damage_multiplier]).round, 1].max
atk = [(atk * multipliers[:attack_multiplier]).round, 1].max
defense = [(defense * multipliers[:defense_multiplier]).round, 1].max
damage = (((2.0 * user.level / 5 + 2).floor * baseDmg * atk / defense).floor / 50).floor + 2
damage = [(damage * multipliers[:final_damage_multiplier]).round, 1].max
damage = [(damage * multipliers[:final_damage_multiplier]).round, 1].max
target.damageState.calcDamage = damage
end
def pbCalcDamageMultipliers(user,target,numTargets,type,baseDmg,multipliers)
def pbCalcDamageMultipliers(user, target, numTargets, type, baseDmg, multipliers)
# Global abilities
if (@battle.pbCheckGlobalAbility(:DARKAURA) && type == :DARK) ||
(@battle.pbCheckGlobalAbility(:FAIRYAURA) && type == :FAIRY)
@@ -296,7 +296,7 @@ class Battle::Move
# Ability effects that alter damage
if user.abilityActive?
Battle::AbilityEffects.triggerDamageCalcFromUser(user.ability,
user,target,self,multipliers,baseDmg,type)
user, target, self, multipliers, baseDmg, type)
end
if !@battle.moldBreaker
# NOTE: It's odd that the user's Mold Breaker prevents its partner's
@@ -305,31 +305,31 @@ class Battle::Move
user.allAllies.each do |b|
next if !b.abilityActive?
Battle::AbilityEffects.triggerDamageCalcFromAlly(b.ability,
user,target,self,multipliers,baseDmg,type)
user, target, self, multipliers, baseDmg, type)
end
if target.abilityActive?
Battle::AbilityEffects.triggerDamageCalcFromTarget(target.ability,
user,target,self,multipliers,baseDmg,type) if !@battle.moldBreaker
user, target, self, multipliers, baseDmg, type) if !@battle.moldBreaker
Battle::AbilityEffects.triggerDamageCalcFromTargetNonIgnorable(target.ability,
user,target,self,multipliers,baseDmg,type)
user, target, self, multipliers, baseDmg, type)
end
target.allAllies.each do |b|
next if !b.abilityActive?
Battle::AbilityEffects.triggerDamageCalcFromTargetAlly(b.ability,
user,target,self,multipliers,baseDmg,type)
user, target, self, multipliers, baseDmg, type)
end
end
# Item effects that alter damage
if user.itemActive?
Battle::ItemEffects.triggerDamageCalcFromUser(user.item,
user,target,self,multipliers,baseDmg,type)
user, target, self, multipliers, baseDmg, type)
end
if target.itemActive?
Battle::ItemEffects.triggerDamageCalcFromTarget(target.item,
user,target,self,multipliers,baseDmg,type)
user, target, self, multipliers, baseDmg, type)
end
# Parental Bond's second attack
if user.effects[PBEffects::ParentalBond]==1
if user.effects[PBEffects::ParentalBond] == 1
multipliers[:base_damage_multiplier] /= (Settings::MECHANICS_GENERATION >= 7) ? 4 : 2
end
# Other
@@ -339,7 +339,7 @@ class Battle::Move
if user.effects[PBEffects::HelpingHand] && !self.is_a?(Battle::Move::Confusion)
multipliers[:base_damage_multiplier] *= 1.5
end
if user.effects[PBEffects::Charge]>0 && type == :ELECTRIC
if user.effects[PBEffects::Charge] > 0 && type == :ELECTRIC
multipliers[:base_damage_multiplier] *= 2
end
# Mud Sport
@@ -347,7 +347,7 @@ class Battle::Move
if @battle.allBattlers.any? { |b| b.effects[PBEffects::MudSport] }
multipliers[:base_damage_multiplier] /= 3
end
if @battle.field.effects[PBEffects::MudSportField]>0
if @battle.field.effects[PBEffects::MudSportField] > 0
multipliers[:base_damage_multiplier] /= 3
end
end
@@ -356,7 +356,7 @@ class Battle::Move
if @battle.allBattlers.any? { |b| b.effects[PBEffects::WaterSport] }
multipliers[:base_damage_multiplier] /= 3
end
if @battle.field.effects[PBEffects::WaterSportField]>0
if @battle.field.effects[PBEffects::WaterSportField] > 0
multipliers[:base_damage_multiplier] /= 3
end
end
@@ -390,7 +390,7 @@ class Battle::Move
end
end
# Multi-targeting attacks
if numTargets>1
if numTargets > 1
multipliers[:final_damage_multiplier] *= 0.75
end
# Weather
@@ -422,7 +422,7 @@ class Battle::Move
end
# Random variance
if !self.is_a?(Battle::Move::Confusion)
random = 85+@battle.pbRandom(16)
random = 85 + @battle.pbRandom(16)
multipliers[:final_damage_multiplier] *= random / 100.0
end
# STAB
@@ -444,13 +444,13 @@ class Battle::Move
if !ignoresReflect? && !target.damageState.critical &&
!user.hasActiveAbility?(:INFILTRATOR)
if target.pbOwnSide.effects[PBEffects::AuroraVeil] > 0
if @battle.pbSideBattlerCount(target)>1
if @battle.pbSideBattlerCount(target) > 1
multipliers[:final_damage_multiplier] *= 2 / 3.0
else
multipliers[:final_damage_multiplier] /= 2
end
elsif target.pbOwnSide.effects[PBEffects::Reflect] > 0 && physicalMove?
if @battle.pbSideBattlerCount(target)>1
if @battle.pbSideBattlerCount(target) > 1
multipliers[:final_damage_multiplier] *= 2 / 3.0
else
multipliers[:final_damage_multiplier] /= 2
@@ -476,12 +476,12 @@ class Battle::Move
#=============================================================================
# Additional effect chance
#=============================================================================
def pbAdditionalEffectChance(user,target,effectChance = 0)
def pbAdditionalEffectChance(user, target, effectChance = 0)
return 0 if target.hasActiveAbility?(:SHIELDDUST) && !@battle.moldBreaker
ret = (effectChance>0) ? effectChance : @addlEffect
ret = (effectChance > 0) ? effectChance : @addlEffect
if Settings::MECHANICS_GENERATION >= 6 || @function != "EffectDependsOnEnvironment"
ret *= 2 if user.hasActiveAbility?(:SERENEGRACE) ||
user.pbOwnSide.effects[PBEffects::Rainbow]>0
user.pbOwnSide.effects[PBEffects::Rainbow] > 0
end
ret = 100 if $DEBUG && Input.press?(Input::CTRL)
return ret
@@ -489,17 +489,17 @@ class Battle::Move
# NOTE: Flinching caused by a move's effect is applied in that move's code,
# not here.
def pbFlinchChance(user,target)
def pbFlinchChance(user, target)
return 0 if flinchingMove?
return 0 if target.hasActiveAbility?(:SHIELDDUST) && !@battle.moldBreaker
ret = 0
if user.hasActiveAbility?(:STENCH,true)
if user.hasActiveAbility?(:STENCH, true)
ret = 10
elsif user.hasActiveItem?([:KINGSROCK,:RAZORFANG],true)
elsif user.hasActiveItem?([:KINGSROCK, :RAZORFANG], true)
ret = 10
end
ret *= 2 if user.hasActiveAbility?(:SERENEGRACE) ||
user.pbOwnSide.effects[PBEffects::Rainbow]>0
user.pbOwnSide.effects[PBEffects::Rainbow] > 0
return ret
end
end

View File

@@ -8,7 +8,7 @@
# Status moves always fail.
#===============================================================================
class Battle::Move::Unimplemented < Battle::Move
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if statusMove?
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -21,7 +21,7 @@ end
# Pseudomove for confusion damage.
#===============================================================================
class Battle::Move::Confusion < Battle::Move
def initialize(battle,move)
def initialize(battle, move)
@battle = battle
@realMove = move
@id = :CONFUSEDAMAGE
@@ -41,16 +41,16 @@ class Battle::Move::Confusion < Battle::Move
@snatched = false
end
def physicalMove?(thisType = nil); return true; end
def specialMove?(thisType = nil); return false; end
def pbCritialOverride(user,target); return -1; end
def physicalMove?(thisType = nil); return true; end
def specialMove?(thisType = nil); return false; end
def pbCritialOverride(user, target); return -1; end
end
#===============================================================================
# Struggle.
#===============================================================================
class Battle::Move::Struggle < Battle::Move
def initialize(battle,move)
def initialize(battle, move)
@battle = battle
@realMove = nil # Not associated with a move
@id = (move) ? move.id : :STRUGGLE
@@ -73,10 +73,10 @@ class Battle::Move::Struggle < Battle::Move
def physicalMove?(thisType = nil); return true; end
def specialMove?(thisType = nil); return false; end
def pbEffectAfterAllHits(user,target)
def pbEffectAfterAllHits(user, target)
return if target.damageState.unaffected
user.pbReduceHP((user.totalhp/4.0).round,false)
@battle.pbDisplay(_INTL("{1} is damaged by recoil!",user.pbThis))
user.pbReduceHP((user.totalhp / 4.0).round, false)
@battle.pbDisplay(_INTL("{1} is damaged by recoil!", user.pbThis))
user.pbItemHPHealCheck
end
end
@@ -87,19 +87,19 @@ end
class Battle::Move::StatUpMove < Battle::Move
def canSnatch?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
return false if damagingMove?
return !user.pbCanRaiseStatStage?(@statUp[0],user,self,true)
return !user.pbCanRaiseStatStage?(@statUp[0], user, self, true)
end
def pbEffectGeneral(user)
return if damagingMove?
user.pbRaiseStatStage(@statUp[0],@statUp[1],user)
user.pbRaiseStatStage(@statUp[0], @statUp[1], user)
end
def pbAdditionalEffect(user,target)
if user.pbCanRaiseStatStage?(@statUp[0],user,self)
user.pbRaiseStatStage(@statUp[0],@statUp[1],user)
def pbAdditionalEffect(user, target)
if user.pbCanRaiseStatStage?(@statUp[0], user, self)
user.pbRaiseStatStage(@statUp[0], @statUp[1], user)
end
end
end
@@ -110,16 +110,16 @@ end
class Battle::Move::MultiStatUpMove < Battle::Move
def canSnatch?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
return false if damagingMove?
failed = true
for i in 0...@statUp.length/2
next if !user.pbCanRaiseStatStage?(@statUp[i*2],user,self)
for i in 0...@statUp.length / 2
next if !user.pbCanRaiseStatStage?(@statUp[i * 2], user, self)
failed = false
break
end
if failed
@battle.pbDisplay(_INTL("{1}'s stats won't go any higher!",user.pbThis))
@battle.pbDisplay(_INTL("{1}'s stats won't go any higher!", user.pbThis))
return true
end
return false
@@ -128,19 +128,19 @@ class Battle::Move::MultiStatUpMove < Battle::Move
def pbEffectGeneral(user)
return if damagingMove?
showAnim = true
for i in 0...@statUp.length/2
next if !user.pbCanRaiseStatStage?(@statUp[i*2],user,self)
if user.pbRaiseStatStage(@statUp[i*2],@statUp[i*2+1],user,showAnim)
for i in 0...@statUp.length / 2
next if !user.pbCanRaiseStatStage?(@statUp[i * 2], user, self)
if user.pbRaiseStatStage(@statUp[i * 2], @statUp[i * 2 + 1], user, showAnim)
showAnim = false
end
end
end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
showAnim = true
for i in 0...@statUp.length/2
next if !user.pbCanRaiseStatStage?(@statUp[i*2],user,self)
if user.pbRaiseStatStage(@statUp[i*2],@statUp[i*2+1],user,showAnim)
for i in 0...@statUp.length / 2
next if !user.pbCanRaiseStatStage?(@statUp[i * 2], user, self)
if user.pbRaiseStatStage(@statUp[i * 2], @statUp[i * 2 + 1], user, showAnim)
showAnim = false
end
end
@@ -151,12 +151,12 @@ end
# Lower multiple of user's stats.
#===============================================================================
class Battle::Move::StatDownMove < Battle::Move
def pbEffectWhenDealingDamage(user,target)
def pbEffectWhenDealingDamage(user, target)
return if @battle.pbAllFainted?(target.idxOwnSide)
showAnim = true
for i in 0...@statDown.length/2
next if !user.pbCanLowerStatStage?(@statDown[i*2],user,self)
if user.pbLowerStatStage(@statDown[i*2],@statDown[i*2+1],user,showAnim)
for i in 0...@statDown.length / 2
next if !user.pbCanLowerStatStage?(@statDown[i * 2], user, self)
if user.pbLowerStatStage(@statDown[i * 2], @statDown[i * 2 + 1], user, showAnim)
showAnim = false
end
end
@@ -174,15 +174,15 @@ class Battle::Move::TargetStatDownMove < Battle::Move
return !target.pbCanLowerStatStage?(@statDown[0], user, self, show_message)
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
return if damagingMove?
target.pbLowerStatStage(@statDown[0],@statDown[1],user)
target.pbLowerStatStage(@statDown[0], @statDown[1], user)
end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.damageState.substitute
return if !target.pbCanLowerStatStage?(@statDown[0],user,self)
target.pbLowerStatStage(@statDown[0],@statDown[1],user)
return if !target.pbCanLowerStatStage?(@statDown[0], user, self)
target.pbLowerStatStage(@statDown[0], @statDown[1], user)
end
end
@@ -195,8 +195,8 @@ class Battle::Move::TargetMultiStatDownMove < Battle::Move
def pbFailsAgainstTarget?(user, target, show_message)
return false if damagingMove?
failed = true
for i in 0...@statDown.length/2
next if !target.pbCanLowerStatStage?(@statDown[i*2],user,self)
for i in 0...@statDown.length / 2
next if !target.pbCanLowerStatStage?(@statDown[i * 2], user, self)
failed = false
break
end
@@ -205,19 +205,19 @@ class Battle::Move::TargetMultiStatDownMove < Battle::Move
# is shown here, I know.
canLower = false
if target.hasActiveAbility?(:CONTRARY) && !@battle.moldBreaker
for i in 0...@statDown.length/2
next if target.statStageAtMax?(@statDown[i*2])
for i in 0...@statDown.length / 2
next if target.statStageAtMax?(@statDown[i * 2])
canLower = true
break
end
@battle.pbDisplay(_INTL("{1}'s stats won't go any higher!",user.pbThis)) if !canLower && show_message
@battle.pbDisplay(_INTL("{1}'s stats won't go any higher!", user.pbThis)) if !canLower && show_message
else
for i in 0...@statDown.length/2
next if target.statStageAtMin?(@statDown[i*2])
for i in 0...@statDown.length / 2
next if target.statStageAtMin?(@statDown[i * 2])
canLower = true
break
end
@battle.pbDisplay(_INTL("{1}'s stats won't go any lower!",user.pbThis)) if !canLower && show_message
@battle.pbDisplay(_INTL("{1}'s stats won't go any lower!", user.pbThis)) if !canLower && show_message
end
if canLower
target.pbCanLowerStatStage?(@statDown[0], user, self, show_message)
@@ -264,11 +264,11 @@ class Battle::Move::TargetMultiStatDownMove < Battle::Move
@battle.pbHideAbilitySplash(target) # To hide target's Mirror Armor splash
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
pbLowerTargetMultipleStats(user, target) if !damagingMove?
end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
pbLowerTargetMultipleStats(user, target) if !target.damageState.substitute
end
end
@@ -277,12 +277,12 @@ end
# Fixed damage-inflicting move.
#===============================================================================
class Battle::Move::FixedDamageMove < Battle::Move
def pbFixedDamage(user,target); return 1; end
def pbFixedDamage(user, target); return 1; end
def pbCalcDamage(user,target,numTargets = 1)
def pbCalcDamage(user, target, numTargets = 1)
target.damageState.critical = false
target.damageState.calcDamage = pbFixedDamage(user,target)
target.damageState.calcDamage = 1 if target.damageState.calcDamage<1
target.damageState.calcDamage = pbFixedDamage(user, target)
target.damageState.calcDamage = 1 if target.damageState.calcDamage < 1
end
end
@@ -315,16 +315,16 @@ class Battle::Move::TwoTurnMove < Battle::Move
return super
end
def pbAccuracyCheck(user,target)
def pbAccuracyCheck(user, target)
return true if !@damagingTurn
return super
end
def pbInitialEffect(user,targets,hitNum)
pbChargingTurnMessage(user,targets) if @chargingTurn
def pbInitialEffect(user, targets, hitNum)
pbChargingTurnMessage(user, targets) if @chargingTurn
if @chargingTurn && @damagingTurn # Move only takes one turn to use
pbShowAnimation(@id,user,targets,1) # Charging anim
targets.each { |b| pbChargingTurnEffect(user,b) }
pbShowAnimation(@id, user, targets, 1) # Charging anim
targets.each { |b| pbChargingTurnEffect(user, b) }
if @powerHerb
# Moves that would make the user semi-invulnerable will hide the user
# after the charging animation, so the "UseItem" animation shouldn't show
@@ -335,39 +335,39 @@ class Battle::Move::TwoTurnMove < Battle::Move
"TwoTurnAttackInvulnerableInSkyParalyzeTarget",
"TwoTurnAttackInvulnerableRemoveProtections",
"TwoTurnAttackInvulnerableInSkyTargetCannotAct"].include?(@function)
@battle.pbCommonAnimation("UseItem",user)
@battle.pbCommonAnimation("UseItem", user)
end
@battle.pbDisplay(_INTL("{1} became fully charged due to its Power Herb!",user.pbThis))
@battle.pbDisplay(_INTL("{1} became fully charged due to its Power Herb!", user.pbThis))
user.pbConsumeItem
end
end
pbAttackingTurnMessage(user,targets) if @damagingTurn
pbAttackingTurnMessage(user, targets) if @damagingTurn
end
def pbChargingTurnMessage(user,targets)
@battle.pbDisplay(_INTL("{1} began charging up!",user.pbThis))
def pbChargingTurnMessage(user, targets)
@battle.pbDisplay(_INTL("{1} began charging up!", user.pbThis))
end
def pbAttackingTurnMessage(user,targets)
def pbAttackingTurnMessage(user, targets)
end
def pbChargingTurnEffect(user,target)
def pbChargingTurnEffect(user, target)
# Skull Bash/Sky Drop are the only two-turn moves with an effect here, and
# the latter just records the target is being Sky Dropped
end
def pbAttackingTurnEffect(user,target)
def pbAttackingTurnEffect(user, target)
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
if @damagingTurn
pbAttackingTurnEffect(user,target)
pbAttackingTurnEffect(user, target)
elsif @chargingTurn
pbChargingTurnEffect(user,target)
pbChargingTurnEffect(user, target)
end
end
def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true)
def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true)
hitNum = 1 if @chargingTurn && !@damagingTurn # Charging anim
super
end
@@ -381,9 +381,9 @@ class Battle::Move::HealingMove < Battle::Move
def pbHealAmount(user); return 1; end
def canSnatch?; return true; end
def pbMoveFailed?(user,targets)
if user.hp==user.totalhp
@battle.pbDisplay(_INTL("{1}'s HP is full!",user.pbThis))
def pbMoveFailed?(user, targets)
if user.hp == user.totalhp
@battle.pbDisplay(_INTL("{1}'s HP is full!", user.pbThis))
return true
end
return false
@@ -392,7 +392,7 @@ class Battle::Move::HealingMove < Battle::Move
def pbEffectGeneral(user)
amt = pbHealAmount(user)
user.pbRecoverHP(amt)
@battle.pbDisplay(_INTL("{1}'s HP was restored.",user.pbThis))
@battle.pbDisplay(_INTL("{1}'s HP was restored.", user.pbThis))
end
end
@@ -401,16 +401,16 @@ end
#===============================================================================
class Battle::Move::RecoilMove < Battle::Move
def recoilMove?; return true; end
def pbRecoilDamage(user,target); return 1; end
def pbRecoilDamage(user, target); return 1; end
def pbEffectAfterAllHits(user,target)
def pbEffectAfterAllHits(user, target)
return if target.damageState.unaffected
return if !user.takesIndirectDamage?
return if user.hasActiveAbility?(:ROCKHEAD)
amt = pbRecoilDamage(user,target)
amt = 1 if amt<1
user.pbReduceHP(amt,false)
@battle.pbDisplay(_INTL("{1} is damaged by recoil!",user.pbThis))
amt = pbRecoilDamage(user, target)
amt = 1 if amt < 1
user.pbReduceHP(amt, false)
@battle.pbDisplay(_INTL("{1} is damaged by recoil!", user.pbThis))
user.pbItemHPHealCheck
end
end
@@ -419,18 +419,18 @@ end
# Protect move.
#===============================================================================
class Battle::Move::ProtectMove < Battle::Move
def initialize(battle,move)
def initialize(battle, move)
super
@sidedEffect = false
end
def pbChangeUsageCounters(user,specialUsage)
def pbChangeUsageCounters(user, specialUsage)
oldVal = user.effects[PBEffects::ProtectRate]
super
user.effects[PBEffects::ProtectRate] = oldVal
end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if @sidedEffect
if user.pbOwnSide.effects[@effect]
user.effects[PBEffects::ProtectRate] = 1
@@ -443,8 +443,8 @@ class Battle::Move::ProtectMove < Battle::Move
return true
end
if (!@sidedEffect || Settings::MECHANICS_GENERATION <= 5) &&
user.effects[PBEffects::ProtectRate]>1 &&
@battle.pbRandom(user.effects[PBEffects::ProtectRate])!=0
user.effects[PBEffects::ProtectRate] > 1 &&
@battle.pbRandom(user.effects[PBEffects::ProtectRate]) != 0
user.effects[PBEffects::ProtectRate] = 1
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -468,9 +468,9 @@ class Battle::Move::ProtectMove < Battle::Move
def pbProtectMessage(user)
if @sidedEffect
@battle.pbDisplay(_INTL("{1} protected {2}!",@name,user.pbTeam(true)))
@battle.pbDisplay(_INTL("{1} protected {2}!", @name, user.pbTeam(true)))
else
@battle.pbDisplay(_INTL("{1} protected itself!",user.pbThis))
@battle.pbDisplay(_INTL("{1} protected itself!", user.pbThis))
end
end
end
@@ -479,12 +479,12 @@ end
# Weather-inducing move.
#===============================================================================
class Battle::Move::WeatherMove < Battle::Move
def initialize(battle,move)
def initialize(battle, move)
super
@weatherType = :None
end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
case @battle.field.weather
when :HarshSun
@battle.pbDisplay(_INTL("The extremely harsh sunlight was not lessened at all!"))
@@ -503,7 +503,7 @@ class Battle::Move::WeatherMove < Battle::Move
end
def pbEffectGeneral(user)
@battle.pbStartWeather(user,@weatherType,true,false)
@battle.pbStartWeather(user, @weatherType, true, false)
end
end
@@ -511,7 +511,7 @@ end
# Pledge move.
#===============================================================================
class Battle::Move::PledgeMove < Battle::Move
def pbOnStartUse(user,targets)
def pbOnStartUse(user, targets)
@pledgeSetup = false
@pledgeCombo = false
@pledgeOtherUser = nil
@@ -519,7 +519,7 @@ class Battle::Move::PledgeMove < Battle::Move
@overrideAnim = nil
# Check whether this is the use of a combo move
@combos.each do |i|
next if i[0]!=user.effects[PBEffects::FirstPledge]
next if i[0] != user.effects[PBEffects::FirstPledge]
@battle.pbDisplay(_INTL("The two moves have become one! It's a combined move!"))
@pledgeCombo = true
@comboEffect = i[1]
@@ -529,11 +529,11 @@ class Battle::Move::PledgeMove < Battle::Move
return if @pledgeCombo
# Check whether this is the setup of a combo move
user.allAllies.each do |b|
next if @battle.choices[b.index][0]!=:UseMove || b.movedThisRound?
next if @battle.choices[b.index][0] != :UseMove || b.movedThisRound?
move = @battle.choices[b.index][2]
next if !move
@combos.each do |i|
next if i[0]!=move.function
next if i[0] != move.function
@pledgeSetup = true
@pledgeOtherUser = b
break
@@ -558,7 +558,7 @@ class Battle::Move::PledgeMove < Battle::Move
return super
end
def pbBaseDamage(baseDmg,user,target)
def pbBaseDamage(baseDmg, user, target)
baseDmg *= 2 if @pledgeCombo
return baseDmg
end
@@ -567,33 +567,33 @@ class Battle::Move::PledgeMove < Battle::Move
user.effects[PBEffects::FirstPledge] = nil
return if !@pledgeSetup
@battle.pbDisplay(_INTL("{1} is waiting for {2}'s move...",
user.pbThis,@pledgeOtherUser.pbThis(true)))
user.pbThis, @pledgeOtherUser.pbThis(true)))
@pledgeOtherUser.effects[PBEffects::FirstPledge] = @function
@pledgeOtherUser.effects[PBEffects::MoveNext] = true
user.lastMoveFailed = true # Treated as a failure for Stomping Tantrum
end
def pbEffectAfterAllHits(user,target)
def pbEffectAfterAllHits(user, target)
return if !@pledgeCombo
msg = nil
animName = nil
case @comboEffect
when :SeaOfFire # Grass + Fire
if user.pbOpposingSide.effects[PBEffects::SeaOfFire]==0
if user.pbOpposingSide.effects[PBEffects::SeaOfFire] == 0
user.pbOpposingSide.effects[PBEffects::SeaOfFire] = 4
msg = _INTL("A sea of fire enveloped {1}!",user.pbOpposingTeam(true))
msg = _INTL("A sea of fire enveloped {1}!", user.pbOpposingTeam(true))
animName = (user.opposes?) ? "SeaOfFire" : "SeaOfFireOpp"
end
when :Rainbow # Fire + Water
if user.pbOwnSide.effects[PBEffects::Rainbow]==0
if user.pbOwnSide.effects[PBEffects::Rainbow] == 0
user.pbOwnSide.effects[PBEffects::Rainbow] = 4
msg = _INTL("A rainbow appeared in the sky on {1}'s side!",user.pbTeam(true))
msg = _INTL("A rainbow appeared in the sky on {1}'s side!", user.pbTeam(true))
animName = (user.opposes?) ? "RainbowOpp" : "Rainbow"
end
when :Swamp # Water + Grass
if user.pbOpposingSide.effects[PBEffects::Swamp]==0
if user.pbOpposingSide.effects[PBEffects::Swamp] == 0
user.pbOpposingSide.effects[PBEffects::Swamp] = 4
msg = _INTL("A swamp enveloped {1}!",user.pbOpposingTeam(true))
msg = _INTL("A swamp enveloped {1}!", user.pbOpposingTeam(true))
animName = (user.opposes?) ? "Swamp" : "SwampOpp"
end
end
@@ -601,7 +601,7 @@ class Battle::Move::PledgeMove < Battle::Move
@battle.pbCommonAnimation(animName) if animName
end
def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true)
def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true)
return if @pledgeSetup # No animation for setting up
id = @overrideAnim if @overrideAnim
return super

View File

@@ -10,9 +10,9 @@ end
class Battle::Move::DoesNothingCongratulations < Battle::Move
def pbEffectGeneral(user)
if user.wild?
@battle.pbDisplay(_INTL("Congratulations from {1}!",user.pbThis(true)))
@battle.pbDisplay(_INTL("Congratulations from {1}!", user.pbThis(true)))
else
@battle.pbDisplay(_INTL("Congratulations, {1}!",@battle.pbGetOwnerName(user.index)))
@battle.pbDisplay(_INTL("Congratulations, {1}!", @battle.pbGetOwnerName(user.index)))
end
end
end
@@ -23,7 +23,7 @@ end
class Battle::Move::DoesNothingFailsIfNoAlly < Battle::Move
def ignoresSubstitute?(user); return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if user.allAllies.length == 0
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -53,7 +53,7 @@ end
class Battle::Move::AddMoneyGainedFromBattle < Battle::Move
def pbEffectGeneral(user)
if user.pbOwnedByPlayer?
@battle.field.effects[PBEffects::PayDay] += 5*user.level
@battle.field.effects[PBEffects::PayDay] += 5 * user.level
end
@battle.pbDisplay(_INTL("Coins were scattered everywhere!"))
end
@@ -73,7 +73,7 @@ end
# Fails if this isn't the user's first turn. (First Impression)
#===============================================================================
class Battle::Move::FailsIfNotUserFirstTurn < Battle::Move
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if user.turnCount > 1
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -91,9 +91,9 @@ class Battle::Move::FailsIfUserHasUnusedMove < Battle::Move
hasOtherMoves = false
hasUnusedMoves = false
user.eachMove do |m|
hasThisMove = true if m.id==@id
hasOtherMoves = true if m.id!=@id
hasUnusedMoves = true if m.id!=@id && !user.movesUsed.include?(m.id)
hasThisMove = true if m.id == @id
hasOtherMoves = true if m.id != @id
hasUnusedMoves = true if m.id != @id && !user.movesUsed.include?(m.id)
end
if !hasThisMove || !hasOtherMoves || hasUnusedMoves
@battle.pbDisplay(_INTL("But it failed!")) if show_message
@@ -107,10 +107,10 @@ end
# Fails unless user has consumed a berry at some point. (Belch)
#===============================================================================
class Battle::Move::FailsIfUserNotConsumedBerry < Battle::Move
def pbCanChooseMove?(user,commandPhase,showMessages)
def pbCanChooseMove?(user, commandPhase, showMessages)
if !user.belched?
if showMessages
msg = _INTL("{1} hasn't eaten any held berry, so it can't possibly belch!",user.pbThis)
msg = _INTL("{1} hasn't eaten any held berry, so it can't possibly belch!", user.pbThis)
(commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg)
end
return false
@@ -118,7 +118,7 @@ class Battle::Move::FailsIfUserNotConsumedBerry < Battle::Move
return true
end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !user.belched?
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -156,7 +156,7 @@ class Battle::Move::FailsUnlessTargetSharesTypeWithUser < Battle::Move
break
end
if !sharesType
@battle.pbDisplay(_INTL("{1} is unaffected!",target.pbThis)) if show_message
@battle.pbDisplay(_INTL("{1} is unaffected!", target.pbThis)) if show_message
return true
end
return false
@@ -169,17 +169,17 @@ end
class Battle::Move::FailsIfUserDamagedThisTurn < Battle::Move
def pbDisplayChargeMessage(user)
user.effects[PBEffects::FocusPunch] = true
@battle.pbCommonAnimation("FocusPunch",user)
@battle.pbDisplay(_INTL("{1} is tightening its focus!",user.pbThis))
@battle.pbCommonAnimation("FocusPunch", user)
@battle.pbDisplay(_INTL("{1} is tightening its focus!", user.pbThis))
end
def pbDisplayUseMessage(user)
super if !user.effects[PBEffects::FocusPunch] || user.lastHPLost==0
super if !user.effects[PBEffects::FocusPunch] || user.lastHPLost == 0
end
def pbMoveFailed?(user,targets)
if user.effects[PBEffects::FocusPunch] && user.lastHPLost>0
@battle.pbDisplay(_INTL("{1} lost its focus and couldn't move!",user.pbThis))
def pbMoveFailed?(user, targets)
if user.effects[PBEffects::FocusPunch] && user.lastHPLost > 0
@battle.pbDisplay(_INTL("{1} lost its focus and couldn't move!", user.pbThis))
return true
end
return false
@@ -192,13 +192,13 @@ end
#===============================================================================
class Battle::Move::FailsIfTargetActed < Battle::Move
def pbFailsAgainstTarget?(user, target, show_message)
if @battle.choices[target.index][0]!=:UseMove
if @battle.choices[target.index][0] != :UseMove
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
oppMove = @battle.choices[target.index][2]
if !oppMove ||
(oppMove.function!="UseMoveTargetIsAboutToUse" &&
(oppMove.function != "UseMoveTargetIsAboutToUse" &&
(target.movedThisRound? || oppMove.statusMove?))
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
@@ -217,9 +217,9 @@ class Battle::Move::CrashDamageIfFailsUnusableInGravity < Battle::Move
def pbCrashDamage(user)
return if !user.takesIndirectDamage?
@battle.pbDisplay(_INTL("{1} kept going and crashed!",user.pbThis))
@battle.pbDisplay(_INTL("{1} kept going and crashed!", user.pbThis))
@battle.scene.pbDamageAnimation(user)
user.pbReduceHP(user.totalhp/2,false)
user.pbReduceHP(user.totalhp / 2, false)
user.pbItemHPHealCheck
user.pbFaint if user.fainted?
end
@@ -229,7 +229,7 @@ end
# Starts sunny weather. (Sunny Day)
#===============================================================================
class Battle::Move::StartSunWeather < Battle::Move::WeatherMove
def initialize(battle,move)
def initialize(battle, move)
super
@weatherType = :Sun
end
@@ -239,7 +239,7 @@ end
# Starts rainy weather. (Rain Dance)
#===============================================================================
class Battle::Move::StartRainWeather < Battle::Move::WeatherMove
def initialize(battle,move)
def initialize(battle, move)
super
@weatherType = :Rain
end
@@ -249,7 +249,7 @@ end
# Starts sandstorm weather. (Sandstorm)
#===============================================================================
class Battle::Move::StartSandstormWeather < Battle::Move::WeatherMove
def initialize(battle,move)
def initialize(battle, move)
super
@weatherType = :Sandstorm
end
@@ -259,7 +259,7 @@ end
# Starts hail weather. (Hail)
#===============================================================================
class Battle::Move::StartHailWeather < Battle::Move::WeatherMove
def initialize(battle,move)
def initialize(battle, move)
super
@weatherType = :Hail
end
@@ -271,7 +271,7 @@ end
# (Electric Terrain)
#===============================================================================
class Battle::Move::StartElectricTerrain < Battle::Move
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if @battle.field.terrain == :Electric
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -290,7 +290,7 @@ end
# (Grassy Terrain)
#===============================================================================
class Battle::Move::StartGrassyTerrain < Battle::Move
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if @battle.field.terrain == :Grassy
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -309,7 +309,7 @@ end
# (Misty Terrain)
#===============================================================================
class Battle::Move::StartMistyTerrain < Battle::Move
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if @battle.field.terrain == :Misty
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -328,7 +328,7 @@ end
# Pokémon only. (Psychic Terrain)
#===============================================================================
class Battle::Move::StartPsychicTerrain < Battle::Move
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if @battle.field.terrain == :Psychic
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -375,8 +375,8 @@ end
class Battle::Move::AddSpikesToFoeSide < Battle::Move
def canMagicCoat?; return true; end
def pbMoveFailed?(user,targets)
if user.pbOpposingSide.effects[PBEffects::Spikes]>=3
def pbMoveFailed?(user, targets)
if user.pbOpposingSide.effects[PBEffects::Spikes] >= 3
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -397,8 +397,8 @@ end
class Battle::Move::AddToxicSpikesToFoeSide < Battle::Move
def canMagicCoat?; return true; end
def pbMoveFailed?(user,targets)
if user.pbOpposingSide.effects[PBEffects::ToxicSpikes]>=2
def pbMoveFailed?(user, targets)
if user.pbOpposingSide.effects[PBEffects::ToxicSpikes] >= 2
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -418,7 +418,7 @@ end
class Battle::Move::AddStealthRocksToFoeSide < Battle::Move
def canMagicCoat?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if user.pbOpposingSide.effects[PBEffects::StealthRock]
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -439,7 +439,7 @@ end
class Battle::Move::AddStickyWebToFoeSide < Battle::Move
def canMagicCoat?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if user.pbOpposingSide.effects[PBEffects::StickyWeb]
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -523,22 +523,22 @@ end
class Battle::Move::UserMakeSubstitute < Battle::Move
def canSnatch?; return true; end
def pbMoveFailed?(user,targets)
if user.effects[PBEffects::Substitute]>0
@battle.pbDisplay(_INTL("{1} already has a substitute!",user.pbThis))
def pbMoveFailed?(user, targets)
if user.effects[PBEffects::Substitute] > 0
@battle.pbDisplay(_INTL("{1} already has a substitute!", user.pbThis))
return true
end
@subLife = user.totalhp/4
@subLife = 1 if @subLife<1
if user.hp<=@subLife
@subLife = user.totalhp / 4
@subLife = 1 if @subLife < 1
if user.hp <= @subLife
@battle.pbDisplay(_INTL("But it does not have enough HP left to make a substitute!"))
return true
end
return false
end
def pbOnStartUse(user,targets)
user.pbReduceHP(@subLife,false,false)
def pbOnStartUse(user, targets)
user.pbReduceHP(@subLife, false, false)
user.pbItemHPHealCheck
end
@@ -546,7 +546,7 @@ class Battle::Move::UserMakeSubstitute < Battle::Move
user.effects[PBEffects::Trapping] = 0
user.effects[PBEffects::TrappingMove] = nil
user.effects[PBEffects::Substitute] = @subLife
@battle.pbDisplay(_INTL("{1} put in a substitute!",user.pbThis))
@battle.pbDisplay(_INTL("{1} put in a substitute!", user.pbThis))
end
end
@@ -555,44 +555,44 @@ end
# Raises user's Speed by 1 stage (Gen 8+). (Rapid Spin)
#===============================================================================
class Battle::Move::RemoveUserBindingAndEntryHazards < Battle::Move::StatUpMove
def initialize(battle,move)
def initialize(battle, move)
super
@statUp = [:SPEED, 1]
end
def pbEffectAfterAllHits(user,target)
def pbEffectAfterAllHits(user, target)
return if user.fainted? || target.damageState.unaffected
if user.effects[PBEffects::Trapping]>0
if user.effects[PBEffects::Trapping] > 0
trapMove = GameData::Move.get(user.effects[PBEffects::TrappingMove]).name
trapUser = @battle.battlers[user.effects[PBEffects::TrappingUser]]
@battle.pbDisplay(_INTL("{1} got free of {2}'s {3}!",user.pbThis,trapUser.pbThis(true),trapMove))
@battle.pbDisplay(_INTL("{1} got free of {2}'s {3}!", user.pbThis, trapUser.pbThis(true), trapMove))
user.effects[PBEffects::Trapping] = 0
user.effects[PBEffects::TrappingMove] = nil
user.effects[PBEffects::TrappingUser] = -1
end
if user.effects[PBEffects::LeechSeed]>=0
if user.effects[PBEffects::LeechSeed] >= 0
user.effects[PBEffects::LeechSeed] = -1
@battle.pbDisplay(_INTL("{1} shed Leech Seed!",user.pbThis))
@battle.pbDisplay(_INTL("{1} shed Leech Seed!", user.pbThis))
end
if user.pbOwnSide.effects[PBEffects::StealthRock]
user.pbOwnSide.effects[PBEffects::StealthRock] = false
@battle.pbDisplay(_INTL("{1} blew away stealth rocks!",user.pbThis))
@battle.pbDisplay(_INTL("{1} blew away stealth rocks!", user.pbThis))
end
if user.pbOwnSide.effects[PBEffects::Spikes]>0
if user.pbOwnSide.effects[PBEffects::Spikes] > 0
user.pbOwnSide.effects[PBEffects::Spikes] = 0
@battle.pbDisplay(_INTL("{1} blew away spikes!",user.pbThis))
@battle.pbDisplay(_INTL("{1} blew away spikes!", user.pbThis))
end
if user.pbOwnSide.effects[PBEffects::ToxicSpikes]>0
if user.pbOwnSide.effects[PBEffects::ToxicSpikes] > 0
user.pbOwnSide.effects[PBEffects::ToxicSpikes] = 0
@battle.pbDisplay(_INTL("{1} blew away poison spikes!",user.pbThis))
@battle.pbDisplay(_INTL("{1} blew away poison spikes!", user.pbThis))
end
if user.pbOwnSide.effects[PBEffects::StickyWeb]
user.pbOwnSide.effects[PBEffects::StickyWeb] = false
@battle.pbDisplay(_INTL("{1} blew away sticky webs!",user.pbThis))
@battle.pbDisplay(_INTL("{1} blew away sticky webs!", user.pbThis))
end
end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
super if Settings::MECHANICS_GENERATION >= 8
end
end
@@ -608,7 +608,7 @@ class Battle::Move::AttackTwoTurnsLater < Battle::Move
return super
end
def pbAccuracyCheck(user,target)
def pbAccuracyCheck(user, target)
return true if !@battle.futureSight
return super
end
@@ -619,14 +619,14 @@ class Battle::Move::AttackTwoTurnsLater < Battle::Move
def pbFailsAgainstTarget?(user, target, show_message)
if !@battle.futureSight &&
@battle.positions[target.index].effects[PBEffects::FutureSightCounter]>0
@battle.positions[target.index].effects[PBEffects::FutureSightCounter] > 0
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
return if @battle.futureSight # Attack is hitting
effects = @battle.positions[target.index].effects
effects[PBEffects::FutureSightCounter] = 3
@@ -634,13 +634,13 @@ class Battle::Move::AttackTwoTurnsLater < Battle::Move
effects[PBEffects::FutureSightUserIndex] = user.index
effects[PBEffects::FutureSightUserPartyIndex] = user.pokemonIndex
if @id == :DOOMDESIRE
@battle.pbDisplay(_INTL("{1} chose Doom Desire as its destiny!",user.pbThis))
@battle.pbDisplay(_INTL("{1} chose Doom Desire as its destiny!", user.pbThis))
else
@battle.pbDisplay(_INTL("{1} foresaw an attack!",user.pbThis))
@battle.pbDisplay(_INTL("{1} foresaw an attack!", user.pbThis))
end
end
def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true)
def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true)
hitNum = 1 if !@battle.futureSight # Charging anim
super
end
@@ -650,17 +650,17 @@ end
# User switches places with its ally. (Ally Switch)
#===============================================================================
class Battle::Move::UserSwapsPositionsWithAlly < Battle::Move
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
numTargets = 0
@idxAlly = -1
idxUserOwner = @battle.pbGetOwnerIndexFromBattlerIndex(user.index)
user.allAllies.each do |b|
next if @battle.pbGetOwnerIndexFromBattlerIndex(b.index)!=idxUserOwner
next if @battle.pbGetOwnerIndexFromBattlerIndex(b.index) != idxUserOwner
next if !b.near?(user)
numTargets += 1
@idxAlly = b.index
end
if numTargets!=1
if numTargets != 1
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -670,9 +670,9 @@ class Battle::Move::UserSwapsPositionsWithAlly < Battle::Move
def pbEffectGeneral(user)
idxA = user.index
idxB = @idxAlly
if @battle.pbSwapBattlers(idxA,idxB)
if @battle.pbSwapBattlers(idxA, idxB)
@battle.pbDisplay(_INTL("{1} and {2} switched places!",
@battle.battlers[idxB].pbThis,@battle.battlers[idxA].pbThis(true)))
@battle.battlers[idxB].pbThis, @battle.battlers[idxA].pbThis(true)))
[idxA, idxB].each { |idx| @battle.pbEffectsOnBattlerEnteringPosition(@battle.battlers[idx]) }
end
end
@@ -685,7 +685,7 @@ end
class Battle::Move::BurnAttackerBeforeUserActs < Battle::Move
def pbDisplayChargeMessage(user)
user.effects[PBEffects::BeakBlast] = true
@battle.pbCommonAnimation("BeakBlast",user)
@battle.pbDisplay(_INTL("{1} started heating up its beak!",user.pbThis))
@battle.pbCommonAnimation("BeakBlast", user)
@battle.pbDisplay(_INTL("{1} started heating up its beak!", user.pbThis))
end
end

View File

@@ -9,14 +9,14 @@ class Battle::Move::SleepTarget < Battle::Move
return !target.pbCanSleep?(user, show_message, self)
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
return if damagingMove?
target.pbSleep
end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.damageState.substitute
target.pbSleep if target.pbCanSleep?(user,false,self)
target.pbSleep if target.pbCanSleep?(user, false, self)
end
end
@@ -24,9 +24,9 @@ end
# Puts the target to sleep. Fails if user is not Darkrai. (Dark Void (Gen 7+))
#===============================================================================
class Battle::Move::SleepTargetIfUserDarkrai < Battle::Move::SleepTarget
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !user.isSpecies?(:DARKRAI) && user.effects[PBEffects::TransformSpecies] != :DARKRAI
@battle.pbDisplay(_INTL("But {1} can't use the move!",user.pbThis))
@battle.pbDisplay(_INTL("But {1} can't use the move!", user.pbThis))
return true
end
return false
@@ -38,13 +38,13 @@ end
# (Relic Song)
#===============================================================================
class Battle::Move::SleepTargetChangeUserMeloettaForm < Battle::Move::SleepTarget
def pbEndOfMoveUsageEffect(user,targets,numHits,switchedBattlers)
return if numHits==0
def pbEndOfMoveUsageEffect(user, targets, numHits, switchedBattlers)
return if numHits == 0
return if user.fainted? || user.effects[PBEffects::Transform]
return if !user.isSpecies?(:MELOETTA)
return if user.hasActiveAbility?(:SHEERFORCE) && @addlEffect>0
newForm = (user.form+1)%2
user.pbChangeForm(newForm,_INTL("{1} transformed!",user.pbThis))
return if user.hasActiveAbility?(:SHEERFORCE) && @addlEffect > 0
newForm = (user.form + 1) % 2
user.pbChangeForm(newForm, _INTL("{1} transformed!", user.pbThis))
end
end
@@ -55,17 +55,17 @@ class Battle::Move::SleepTargetNextTurn < Battle::Move
def canMagicCoat?; return true; end
def pbFailsAgainstTarget?(user, target, show_message)
if target.effects[PBEffects::Yawn]>0
if target.effects[PBEffects::Yawn] > 0
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
return true if !target.pbCanSleep?(user,true,self)
return true if !target.pbCanSleep?(user, true, self)
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::Yawn] = 2
@battle.pbDisplay(_INTL("{1} made {2} drowsy!",user.pbThis,target.pbThis(true)))
@battle.pbDisplay(_INTL("{1} made {2} drowsy!", user.pbThis, target.pbThis(true)))
end
end
@@ -75,7 +75,7 @@ end
class Battle::Move::PoisonTarget < Battle::Move
def canMagicCoat?; return true; end
def initialize(battle,move)
def initialize(battle, move)
super
@toxic = false
end
@@ -85,14 +85,14 @@ class Battle::Move::PoisonTarget < Battle::Move
return !target.pbCanPoison?(user, show_message, self)
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
return if damagingMove?
target.pbPoison(user,nil,@toxic)
target.pbPoison(user, nil, @toxic)
end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.damageState.substitute
target.pbPoison(user,nil,@toxic) if target.pbCanPoison?(user,false,self)
target.pbPoison(user, nil, @toxic) if target.pbCanPoison?(user, false, self)
end
end
@@ -103,18 +103,18 @@ class Battle::Move::PoisonTargetLowerTargetSpeed1 < Battle::Move
def canMagicCoat?; return true; end
def pbFailsAgainstTarget?(user, target, show_message)
if !target.pbCanPoison?(user,false,self) &&
!target.pbCanLowerStatStage?(:SPEED,user,self)
if !target.pbCanPoison?(user, false, self) &&
!target.pbCanLowerStatStage?(:SPEED, user, self)
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
return false
end
def pbEffectAgainstTarget(user,target)
target.pbPoison(user) if target.pbCanPoison?(user,false,self)
if target.pbCanLowerStatStage?(:SPEED,user,self)
target.pbLowerStatStage(:SPEED,1,user)
def pbEffectAgainstTarget(user, target)
target.pbPoison(user) if target.pbCanPoison?(user, false, self)
if target.pbCanLowerStatStage?(:SPEED, user, self)
target.pbLowerStatStage(:SPEED, 1, user)
end
end
end
@@ -123,12 +123,12 @@ end
# Badly poisons the target. (Poison Fang, Toxic)
#===============================================================================
class Battle::Move::BadPoisonTarget < Battle::Move::PoisonTarget
def initialize(battle,move)
def initialize(battle, move)
super
@toxic = true
end
def pbOverrideSuccessCheckPerHit(user,target)
def pbOverrideSuccessCheckPerHit(user, target)
return (Settings::MORE_TYPE_EFFECTS && statusMove? && user.pbHasType?(:POISON))
end
end
@@ -144,14 +144,14 @@ class Battle::Move::ParalyzeTarget < Battle::Move
return !target.pbCanParalyze?(user, show_message, self)
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
return if damagingMove?
target.pbParalyze(user)
end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.damageState.substitute
target.pbParalyze(user) if target.pbCanParalyze?(user,false,self)
target.pbParalyze(user) if target.pbCanParalyze?(user, false, self)
end
end
@@ -175,8 +175,8 @@ end
#===============================================================================
class Battle::Move::ParalyzeTargetTrampleMinimize < Battle::Move::ParalyzeTarget
def tramplesMinimize?(param = 1)
return true if param==1 && Settings::MECHANICS_GENERATION >= 6 # Perfect accuracy
return true if param==2 # Double damage
return true if param == 1 && Settings::MECHANICS_GENERATION >= 6 # Perfect accuracy
return true if param == 2 # Double damage
return super
end
end
@@ -188,7 +188,7 @@ end
class Battle::Move::ParalyzeTargetAlwaysHitsInRainHitsTargetInSky < Battle::Move::ParalyzeTarget
def hitsFlyingTargets?; return true; end
def pbBaseAccuracy(user,target)
def pbBaseAccuracy(user, target)
case target.effectiveWeather
when :Sun, :HarshSun
return 50
@@ -205,14 +205,14 @@ end
class Battle::Move::ParalyzeFlinchTarget < Battle::Move
def flinchingMove?; return true; end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.damageState.substitute
chance = pbAdditionalEffectChance(user,target,10)
return if chance==0
if @battle.pbRandom(100)<chance
target.pbParalyze(user) if target.pbCanParalyze?(user,false,self)
chance = pbAdditionalEffectChance(user, target, 10)
return if chance == 0
if @battle.pbRandom(100) < chance
target.pbParalyze(user) if target.pbCanParalyze?(user, false, self)
end
target.pbFlinch(user) if @battle.pbRandom(100)<chance
target.pbFlinch(user) if @battle.pbRandom(100) < chance
end
end
@@ -227,14 +227,14 @@ class Battle::Move::BurnTarget < Battle::Move
return !target.pbCanBurn?(user, show_message, self)
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
return if damagingMove?
target.pbBurn(user)
end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.damageState.substitute
target.pbBurn(user) if target.pbCanBurn?(user,false,self)
target.pbBurn(user) if target.pbCanBurn?(user, false, self)
end
end
@@ -254,14 +254,14 @@ end
class Battle::Move::BurnFlinchTarget < Battle::Move
def flinchingMove?; return true; end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.damageState.substitute
chance = pbAdditionalEffectChance(user,target,10)
return if chance==0
if @battle.pbRandom(100)<chance
target.pbBurn(user) if target.pbCanBurn?(user,false,self)
chance = pbAdditionalEffectChance(user, target, 10)
return if chance == 0
if @battle.pbRandom(100) < chance
target.pbBurn(user) if target.pbCanBurn?(user, false, self)
end
target.pbFlinch(user) if @battle.pbRandom(100)<chance
target.pbFlinch(user) if @battle.pbRandom(100) < chance
end
end
@@ -276,14 +276,14 @@ class Battle::Move::FreezeTarget < Battle::Move
return !target.pbCanFreeze?(user, show_message, self)
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
return if damagingMove?
target.pbFreeze
end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.damageState.substitute
target.pbFreeze if target.pbCanFreeze?(user,false,self)
target.pbFreeze if target.pbCanFreeze?(user, false, self)
end
end
@@ -291,7 +291,7 @@ end
# Freezes the target. Effectiveness against Water-type is 2x. (Freeze-Dry)
#===============================================================================
class Battle::Move::FreezeTargetSuperEffectiveAgainstWater < Battle::Move::FreezeTarget
def pbCalcTypeModSingle(moveType,defType,user,target)
def pbCalcTypeModSingle(moveType, defType, user, target)
return Effectiveness::SUPER_EFFECTIVE_ONE if defType == :WATER
return super
end
@@ -301,7 +301,7 @@ end
# Freezes the target. Accuracy perfect in hail. (Blizzard)
#===============================================================================
class Battle::Move::FreezeTargetAlwaysHitsInHail < Battle::Move::FreezeTarget
def pbBaseAccuracy(user,target)
def pbBaseAccuracy(user, target)
return 0 if target.effectiveWeather == :Hail
return super
end
@@ -313,14 +313,14 @@ end
class Battle::Move::FreezeFlinchTarget < Battle::Move
def flinchingMove?; return true; end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.damageState.substitute
chance = pbAdditionalEffectChance(user,target,10)
return if chance==0
if @battle.pbRandom(100)<chance
target.pbFreeze if target.pbCanFreeze?(user,false,self)
chance = pbAdditionalEffectChance(user, target, 10)
return if chance == 0
if @battle.pbRandom(100) < chance
target.pbFreeze if target.pbCanFreeze?(user, false, self)
end
target.pbFlinch(user) if @battle.pbRandom(100)<chance
target.pbFlinch(user) if @battle.pbRandom(100) < chance
end
end
@@ -328,7 +328,7 @@ end
# Burns, freezes or paralyzes the target. (Tri Attack)
#===============================================================================
class Battle::Move::ParalyzeBurnOrFreezeTarget < Battle::Move
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.damageState.substitute
case @battle.pbRandom(3)
when 0 then target.pbBurn(user) if target.pbCanBurn?(user, false, self)
@@ -342,7 +342,7 @@ end
# User passes its status problem to the target. (Psycho Shift)
#===============================================================================
class Battle::Move::GiveUserStatusToTarget < Battle::Move
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if user.status == :NONE
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -351,33 +351,33 @@ class Battle::Move::GiveUserStatusToTarget < Battle::Move
end
def pbFailsAgainstTarget?(user, target, show_message)
if !target.pbCanInflictStatus?(user.status,user,false,self)
if !target.pbCanInflictStatus?(user.status, user, false, self)
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
msg = ""
case user.status
when :SLEEP
target.pbSleep
msg = _INTL("{1} woke up.",user.pbThis)
msg = _INTL("{1} woke up.", user.pbThis)
when :POISON
target.pbPoison(user,nil,user.statusCount!=0)
msg = _INTL("{1} was cured of its poisoning.",user.pbThis)
target.pbPoison(user, nil, user.statusCount != 0)
msg = _INTL("{1} was cured of its poisoning.", user.pbThis)
when :BURN
target.pbBurn(user)
msg = _INTL("{1}'s burn was healed.",user.pbThis)
msg = _INTL("{1}'s burn was healed.", user.pbThis)
when :PARALYSIS
target.pbParalyze(user)
msg = _INTL("{1} was cured of paralysis.",user.pbThis)
msg = _INTL("{1} was cured of paralysis.", user.pbThis)
when :FROZEN
target.pbFreeze
msg = _INTL("{1} was thawed out.",user.pbThis)
msg = _INTL("{1} was thawed out.", user.pbThis)
end
if msg!=""
if msg != ""
user.pbCureStatus(false)
@battle.pbDisplay(msg)
end
@@ -390,7 +390,7 @@ end
class Battle::Move::CureUserBurnPoisonParalysis < Battle::Move
def canSnatch?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if ![:BURN, :POISON, :PARALYSIS].include?(user.status)
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -403,11 +403,11 @@ class Battle::Move::CureUserBurnPoisonParalysis < Battle::Move
user.pbCureStatus(false)
case old_status
when :BURN
@battle.pbDisplay(_INTL("{1} healed its burn!",user.pbThis))
@battle.pbDisplay(_INTL("{1} healed its burn!", user.pbThis))
when :POISON
@battle.pbDisplay(_INTL("{1} cured its poisoning!",user.pbThis))
@battle.pbDisplay(_INTL("{1} cured its poisoning!", user.pbThis))
when :PARALYSIS
@battle.pbDisplay(_INTL("{1} cured its paralysis!",user.pbThis))
@battle.pbDisplay(_INTL("{1} cured its paralysis!", user.pbThis))
end
end
end
@@ -426,7 +426,7 @@ class Battle::Move::CureUserPartyStatus < Battle::Move
def canSnatch?; return true; end
def worksWithNoTargets?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
has_effect = @battle.allSameSideBattlers(user).any? { |b| b.status != :NONE }
if !has_effect
has_effect = @battle.pbParty(user.index).any? { |pkmn| pkmn && pkmn.able? && pkmn.status != :NONE }
@@ -442,7 +442,7 @@ class Battle::Move::CureUserPartyStatus < Battle::Move
return target.status == :NONE
end
def pbAromatherapyHeal(pkmn,battler = nil)
def pbAromatherapyHeal(pkmn, battler = nil)
oldStatus = (battler) ? battler.status : pkmn.status
curedName = (battler) ? battler.pbThis : pkmn.name
if battler
@@ -453,21 +453,21 @@ class Battle::Move::CureUserPartyStatus < Battle::Move
end
case oldStatus
when :SLEEP
@battle.pbDisplay(_INTL("{1} was woken from sleep.",curedName))
@battle.pbDisplay(_INTL("{1} was woken from sleep.", curedName))
when :POISON
@battle.pbDisplay(_INTL("{1} was cured of its poisoning.",curedName))
@battle.pbDisplay(_INTL("{1} was cured of its poisoning.", curedName))
when :BURN
@battle.pbDisplay(_INTL("{1}'s burn was healed.",curedName))
@battle.pbDisplay(_INTL("{1}'s burn was healed.", curedName))
when :PARALYSIS
@battle.pbDisplay(_INTL("{1} was cured of paralysis.",curedName))
@battle.pbDisplay(_INTL("{1} was cured of paralysis.", curedName))
when :FROZEN
@battle.pbDisplay(_INTL("{1} was thawed out.",curedName))
@battle.pbDisplay(_INTL("{1} was thawed out.", curedName))
end
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
# Cure all Pokémon in battle on the user's side.
pbAromatherapyHeal(target.pokemon,target)
pbAromatherapyHeal(target.pokemon, target)
end
def pbEffectGeneral(user)
@@ -481,14 +481,14 @@ class Battle::Move::CureUserPartyStatus < Battle::Move
# Cure all Pokémon in the user's and partner trainer's party.
# NOTE: This intentionally affects the partner trainer's inactive Pokémon
# too.
@battle.pbParty(user.index).each_with_index do |pkmn,i|
@battle.pbParty(user.index).each_with_index do |pkmn, i|
next if !pkmn || !pkmn.able? || pkmn.status == :NONE
next if @battle.pbFindBattler(i,user) # Skip Pokémon in battle
next if @battle.pbFindBattler(i, user) # Skip Pokémon in battle
pbAromatherapyHeal(pkmn)
end
end
def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true)
def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true)
super
if @id == :AROMATHERAPY
@battle.pbDisplay(_INTL("A soothing aroma wafted through the area!"))
@@ -502,7 +502,7 @@ end
# Cures the target's burn. (Sparkling Aria)
#===============================================================================
class Battle::Move::CureTargetBurn < Battle::Move
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.fainted? || target.damageState.substitute
return if target.status != :BURN
target.pbCureStatus
@@ -516,8 +516,8 @@ end
class Battle::Move::StartUserSideImmunityToInflictedStatus < Battle::Move
def canSnatch?; return true; end
def pbMoveFailed?(user,targets)
if user.pbOwnSide.effects[PBEffects::Safeguard]>0
def pbMoveFailed?(user, targets)
if user.pbOwnSide.effects[PBEffects::Safeguard] > 0
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -526,7 +526,7 @@ class Battle::Move::StartUserSideImmunityToInflictedStatus < Battle::Move
def pbEffectGeneral(user)
user.pbOwnSide.effects[PBEffects::Safeguard] = 5
@battle.pbDisplay(_INTL("{1} became cloaked in a mystical veil!",user.pbTeam))
@battle.pbDisplay(_INTL("{1} became cloaked in a mystical veil!", user.pbTeam))
end
end
@@ -536,12 +536,12 @@ end
class Battle::Move::FlinchTarget < Battle::Move
def flinchingMove?; return true; end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
return if damagingMove?
target.pbFlinch(user)
end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.damageState.substitute
target.pbFlinch(user)
end
@@ -553,8 +553,8 @@ end
#===============================================================================
class Battle::Move::FlinchTargetTrampleMinimize < Battle::Move::FlinchTarget
def tramplesMinimize?(param = 1)
return true if param==1 && Settings::MECHANICS_GENERATION >= 6 # Perfect accuracy
return true if param==2 # Double damage
return true if param == 1 && Settings::MECHANICS_GENERATION >= 6 # Perfect accuracy
return true if param == 2 # Double damage
return super
end
end
@@ -565,7 +565,7 @@ end
class Battle::Move::FlinchTargetFailsIfUserNotAsleep < Battle::Move::FlinchTarget
def usableWhenAsleep?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !user.asleep?
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -579,7 +579,7 @@ end
# (Fake Out)
#===============================================================================
class Battle::Move::FlinchTargetFailsIfNotUserFirstTurn < Battle::Move::FlinchTarget
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if user.turnCount > 1
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -595,11 +595,11 @@ end
class Battle::Move::FlinchTargetDoublePowerIfTargetInSky < Battle::Move::FlinchTarget
def hitsFlyingTargets?; return true; end
def pbBaseDamage(baseDmg,user,target)
def pbBaseDamage(baseDmg, user, target)
baseDmg *= 2 if target.inTwoTurnAttack?("TwoTurnAttackInvulnerableInSky",
"TwoTurnAttackInvulnerableInSkyParalyzeTarget",
"TwoTurnAttackInvulnerableInSkyTargetCannotAct") ||
target.effects[PBEffects::SkyDrop]>=0
target.effects[PBEffects::SkyDrop] >= 0
return baseDmg
end
end
@@ -615,14 +615,14 @@ class Battle::Move::ConfuseTarget < Battle::Move
return !target.pbCanConfuse?(user, show_message, self)
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
return if damagingMove?
target.pbConfuse
end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.damageState.substitute
return if !target.pbCanConfuse?(user,false,self)
return if !target.pbCanConfuse?(user, false, self)
target.pbConfuse
end
end
@@ -634,7 +634,7 @@ end
class Battle::Move::ConfuseTargetAlwaysHitsInRainHitsTargetInSky < Battle::Move::ConfuseTarget
def hitsFlyingTargets?; return true; end
def pbBaseAccuracy(user,target)
def pbBaseAccuracy(user, target)
case target.effectiveWeather
when :Sun, :HarshSun
return 50
@@ -659,14 +659,14 @@ class Battle::Move::AttractTarget < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
return if damagingMove?
target.pbAttract(user)
end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.damageState.substitute
target.pbAttract(user) if target.pbCanAttract?(user,false)
target.pbAttract(user) if target.pbCanAttract?(user, false)
end
end
@@ -676,7 +676,7 @@ end
class Battle::Move::SetUserTypesBasedOnEnvironment < Battle::Move
def canSnatch?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !user.canChangeType?
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -742,7 +742,7 @@ class Battle::Move::SetUserTypesBasedOnEnvironment < Battle::Move
def pbEffectGeneral(user)
user.pbChangeTypes(@newType)
typeName = GameData::Type.get(@newType).name
@battle.pbDisplay(_INTL("{1}'s type changed to {2}!",user.pbThis,typeName))
@battle.pbDisplay(_INTL("{1}'s type changed to {2}!", user.pbThis, typeName))
end
end
@@ -794,7 +794,7 @@ end
class Battle::Move::SetUserTypesToTargetTypes < Battle::Move
def ignoresSubstitute?(user); return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !user.canChangeType?
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -804,22 +804,22 @@ class Battle::Move::SetUserTypesToTargetTypes < Battle::Move
def pbFailsAgainstTarget?(user, target, show_message)
newTypes = target.pbTypes(true)
if newTypes.length==0 # Target has no type to copy
if newTypes.length == 0 # Target has no type to copy
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
if user.pbTypes==target.pbTypes &&
user.effects[PBEffects::Type3]==target.effects[PBEffects::Type3]
if user.pbTypes == target.pbTypes &&
user.effects[PBEffects::Type3] == target.effects[PBEffects::Type3]
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
user.pbChangeTypes(target)
@battle.pbDisplay(_INTL("{1}'s type changed to match {2}'s!",
user.pbThis,target.pbThis(true)))
user.pbThis, target.pbThis(true)))
end
end
@@ -831,20 +831,20 @@ end
class Battle::Move::SetUserTypesToUserMoveType < Battle::Move
def canSnatch?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !user.canChangeType?
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
userTypes = user.pbTypes(true)
@newTypes = []
user.eachMoveWithIndex do |m,i|
break if Settings::MECHANICS_GENERATION >= 6 && i>0
user.eachMoveWithIndex do |m, i|
break if Settings::MECHANICS_GENERATION >= 6 && i > 0
next if GameData::Type.get(m.type).pseudo_type
next if userTypes.include?(m.type)
@newTypes.push(m.type) if !@newTypes.include?(m.type)
end
if @newTypes.length==0
if @newTypes.length == 0
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -855,7 +855,7 @@ class Battle::Move::SetUserTypesToUserMoveType < Battle::Move
newType = @newTypes[@battle.pbRandom(@newTypes.length)]
user.pbChangeTypes(newType)
typeName = GameData::Type.get(newType).name
@battle.pbDisplay(_INTL("{1}'s type changed to {2}!",user.pbThis,typeName))
@battle.pbDisplay(_INTL("{1}'s type changed to {2}!", user.pbThis, typeName))
end
end
@@ -896,10 +896,10 @@ class Battle::Move::SetTargetTypesToWater < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.pbChangeTypes(:WATER)
typeName = GameData::Type.get(:WATER).name
@battle.pbDisplay(_INTL("{1}'s type changed to {2}!",target.pbThis,typeName))
@battle.pbDisplay(_INTL("{1}'s type changed to {2}!", target.pbThis, typeName))
end
end
@@ -917,10 +917,10 @@ class Battle::Move::AddGhostTypeToTarget < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::Type3] = :GHOST
typeName = GameData::Type.get(:GHOST).name
@battle.pbDisplay(_INTL("{1} transformed into the {2} type!",target.pbThis,typeName))
@battle.pbDisplay(_INTL("{1} transformed into the {2} type!", target.pbThis, typeName))
end
end
@@ -938,10 +938,10 @@ class Battle::Move::AddGrassTypeToTarget < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::Type3] = :GRASS
typeName = GameData::Type.get(:GRASS).name
@battle.pbDisplay(_INTL("{1} transformed into the {2} type!",target.pbThis,typeName))
@battle.pbDisplay(_INTL("{1} transformed into the {2} type!", target.pbThis, typeName))
end
end
@@ -949,7 +949,7 @@ end
# User loses their Fire type. Fails if user is not Fire-type. (Burn Up)
#===============================================================================
class Battle::Move::UserLosesFireType < Battle::Move
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !user.pbHasType?(:FIRE)
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -957,10 +957,10 @@ class Battle::Move::UserLosesFireType < Battle::Move
return false
end
def pbEffectAfterAllHits(user,target)
def pbEffectAfterAllHits(user, target)
if !user.effects[PBEffects::BurnUp]
user.effects[PBEffects::BurnUp] = true
@battle.pbDisplay(_INTL("{1} burned itself out!",user.pbThis))
@battle.pbDisplay(_INTL("{1} burned itself out!", user.pbThis))
end
end
end
@@ -971,7 +971,7 @@ end
class Battle::Move::SetTargetAbilityToSimple < Battle::Move
def canMagicCoat?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !GameData::Ability.exists?(:SIMPLE)
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -987,12 +987,12 @@ class Battle::Move::SetTargetAbilityToSimple < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
@battle.pbShowAbilitySplash(target,true,false)
def pbEffectAgainstTarget(user, target)
@battle.pbShowAbilitySplash(target, true, false)
oldAbil = target.ability
target.ability = :SIMPLE
@battle.pbReplaceAbilitySplash(target)
@battle.pbDisplay(_INTL("{1} acquired {2}!",target.pbThis,target.abilityName))
@battle.pbDisplay(_INTL("{1} acquired {2}!", target.pbThis, target.abilityName))
@battle.pbHideAbilitySplash(target)
target.pbOnLosingAbility(oldAbil)
target.pbTriggerAbilityOnGainingIt
@@ -1005,7 +1005,7 @@ end
class Battle::Move::SetTargetAbilityToInsomnia < Battle::Move
def canMagicCoat?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !GameData::Ability.exists?(:INSOMNIA)
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -1021,12 +1021,12 @@ class Battle::Move::SetTargetAbilityToInsomnia < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
@battle.pbShowAbilitySplash(target,true,false)
def pbEffectAgainstTarget(user, target)
@battle.pbShowAbilitySplash(target, true, false)
oldAbil = target.ability
target.ability = :INSOMNIA
@battle.pbReplaceAbilitySplash(target)
@battle.pbDisplay(_INTL("{1} acquired {2}!",target.pbThis,target.abilityName))
@battle.pbDisplay(_INTL("{1} acquired {2}!", target.pbThis, target.abilityName))
@battle.pbHideAbilitySplash(target)
target.pbOnLosingAbility(oldAbil)
target.pbTriggerAbilityOnGainingIt
@@ -1039,7 +1039,7 @@ end
class Battle::Move::SetUserAbilityToTargetAbility < Battle::Move
def ignoresSubstitute?(user); return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if user.unstoppableAbility?
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -1048,7 +1048,7 @@ class Battle::Move::SetUserAbilityToTargetAbility < Battle::Move
end
def pbFailsAgainstTarget?(user, target, show_message)
if !target.ability || user.ability==target.ability
if !target.ability || user.ability == target.ability
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
@@ -1060,13 +1060,13 @@ class Battle::Move::SetUserAbilityToTargetAbility < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
@battle.pbShowAbilitySplash(user,true,false)
def pbEffectAgainstTarget(user, target)
@battle.pbShowAbilitySplash(user, true, false)
oldAbil = user.ability
user.ability = target.ability
@battle.pbReplaceAbilitySplash(user)
@battle.pbDisplay(_INTL("{1} copied {2}'s {3}!",
user.pbThis,target.pbThis(true),target.abilityName))
user.pbThis, target.pbThis(true), target.abilityName))
@battle.pbHideAbilitySplash(user)
user.pbOnLosingAbility(oldAbil)
user.pbTriggerAbilityOnGainingIt
@@ -1079,7 +1079,7 @@ end
class Battle::Move::SetTargetAbilityToUserAbility < Battle::Move
def canMagicCoat?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !user.ability
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -1100,12 +1100,12 @@ class Battle::Move::SetTargetAbilityToUserAbility < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
@battle.pbShowAbilitySplash(target,true,false)
def pbEffectAgainstTarget(user, target)
@battle.pbShowAbilitySplash(target, true, false)
oldAbil = target.ability
target.ability = user.ability
@battle.pbReplaceAbilitySplash(target)
@battle.pbDisplay(_INTL("{1} acquired {2}!",target.pbThis,target.abilityName))
@battle.pbDisplay(_INTL("{1} acquired {2}!", target.pbThis, target.abilityName))
@battle.pbHideAbilitySplash(target)
target.pbOnLosingAbility(oldAbil)
target.pbTriggerAbilityOnGainingIt
@@ -1118,7 +1118,7 @@ end
class Battle::Move::UserTargetSwapAbilities < Battle::Move
def ignoresSubstitute?(user); return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !user.ability
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -1151,10 +1151,10 @@ class Battle::Move::UserTargetSwapAbilities < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
if user.opposes?(target)
@battle.pbShowAbilitySplash(user,false,false)
@battle.pbShowAbilitySplash(target,true,false)
@battle.pbShowAbilitySplash(user, false, false)
@battle.pbShowAbilitySplash(target, true, false)
end
oldUserAbil = user.ability
oldTargetAbil = target.ability
@@ -1165,10 +1165,10 @@ class Battle::Move::UserTargetSwapAbilities < Battle::Move
@battle.pbReplaceAbilitySplash(target)
end
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} swapped Abilities with its target!",user.pbThis))
@battle.pbDisplay(_INTL("{1} swapped Abilities with its target!", user.pbThis))
else
@battle.pbDisplay(_INTL("{1} swapped its {2} Ability with its target's {3} Ability!",
user.pbThis,target.abilityName,user.abilityName))
user.pbThis, target.abilityName, user.abilityName))
end
if user.opposes?(target)
@battle.pbHideAbilitySplash(user)
@@ -1195,10 +1195,10 @@ class Battle::Move::NegateTargetAbility < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::GastroAcid] = true
target.effects[PBEffects::Truant] = false
@battle.pbDisplay(_INTL("{1}'s Ability was suppressed!",target.pbThis))
@battle.pbDisplay(_INTL("{1}'s Ability was suppressed!", target.pbThis))
target.pbOnLosingAbility(target.ability, true)
end
end
@@ -1208,15 +1208,15 @@ end
# performed its action this round. (Core Enforcer)
#===============================================================================
class Battle::Move::NegateTargetAbilityIfTargetActed < Battle::Move
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
return if target.damageState.substitute || target.effects[PBEffects::GastroAcid]
return if target.unstoppableAbility?
return if @battle.choices[target.index][0]!=:UseItem &&
!((@battle.choices[target.index][0]==:UseMove ||
@battle.choices[target.index][0]==:Shift) && target.movedThisRound?)
return if @battle.choices[target.index][0] != :UseItem &&
!((@battle.choices[target.index][0] == :UseMove ||
@battle.choices[target.index][0] == :Shift) && target.movedThisRound?)
target.effects[PBEffects::GastroAcid] = true
target.effects[PBEffects::Truant] = false
@battle.pbDisplay(_INTL("{1}'s Ability was suppressed!",target.pbThis))
@battle.pbDisplay(_INTL("{1}'s Ability was suppressed!", target.pbThis))
target.pbOnLosingAbility(target.ability, true)
end
end
@@ -1226,7 +1226,7 @@ end
# (Moongeist Beam, Sunsteel Strike)
#===============================================================================
class Battle::Move::IgnoreTargetAbility < Battle::Move
def pbChangeUsageCounters(user,specialUsage)
def pbChangeUsageCounters(user, specialUsage)
super
@battle.moldBreaker = true if !specialUsage
end
@@ -1239,10 +1239,10 @@ class Battle::Move::StartUserAirborne < Battle::Move
def unusableInGravity?; return true; end
def canSnatch?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if user.effects[PBEffects::Ingrain] ||
user.effects[PBEffects::SmackDown] ||
user.effects[PBEffects::MagnetRise]>0
user.effects[PBEffects::MagnetRise] > 0
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -1251,7 +1251,7 @@ class Battle::Move::StartUserAirborne < Battle::Move
def pbEffectGeneral(user)
user.effects[PBEffects::MagnetRise] = 5
@battle.pbDisplay(_INTL("{1} levitated with electromagnetism!",user.pbThis))
@battle.pbDisplay(_INTL("{1} levitated with electromagnetism!", user.pbThis))
end
end
@@ -1265,7 +1265,7 @@ class Battle::Move::StartTargetAirborneAndAlwaysHitByMoves < Battle::Move
def pbFailsAgainstTarget?(user, target, show_message)
if target.effects[PBEffects::Ingrain] ||
target.effects[PBEffects::SmackDown] ||
target.effects[PBEffects::Telekinesis]>0
target.effects[PBEffects::Telekinesis] > 0
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
@@ -1280,9 +1280,9 @@ class Battle::Move::StartTargetAirborneAndAlwaysHitByMoves < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::Telekinesis] = 3
@battle.pbDisplay(_INTL("{1} was hurled into the air!",target.pbThis))
@battle.pbDisplay(_INTL("{1} was hurled into the air!", target.pbThis))
end
end
@@ -1300,19 +1300,19 @@ end
class Battle::Move::HitsTargetInSkyGroundsTarget < Battle::Move
def hitsFlyingTargets?; return true; end
def pbCalcTypeModSingle(moveType,defType,user,target)
def pbCalcTypeModSingle(moveType, defType, user, target)
return Effectiveness::NORMAL_EFFECTIVE_ONE if moveType == :GROUND && defType == :FLYING
return super
end
def pbEffectAfterAllHits(user,target)
def pbEffectAfterAllHits(user, target)
return if target.fainted?
return if target.damageState.unaffected || target.damageState.substitute
return if target.inTwoTurnAttack?("TwoTurnAttackInvulnerableInSkyTargetCannotAct") ||
target.effects[PBEffects::SkyDrop]>=0 # Sky Drop
target.effects[PBEffects::SkyDrop] >= 0 # Sky Drop
return if !target.airborne? && !target.inTwoTurnAttack?("TwoTurnAttackInvulnerableInSky",
"TwoTurnAttackInvulnerableInSkyParalyzeTarget")
target.effects[PBEffects::SmackDown] = true
target.effects[PBEffects::SmackDown] = true
if target.inTwoTurnAttack?("TwoTurnAttackInvulnerableInSky",
"TwoTurnAttackInvulnerableInSkyParalyzeTarget") # NOTE: Not Sky Drop.
target.effects[PBEffects::TwoTurnAttack] = nil
@@ -1320,7 +1320,7 @@ class Battle::Move::HitsTargetInSkyGroundsTarget < Battle::Move
end
target.effects[PBEffects::MagnetRise] = 0
target.effects[PBEffects::Telekinesis] = 0
@battle.pbDisplay(_INTL("{1} fell straight down!",target.pbThis))
@battle.pbDisplay(_INTL("{1} fell straight down!", target.pbThis))
end
end
@@ -1329,8 +1329,8 @@ end
# (Gravity)
#===============================================================================
class Battle::Move::StartGravity < Battle::Move
def pbMoveFailed?(user,targets)
if @battle.field.effects[PBEffects::Gravity]>0
def pbMoveFailed?(user, targets)
if @battle.field.effects[PBEffects::Gravity] > 0
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -1349,9 +1349,9 @@ class Battle::Move::StartGravity < Battle::Move
@battle.pbClearChoice(b.index) if !b.movedThisRound?
showMessage = true
end
if b.effects[PBEffects::MagnetRise]>0 ||
b.effects[PBEffects::Telekinesis]>0 ||
b.effects[PBEffects::SkyDrop]>=0
if b.effects[PBEffects::MagnetRise] > 0 ||
b.effects[PBEffects::Telekinesis] > 0 ||
b.effects[PBEffects::SkyDrop] >= 0
b.effects[PBEffects::MagnetRise] = 0
b.effects[PBEffects::Telekinesis] = 0
b.effects[PBEffects::SkyDrop] = -1
@@ -1367,7 +1367,7 @@ end
# User transforms into the target. (Transform)
#===============================================================================
class Battle::Move::TransformUserIntoTarget < Battle::Move
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if user.effects[PBEffects::Transform]
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -1384,12 +1384,12 @@ class Battle::Move::TransformUserIntoTarget < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
user.pbTransform(target)
end
def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true)
def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true)
super
@battle.scene.pbChangePokemon(user,targets[0].pokemon)
@battle.scene.pbChangePokemon(user, targets[0].pokemon)
end
end

View File

@@ -2,16 +2,16 @@
# Hits twice.
#===============================================================================
class Battle::Move::HitTwoTimes < Battle::Move
def multiHitMove?; return true; end
def pbNumHits(user,targets); return 2; end
def multiHitMove?; return true; end
def pbNumHits(user, targets); return 2; end
end
#===============================================================================
# Hits twice. May poison the target on each hit. (Twineedle)
#===============================================================================
class Battle::Move::HitTwoTimesPoisonTarget < Battle::Move::PoisonTarget
def multiHitMove?; return true; end
def pbNumHits(user,targets); return 2; end
def multiHitMove?; return true; end
def pbNumHits(user, targets); return 2; end
end
#===============================================================================
@@ -69,19 +69,19 @@ end
# An accuracy check is performed for each hit.
#===============================================================================
class Battle::Move::HitThreeTimesPowersUpWithEachHit < Battle::Move
def multiHitMove?; return true; end
def pbNumHits(user,targets); return 3; end
def multiHitMove?; return true; end
def pbNumHits(user, targets); return 3; end
def successCheckPerHit?
return @accCheckPerHit
end
def pbOnStartUse(user,targets)
def pbOnStartUse(user, targets)
@calcBaseDmg = 0
@accCheckPerHit = !user.hasActiveAbility?(:SKILLLINK)
end
def pbBaseDamage(baseDmg,user,target)
def pbBaseDamage(baseDmg, user, target)
@calcBaseDmg += baseDmg
return @calcBaseDmg
end
@@ -103,7 +103,7 @@ end
class Battle::Move::HitTwoToFiveTimes < Battle::Move
def multiHitMove?; return true; end
def pbNumHits(user,targets)
def pbNumHits(user, targets)
hitChances = [
2, 2, 2, 2, 2, 2, 2,
3, 3, 3, 3, 3, 3, 3,
@@ -111,7 +111,7 @@ class Battle::Move::HitTwoToFiveTimes < Battle::Move
5, 5, 5
]
r = @battle.pbRandom(hitChances.length)
r = hitChances.length-1 if user.hasActiveAbility?(:SKILLLINK)
r = hitChances.length - 1 if user.hasActiveAbility?(:SKILLLINK)
return hitChances[r]
end
end
@@ -121,12 +121,12 @@ end
# (Water Shuriken)
#===============================================================================
class Battle::Move::HitTwoToFiveTimesOrThreeForAshGreninja < Battle::Move::HitTwoToFiveTimes
def pbNumHits(user,targets)
def pbNumHits(user, targets)
return 3 if user.isSpecies?(:GRENINJA) && user.form == 2
return super
end
def pbBaseDamage(baseDmg,user,target)
def pbBaseDamage(baseDmg, user, target)
return 20 if user.isSpecies?(:GRENINJA) && user.form == 2
return super
end
@@ -171,27 +171,27 @@ end
class Battle::Move::HitOncePerUserTeamMember < Battle::Move
def multiHitMove?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
@beatUpList = []
@battle.eachInTeamFromBattlerIndex(user.index) do |pkmn,i|
@battle.eachInTeamFromBattlerIndex(user.index) do |pkmn, i|
next if !pkmn.able? || pkmn.status != :NONE
@beatUpList.push(i)
end
if @beatUpList.length==0
if @beatUpList.length == 0
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
return false
end
def pbNumHits(user,targets)
def pbNumHits(user, targets)
return @beatUpList.length
end
def pbBaseDamage(baseDmg,user,target)
def pbBaseDamage(baseDmg, user, target)
i = @beatUpList.shift # First element in array, and removes it from array
atk = @battle.pbParty(user.index)[i].baseStats[:ATTACK]
return 5+(atk/10)
return 5 + (atk / 10)
end
end
@@ -209,8 +209,8 @@ end
# Two turn attack. Skips first turn, attacks second turn. (Razor Wind)
#===============================================================================
class Battle::Move::TwoTurnAttack < Battle::Move::TwoTurnMove
def pbChargingTurnMessage(user,targets)
@battle.pbDisplay(_INTL("{1} whipped up a whirlwind!",user.pbThis))
def pbChargingTurnMessage(user, targets)
@battle.pbDisplay(_INTL("{1} whipped up a whirlwind!", user.pbThis))
end
end
@@ -232,11 +232,11 @@ class Battle::Move::TwoTurnAttackOneTurnInSun < Battle::Move::TwoTurnMove
return ret
end
def pbChargingTurnMessage(user,targets)
@battle.pbDisplay(_INTL("{1} took in sunlight!",user.pbThis))
def pbChargingTurnMessage(user, targets)
@battle.pbDisplay(_INTL("{1} took in sunlight!", user.pbThis))
end
def pbBaseDamageMultiplier(damageMult,user,target)
def pbBaseDamageMultiplier(damageMult, user, target)
damageMult /= 2 if ![:None, :Sun, :HarshSun].include?(user.effectiveWeather)
return damageMult
end
@@ -247,13 +247,13 @@ end
# May paralyze the target.
#===============================================================================
class Battle::Move::TwoTurnAttackParalyzeTarget < Battle::Move::TwoTurnMove
def pbChargingTurnMessage(user,targets)
@battle.pbDisplay(_INTL("{1} became cloaked in a freezing light!",user.pbThis))
def pbChargingTurnMessage(user, targets)
@battle.pbDisplay(_INTL("{1} became cloaked in a freezing light!", user.pbThis))
end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.damageState.substitute
target.pbParalyze(user) if target.pbCanParalyze?(user,false,self)
target.pbParalyze(user) if target.pbCanParalyze?(user, false, self)
end
end
@@ -262,13 +262,13 @@ end
# May burn the target.
#===============================================================================
class Battle::Move::TwoTurnAttackBurnTarget < Battle::Move::TwoTurnMove
def pbChargingTurnMessage(user,targets)
@battle.pbDisplay(_INTL("{1} became cloaked in freezing air!",user.pbThis))
def pbChargingTurnMessage(user, targets)
@battle.pbDisplay(_INTL("{1} became cloaked in freezing air!", user.pbThis))
end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.damageState.substitute
target.pbBurn(user) if target.pbCanBurn?(user,false,self)
target.pbBurn(user) if target.pbCanBurn?(user, false, self)
end
end
@@ -279,11 +279,11 @@ end
class Battle::Move::TwoTurnAttackFlinchTarget < Battle::Move::TwoTurnMove
def flinchingMove?; return true; end
def pbChargingTurnMessage(user,targets)
@battle.pbDisplay(_INTL("{1} became cloaked in a harsh light!",user.pbThis))
def pbChargingTurnMessage(user, targets)
@battle.pbDisplay(_INTL("{1} became cloaked in a harsh light!", user.pbThis))
end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.damageState.substitute
target.pbFlinch(user)
end
@@ -294,27 +294,27 @@ end
# Special Defense and Speed by 2 stages each in the second turn. (Geomancy)
#===============================================================================
class Battle::Move::TwoTurnAttackRaiseUserSpAtkSpDefSpd2 < Battle::Move::TwoTurnMove
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
return false if user.effects[PBEffects::TwoTurnAttack] # Charging turn
if !user.pbCanRaiseStatStage?(:SPECIAL_ATTACK,user,self) &&
!user.pbCanRaiseStatStage?(:SPECIAL_DEFENSE,user,self) &&
!user.pbCanRaiseStatStage?(:SPEED,user,self)
@battle.pbDisplay(_INTL("{1}'s stats won't go any higher!",user.pbThis))
if !user.pbCanRaiseStatStage?(:SPECIAL_ATTACK, user, self) &&
!user.pbCanRaiseStatStage?(:SPECIAL_DEFENSE, user, self) &&
!user.pbCanRaiseStatStage?(:SPEED, user, self)
@battle.pbDisplay(_INTL("{1}'s stats won't go any higher!", user.pbThis))
return true
end
return false
end
def pbChargingTurnMessage(user,targets)
@battle.pbDisplay(_INTL("{1} is absorbing power!",user.pbThis))
def pbChargingTurnMessage(user, targets)
@battle.pbDisplay(_INTL("{1} is absorbing power!", user.pbThis))
end
def pbEffectGeneral(user)
return if !@damagingTurn
showAnim = true
[:SPECIAL_ATTACK,:SPECIAL_DEFENSE,:SPEED].each do |s|
next if !user.pbCanRaiseStatStage?(s,user,self)
if user.pbRaiseStatStage(s,2,user,showAnim)
[:SPECIAL_ATTACK, :SPECIAL_DEFENSE, :SPEED].each do |s|
next if !user.pbCanRaiseStatStage?(s, user, self)
if user.pbRaiseStatStage(s, 2, user, showAnim)
showAnim = false
end
end
@@ -326,13 +326,13 @@ end
# (Skull Bash)
#===============================================================================
class Battle::Move::TwoTurnAttackChargeRaiseUserDefense1 < Battle::Move::TwoTurnMove
def pbChargingTurnMessage(user,targets)
@battle.pbDisplay(_INTL("{1} tucked in its head!",user.pbThis))
def pbChargingTurnMessage(user, targets)
@battle.pbDisplay(_INTL("{1} tucked in its head!", user.pbThis))
end
def pbChargingTurnEffect(user,target)
if user.pbCanRaiseStatStage?(:DEFENSE,user,self)
user.pbRaiseStatStage(:DEFENSE,1,user)
def pbChargingTurnEffect(user, target)
if user.pbCanRaiseStatStage?(:DEFENSE, user, self)
user.pbRaiseStatStage(:DEFENSE, 1, user)
end
end
end
@@ -358,8 +358,8 @@ end
# (Handled in Battler's pbSuccessCheckPerHit): Is semi-invulnerable during use.
#===============================================================================
class Battle::Move::TwoTurnAttackInvulnerableUnderground < Battle::Move::TwoTurnMove
def pbChargingTurnMessage(user,targets)
@battle.pbDisplay(_INTL("{1} burrowed its way under the ground!",user.pbThis))
def pbChargingTurnMessage(user, targets)
@battle.pbDisplay(_INTL("{1} burrowed its way under the ground!", user.pbThis))
end
end
@@ -368,8 +368,8 @@ end
# (Handled in Battler's pbSuccessCheckPerHit): Is semi-invulnerable during use.
#===============================================================================
class Battle::Move::TwoTurnAttackInvulnerableUnderwater < Battle::Move::TwoTurnMove
def pbChargingTurnMessage(user,targets)
@battle.pbDisplay(_INTL("{1} hid underwater!",user.pbThis))
def pbChargingTurnMessage(user, targets)
@battle.pbDisplay(_INTL("{1} hid underwater!", user.pbThis))
end
end
@@ -380,8 +380,8 @@ end
class Battle::Move::TwoTurnAttackInvulnerableInSky < Battle::Move::TwoTurnMove
def unusableInGravity?; return true; end
def pbChargingTurnMessage(user,targets)
@battle.pbDisplay(_INTL("{1} flew up high!",user.pbThis))
def pbChargingTurnMessage(user, targets)
@battle.pbDisplay(_INTL("{1} flew up high!", user.pbThis))
end
end
@@ -393,13 +393,13 @@ end
class Battle::Move::TwoTurnAttackInvulnerableInSkyParalyzeTarget < Battle::Move::TwoTurnMove
def unusableInGravity?; return true; end
def pbChargingTurnMessage(user,targets)
@battle.pbDisplay(_INTL("{1} sprang up!",user.pbThis))
def pbChargingTurnMessage(user, targets)
@battle.pbDisplay(_INTL("{1} sprang up!", user.pbThis))
end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.damageState.substitute
target.pbParalyze(user) if target.pbCanParalyze?(user,false,self)
target.pbParalyze(user) if target.pbCanParalyze?(user, false, self)
end
end
@@ -426,44 +426,44 @@ class Battle::Move::TwoTurnAttackInvulnerableInSkyTargetCannotAct < Battle::Move
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
if target.effects[PBEffects::Substitute]>0 && !ignoresSubstitute?(user)
if target.effects[PBEffects::Substitute] > 0 && !ignoresSubstitute?(user)
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
if Settings::MECHANICS_GENERATION >= 6 && target.pbWeight>=2000 # 200.0kg
if Settings::MECHANICS_GENERATION >= 6 && target.pbWeight >= 2000 # 200.0kg
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
if target.semiInvulnerable? ||
(target.effects[PBEffects::SkyDrop]>=0 && @chargingTurn)
(target.effects[PBEffects::SkyDrop] >= 0 && @chargingTurn)
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
if target.effects[PBEffects::SkyDrop]!=user.index && @damagingTurn
if target.effects[PBEffects::SkyDrop] != user.index && @damagingTurn
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
return false
end
def pbCalcTypeMod(movetype,user,target)
def pbCalcTypeMod(movetype, user, target)
return Effectiveness::INEFFECTIVE if target.pbHasType?(:FLYING)
return super
end
def pbChargingTurnMessage(user,targets)
@battle.pbDisplay(_INTL("{1} took {2} into the sky!",user.pbThis,targets[0].pbThis(true)))
def pbChargingTurnMessage(user, targets)
@battle.pbDisplay(_INTL("{1} took {2} into the sky!", user.pbThis, targets[0].pbThis(true)))
end
def pbAttackingTurnMessage(user,targets)
@battle.pbDisplay(_INTL("{1} was freed from the Sky Drop!",targets[0].pbThis))
def pbAttackingTurnMessage(user, targets)
@battle.pbDisplay(_INTL("{1} was freed from the Sky Drop!", targets[0].pbThis))
end
def pbChargingTurnEffect(user,target)
def pbChargingTurnEffect(user, target)
target.effects[PBEffects::SkyDrop] = user.index
end
def pbAttackingTurnEffect(user,target)
def pbAttackingTurnEffect(user, target)
target.effects[PBEffects::SkyDrop] = -1
end
end
@@ -473,11 +473,11 @@ end
# use. Ends target's protections upon hit. (Shadow Force, Phantom Force)
#===============================================================================
class Battle::Move::TwoTurnAttackInvulnerableRemoveProtections < Battle::Move::TwoTurnMove
def pbChargingTurnMessage(user,targets)
@battle.pbDisplay(_INTL("{1} vanished instantly!",user.pbThis))
def pbChargingTurnMessage(user, targets)
@battle.pbDisplay(_INTL("{1} vanished instantly!", user.pbThis))
end
def pbAttackingTurnEffect(user,target)
def pbAttackingTurnEffect(user, target)
target.effects[PBEffects::BanefulBunker] = false
target.effects[PBEffects::KingsShield] = false
target.effects[PBEffects::Obstruct] = false
@@ -499,10 +499,10 @@ end
#===============================================================================
class Battle::Move::MultiTurnAttackPreventSleeping < Battle::Move
def pbEffectGeneral(user)
return if user.effects[PBEffects::Uproar]>0
return if user.effects[PBEffects::Uproar] > 0
user.effects[PBEffects::Uproar] = 3
user.currentMove = @id
@battle.pbDisplay(_INTL("{1} caused an uproar!",user.pbThis))
@battle.pbDisplay(_INTL("{1} caused an uproar!", user.pbThis))
@battle.pbPriority(true).each do |b|
next if b.fainted? || b.status != :SLEEP
next if b.hasActiveAbility?(:SOUNDPROOF)
@@ -516,15 +516,15 @@ end
# (Outrage, Petal Dange, Thrash)
#===============================================================================
class Battle::Move::MultiTurnAttackConfuseUserAtEnd < Battle::Move
def pbEffectAfterAllHits(user,target)
if !target.damageState.unaffected && user.effects[PBEffects::Outrage]==0
user.effects[PBEffects::Outrage] = 2+@battle.pbRandom(2)
def pbEffectAfterAllHits(user, target)
if !target.damageState.unaffected && user.effects[PBEffects::Outrage] == 0
user.effects[PBEffects::Outrage] = 2 + @battle.pbRandom(2)
user.currentMove = @id
end
if user.effects[PBEffects::Outrage]>0
if user.effects[PBEffects::Outrage] > 0
user.effects[PBEffects::Outrage] -= 1
if user.effects[PBEffects::Outrage]==0 && user.pbCanConfuseSelf?(false)
user.pbConfuse(_INTL("{1} became confused due to fatigue!",user.pbThis))
if user.effects[PBEffects::Outrage] == 0 && user.pbCanConfuseSelf?(false)
user.pbConfuse(_INTL("{1} became confused due to fatigue!", user.pbThis))
end
end
end
@@ -535,7 +535,7 @@ end
# Power is also doubled if user has curled up. (Ice Ball, Rollout)
#===============================================================================
class Battle::Move::MultiTurnAttackPowersUpEachTurn < Battle::Move
def pbBaseDamage(baseDmg,user,target)
def pbBaseDamage(baseDmg, user, target)
shift = (5 - user.effects[PBEffects::Rollout]) # 0-4, where 0 is most powerful
shift = 0 if user.effects[PBEffects::Rollout] == 0 # For first turn
shift += 1 if user.effects[PBEffects::DefenseCurl]
@@ -543,7 +543,7 @@ class Battle::Move::MultiTurnAttackPowersUpEachTurn < Battle::Move
return baseDmg
end
def pbEffectAfterAllHits(user,target)
def pbEffectAfterAllHits(user, target)
if !target.damageState.unaffected && user.effects[PBEffects::Rollout] == 0
user.effects[PBEffects::Rollout] = 5
user.currentMove = @id
@@ -558,23 +558,23 @@ end
# (Bide)
#===============================================================================
class Battle::Move::MultiTurnAttackBideThenReturnDoubleDamage < Battle::Move::FixedDamageMove
def pbAddTarget(targets,user)
return if user.effects[PBEffects::Bide]!=1 # Not the attack turn
def pbAddTarget(targets, user)
return if user.effects[PBEffects::Bide] != 1 # Not the attack turn
idxTarget = user.effects[PBEffects::BideTarget]
t = (idxTarget>=0) ? @battle.battlers[idxTarget] : nil
if !user.pbAddTarget(targets,user,t,self,false)
user.pbAddTargetRandomFoe(targets,user,self,false)
t = (idxTarget >= 0) ? @battle.battlers[idxTarget] : nil
if !user.pbAddTarget(targets, user, t, self, false)
user.pbAddTargetRandomFoe(targets, user, self, false)
end
end
def pbMoveFailed?(user,targets)
return false if user.effects[PBEffects::Bide]!=1 # Not the attack turn
if user.effects[PBEffects::BideDamage]==0
def pbMoveFailed?(user, targets)
return false if user.effects[PBEffects::Bide] != 1 # Not the attack turn
if user.effects[PBEffects::BideDamage] == 0
@battle.pbDisplay(_INTL("But it failed!"))
user.effects[PBEffects::Bide] = 0 # No need to reset other Bide variables
return true
end
if targets.length==0
if targets.length == 0
@battle.pbDisplay(_INTL("But there was no target..."))
user.effects[PBEffects::Bide] = 0 # No need to reset other Bide variables
return true
@@ -582,15 +582,15 @@ class Battle::Move::MultiTurnAttackBideThenReturnDoubleDamage < Battle::Move::Fi
return false
end
def pbOnStartUse(user,targets)
@damagingTurn = (user.effects[PBEffects::Bide]==1) # If attack turn
def pbOnStartUse(user, targets)
@damagingTurn = (user.effects[PBEffects::Bide] == 1) # If attack turn
end
def pbDisplayUseMessage(user)
if @damagingTurn # Attack turn
@battle.pbDisplayBrief(_INTL("{1} unleashed energy!",user.pbThis))
elsif user.effects[PBEffects::Bide]>1 # Charging turns
@battle.pbDisplayBrief(_INTL("{1} is storing energy!",user.pbThis))
@battle.pbDisplayBrief(_INTL("{1} unleashed energy!", user.pbThis))
elsif user.effects[PBEffects::Bide] > 1 # Charging turns
@battle.pbDisplayBrief(_INTL("{1} is storing energy!", user.pbThis))
else
super # Start using Bide
end
@@ -601,12 +601,12 @@ class Battle::Move::MultiTurnAttackBideThenReturnDoubleDamage < Battle::Move::Fi
return super
end
def pbFixedDamage(user,target)
return user.effects[PBEffects::BideDamage]*2
def pbFixedDamage(user, target)
return user.effects[PBEffects::BideDamage] * 2
end
def pbEffectGeneral(user)
if user.effects[PBEffects::Bide]==0 # Starting using Bide
if user.effects[PBEffects::Bide] == 0 # Starting using Bide
user.effects[PBEffects::Bide] = 3
user.effects[PBEffects::BideDamage] = 0
user.effects[PBEffects::BideTarget] = -1
@@ -615,7 +615,7 @@ class Battle::Move::MultiTurnAttackBideThenReturnDoubleDamage < Battle::Move::Fi
user.effects[PBEffects::Bide] -= 1
end
def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true)
def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true)
hitNum = 1 if !@damagingTurn # Charging anim
super
end

View File

@@ -2,22 +2,22 @@
# Heals user to full HP. User falls asleep for 2 more rounds. (Rest)
#===============================================================================
class Battle::Move::HealUserFullyAndFallAsleep < Battle::Move::HealingMove
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if user.asleep?
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
return true if !user.pbCanSleep?(user,true,self,true)
return true if !user.pbCanSleep?(user, true, self, true)
return true if super
return false
end
def pbHealAmount(user)
return user.totalhp-user.hp
return user.totalhp - user.hp
end
def pbEffectGeneral(user)
user.pbSleepSelf(_INTL("{1} slept and became healthy!",user.pbThis),3)
user.pbSleepSelf(_INTL("{1} slept and became healthy!", user.pbThis), 3)
super
end
end
@@ -27,7 +27,7 @@ end
#===============================================================================
class Battle::Move::HealUserHalfOfTotalHP < Battle::Move::HealingMove
def pbHealAmount(user)
return (user.totalhp/2.0).round
return (user.totalhp / 2.0).round
end
end
@@ -36,14 +36,14 @@ end
# Synthesis)
#===============================================================================
class Battle::Move::HealUserDependingOnWeather < Battle::Move::HealingMove
def pbOnStartUse(user,targets)
def pbOnStartUse(user, targets)
case user.effectiveWeather
when :Sun, :HarshSun
@healAmount = (user.totalhp*2/3.0).round
@healAmount = (user.totalhp * 2 / 3.0).round
when :None, :StrongWinds
@healAmount = (user.totalhp/2.0).round
@healAmount = (user.totalhp / 2.0).round
else
@healAmount = (user.totalhp/4.0).round
@healAmount = (user.totalhp / 4.0).round
end
end
@@ -68,7 +68,7 @@ end
#===============================================================================
class Battle::Move::HealUserHalfOfTotalHPLoseFlyingTypeThisTurn < Battle::Move::HealingMove
def pbHealAmount(user)
return (user.totalhp/2.0).round
return (user.totalhp / 2.0).round
end
def pbEffectGeneral(user)
@@ -94,10 +94,10 @@ class Battle::Move::CureTargetStatusHealUserHalfOfTotalHP < Battle::Move::Healin
end
def pbHealAmount(user)
return (user.totalhp/2.0).round
return (user.totalhp / 2.0).round
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.pbCureStatus
super
end
@@ -129,28 +129,28 @@ class Battle::Move::HealUserByTargetAttackLowerTargetAttack1 < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
# Calculate target's effective attack value
stageMul = [2,2,2,2,2,2, 2, 3,4,5,6,7,8]
stageDiv = [8,7,6,5,4,3, 2, 2,2,2,2,2,2]
stageMul = [2, 2, 2, 2, 2, 2, 2, 3, 4, 5, 6, 7, 8]
stageDiv = [8, 7, 6, 5, 4, 3, 2, 2, 2, 2, 2, 2, 2]
atk = target.attack
atkStage = target.stages[:ATTACK]+6
healAmt = (atk.to_f*stageMul[atkStage]/stageDiv[atkStage]).floor
atkStage = target.stages[:ATTACK] + 6
healAmt = (atk.to_f * stageMul[atkStage] / stageDiv[atkStage]).floor
# Reduce target's Attack stat
if target.pbCanLowerStatStage?(:ATTACK,user,self)
target.pbLowerStatStage(:ATTACK,1,user)
if target.pbCanLowerStatStage?(:ATTACK, user, self)
target.pbLowerStatStage(:ATTACK, 1, user)
end
# Heal user
if target.hasActiveAbility?(:LIQUIDOOZE)
@battle.pbShowAbilitySplash(target)
user.pbReduceHP(healAmt)
@battle.pbDisplay(_INTL("{1} sucked up the liquid ooze!",user.pbThis))
@battle.pbDisplay(_INTL("{1} sucked up the liquid ooze!", user.pbThis))
@battle.pbHideAbilitySplash(target)
user.pbItemHPHealCheck
elsif user.canHeal?
healAmt = (healAmt*1.3).floor if user.hasActiveItem?(:BIGROOT)
healAmt = (healAmt * 1.3).floor if user.hasActiveItem?(:BIGROOT)
user.pbRecoverHP(healAmt)
@battle.pbDisplay(_INTL("{1}'s HP was restored.",user.pbThis))
@battle.pbDisplay(_INTL("{1}'s HP was restored.", user.pbThis))
end
end
end
@@ -161,10 +161,10 @@ end
class Battle::Move::HealUserByHalfOfDamageDone < Battle::Move
def healingMove?; return Settings::MECHANICS_GENERATION >= 6; end
def pbEffectAgainstTarget(user,target)
return if target.damageState.hpLost<=0
hpGain = (target.damageState.hpLost/2.0).round
user.pbRecoverHPFromDrain(hpGain,target)
def pbEffectAgainstTarget(user, target)
return if target.damageState.hpLost <= 0
hpGain = (target.damageState.hpLost / 2.0).round
user.pbRecoverHPFromDrain(hpGain, target)
end
end
@@ -183,10 +183,10 @@ class Battle::Move::HealUserByHalfOfDamageDoneIfTargetAsleep < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
return if target.damageState.hpLost<=0
hpGain = (target.damageState.hpLost/2.0).round
user.pbRecoverHPFromDrain(hpGain,target)
def pbEffectAgainstTarget(user, target)
return if target.damageState.hpLost <= 0
hpGain = (target.damageState.hpLost / 2.0).round
user.pbRecoverHPFromDrain(hpGain, target)
end
end
@@ -196,10 +196,10 @@ end
class Battle::Move::HealUserByThreeQuartersOfDamageDone < Battle::Move
def healingMove?; return Settings::MECHANICS_GENERATION >= 6; end
def pbEffectAgainstTarget(user,target)
return if target.damageState.hpLost<=0
hpGain = (target.damageState.hpLost*0.75).round
user.pbRecoverHPFromDrain(hpGain,target)
def pbEffectAgainstTarget(user, target)
return if target.damageState.hpLost <= 0
hpGain = (target.damageState.hpLost * 0.75).round
user.pbRecoverHPFromDrain(hpGain, target)
end
end
@@ -278,7 +278,7 @@ class Battle::Move::HealTargetHalfOfTotalHP < Battle::Move
def canMagicCoat?; return true; end
def pbFailsAgainstTarget?(user, target, show_message)
if target.hp==target.totalhp
if target.hp == target.totalhp
@battle.pbDisplay(_INTL("{1}'s HP is full!", target.pbThis)) if show_message
return true
elsif !target.canHeal?
@@ -288,13 +288,13 @@ class Battle::Move::HealTargetHalfOfTotalHP < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
hpGain = (target.totalhp/2.0).round
def pbEffectAgainstTarget(user, target)
hpGain = (target.totalhp / 2.0).round
if pulseMove? && user.hasActiveAbility?(:MEGALAUNCHER)
hpGain = (target.totalhp*3/4.0).round
hpGain = (target.totalhp * 3 / 4.0).round
end
target.pbRecoverHP(hpGain)
@battle.pbDisplay(_INTL("{1}'s HP was restored.",target.pbThis))
@battle.pbDisplay(_INTL("{1}'s HP was restored.", target.pbThis))
end
end
@@ -307,7 +307,7 @@ class Battle::Move::HealTargetDependingOnGrassyTerrain < Battle::Move
def canMagicCoat?; return true; end
def pbFailsAgainstTarget?(user, target, show_message)
if target.hp==target.totalhp
if target.hp == target.totalhp
@battle.pbDisplay(_INTL("{1}'s HP is full!", target.pbThis)) if show_message
return true
elsif !target.canHeal?
@@ -317,11 +317,11 @@ class Battle::Move::HealTargetDependingOnGrassyTerrain < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
hpGain = (target.totalhp/2.0).round
hpGain = (target.totalhp*2/3.0).round if @battle.field.terrain == :Grassy
def pbEffectAgainstTarget(user, target)
hpGain = (target.totalhp / 2.0).round
hpGain = (target.totalhp * 2 / 3.0).round if @battle.field.terrain == :Grassy
target.pbRecoverHP(hpGain)
@battle.pbDisplay(_INTL("{1}'s HP was restored.",target.pbThis))
@battle.pbDisplay(_INTL("{1}'s HP was restored.", target.pbThis))
end
end
@@ -333,8 +333,8 @@ class Battle::Move::HealUserPositionNextTurn < Battle::Move
def healingMove?; return true; end
def canSnatch?; return true; end
def pbMoveFailed?(user,targets)
if @battle.positions[user.index].effects[PBEffects::Wish]>0
def pbMoveFailed?(user, targets)
if @battle.positions[user.index].effects[PBEffects::Wish] > 0
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -343,7 +343,7 @@ class Battle::Move::HealUserPositionNextTurn < Battle::Move
def pbEffectGeneral(user)
@battle.positions[user.index].effects[PBEffects::Wish] = 2
@battle.positions[user.index].effects[PBEffects::WishAmount] = (user.totalhp/2.0).round
@battle.positions[user.index].effects[PBEffects::WishAmount] = (user.totalhp / 2.0).round
@battle.positions[user.index].effects[PBEffects::WishMaker] = user.pokemonIndex
end
end
@@ -355,7 +355,7 @@ end
class Battle::Move::StartHealUserEachTurn < Battle::Move
def canSnatch?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if user.effects[PBEffects::AquaRing]
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -365,7 +365,7 @@ class Battle::Move::StartHealUserEachTurn < Battle::Move
def pbEffectGeneral(user)
user.effects[PBEffects::AquaRing] = true
@battle.pbDisplay(_INTL("{1} surrounded itself with a veil of water!",user.pbThis))
@battle.pbDisplay(_INTL("{1} surrounded itself with a veil of water!", user.pbThis))
end
end
@@ -376,7 +376,7 @@ end
class Battle::Move::StartHealUserEachTurnTrapUserInBattle < Battle::Move
def canSnatch?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if user.effects[PBEffects::Ingrain]
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -386,7 +386,7 @@ class Battle::Move::StartHealUserEachTurnTrapUserInBattle < Battle::Move
def pbEffectGeneral(user)
user.effects[PBEffects::Ingrain] = true
@battle.pbDisplay(_INTL("{1} planted its roots!",user.pbThis))
@battle.pbDisplay(_INTL("{1} planted its roots!", user.pbThis))
end
end
@@ -402,9 +402,9 @@ class Battle::Move::StartDamageTargetEachTurnIfTargetAsleep < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::Nightmare] = true
@battle.pbDisplay(_INTL("{1} began having a nightmare!",target.pbThis))
@battle.pbDisplay(_INTL("{1} began having a nightmare!", target.pbThis))
end
end
@@ -416,7 +416,7 @@ class Battle::Move::StartLeechSeedTarget < Battle::Move
def canMagicCoat?; return true; end
def pbFailsAgainstTarget?(user, target, show_message)
if target.effects[PBEffects::LeechSeed]>=0
if target.effects[PBEffects::LeechSeed] >= 0
@battle.pbDisplay(_INTL("{1} evaded the attack!", target.pbThis)) if show_message
return true
end
@@ -427,14 +427,14 @@ class Battle::Move::StartLeechSeedTarget < Battle::Move
return false
end
def pbMissMessage(user,target)
@battle.pbDisplay(_INTL("{1} evaded the attack!",target.pbThis))
def pbMissMessage(user, target)
@battle.pbDisplay(_INTL("{1} evaded the attack!", target.pbThis))
return true
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::LeechSeed] = user.index
@battle.pbDisplay(_INTL("{1} was seeded!",target.pbThis))
@battle.pbDisplay(_INTL("{1} was seeded!", target.pbThis))
end
end
@@ -459,16 +459,16 @@ end
class Battle::Move::UserLosesHalfOfTotalHPExplosive < Battle::Move
def worksWithNoTargets?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !@battle.moldBreaker
bearer = @battle.pbCheckGlobalAbility(:DAMP)
if bearer!=nil
if bearer != nil
@battle.pbShowAbilitySplash(bearer)
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} cannot use {2}!",user.pbThis,@name))
@battle.pbDisplay(_INTL("{1} cannot use {2}!", user.pbThis, @name))
else
@battle.pbDisplay(_INTL("{1} cannot use {2} because of {3}'s {4}!",
user.pbThis,@name,bearer.pbThis(true),bearer.abilityName))
user.pbThis, @name, bearer.pbThis(true), bearer.abilityName))
end
@battle.pbHideAbilitySplash(bearer)
return true
@@ -479,7 +479,7 @@ class Battle::Move::UserLosesHalfOfTotalHPExplosive < Battle::Move
def pbSelfKO(user)
return if !user.takesIndirectDamage?
user.pbReduceHP((user.totalhp/2.0).round,false)
user.pbReduceHP((user.totalhp / 2.0).round, false)
user.pbItemHPHealCheck
end
end
@@ -489,18 +489,18 @@ end
#===============================================================================
class Battle::Move::UserFaintsExplosive < Battle::Move
def worksWithNoTargets?; return true; end
def pbNumHits(user,targets); return 1; end
def pbNumHits(user, targets); return 1; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !@battle.moldBreaker
bearer = @battle.pbCheckGlobalAbility(:DAMP)
if bearer!=nil
if bearer != nil
@battle.pbShowAbilitySplash(bearer)
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} cannot use {2}!",user.pbThis,@name))
@battle.pbDisplay(_INTL("{1} cannot use {2}!", user.pbThis, @name))
else
@battle.pbDisplay(_INTL("{1} cannot use {2} because of {3}'s {4}!",
user.pbThis,@name,bearer.pbThis(true),bearer.abilityName))
user.pbThis, @name, bearer.pbThis(true), bearer.abilityName))
end
@battle.pbHideAbilitySplash(bearer)
return true
@@ -511,7 +511,7 @@ class Battle::Move::UserFaintsExplosive < Battle::Move
def pbSelfKO(user)
return if user.fainted?
user.pbReduceHP(user.hp,false)
user.pbReduceHP(user.hp, false)
user.pbItemHPHealCheck
end
end
@@ -532,19 +532,19 @@ end
# User faints (if successful).
#===============================================================================
class Battle::Move::UserFaintsFixedDamageUserHP < Battle::Move::FixedDamageMove
def pbNumHits(user,targets); return 1; end
def pbNumHits(user, targets); return 1; end
def pbOnStartUse(user,targets)
def pbOnStartUse(user, targets)
@finalGambitDamage = user.hp
end
def pbFixedDamage(user,target)
def pbFixedDamage(user, target)
return @finalGambitDamage
end
def pbSelfKO(user)
return if user.fainted?
user.pbReduceHP(user.hp,false)
user.pbReduceHP(user.hp, false)
user.pbItemHPHealCheck
end
end
@@ -556,9 +556,9 @@ end
class Battle::Move::UserFaintsLowerTargetAtkSpAtk2 < Battle::Move::TargetMultiStatDownMove
def canMagicCoat?; return false; end
def initialize(battle,move)
def initialize(battle, move)
super
@statDown = [:ATTACK,2,:SPECIAL_ATTACK,2]
@statDown = [:ATTACK, 2, :SPECIAL_ATTACK, 2]
end
# NOTE: The user faints even if the target's stats cannot be changed, so this
@@ -569,7 +569,7 @@ class Battle::Move::UserFaintsLowerTargetAtkSpAtk2 < Battle::Move::TargetMultiSt
def pbSelfKO(user)
return if user.fainted?
user.pbReduceHP(user.hp,false)
user.pbReduceHP(user.hp, false)
user.pbItemHPHealCheck
end
end
@@ -582,7 +582,7 @@ class Battle::Move::UserFaintsHealAndCureReplacement < Battle::Move
def healingMove?; return true; end
def canSnatch?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !@battle.pbCanChooseNonActive?(user.index)
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -592,7 +592,7 @@ class Battle::Move::UserFaintsHealAndCureReplacement < Battle::Move
def pbSelfKO(user)
return if user.fainted?
user.pbReduceHP(user.hp,false)
user.pbReduceHP(user.hp, false)
user.pbItemHPHealCheck
@battle.positions[user.index].effects[PBEffects::HealingWish] = true
end
@@ -606,7 +606,7 @@ class Battle::Move::UserFaintsHealAndCureReplacementRestorePP < Battle::Move
def healingMove?; return true; end
def canSnatch?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !@battle.pbCanChooseNonActive?(user.index)
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -616,7 +616,7 @@ class Battle::Move::UserFaintsHealAndCureReplacementRestorePP < Battle::Move
def pbSelfKO(user)
return if user.fainted?
user.pbReduceHP(user.hp,false)
user.pbReduceHP(user.hp, false)
user.pbItemHPHealCheck
@battle.positions[user.index].effects[PBEffects::LunarDance] = true
end
@@ -626,10 +626,10 @@ end
# All current battlers will perish after 3 more rounds. (Perish Song)
#===============================================================================
class Battle::Move::StartPerishCountsForAllBattlers < Battle::Move
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
failed = true
targets.each do |b|
next if b.effects[PBEffects::PerishSong]>0 # Heard it before
next if b.effects[PBEffects::PerishSong] > 0 # Heard it before
failed = false
break
end
@@ -641,15 +641,15 @@ class Battle::Move::StartPerishCountsForAllBattlers < Battle::Move
end
def pbFailsAgainstTarget?(user, target, show_message)
return target.effects[PBEffects::PerishSong]>0 # Heard it before
return target.effects[PBEffects::PerishSong] > 0 # Heard it before
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::PerishSong] = 4
target.effects[PBEffects::PerishSongUser] = user.index
end
def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true)
def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true)
super
@battle.pbDisplay(_INTL("All Pokémon that hear the song will faint in three turns!"))
end
@@ -660,7 +660,7 @@ end
# (Destiny Bond)
#===============================================================================
class Battle::Move::AttackerFaintsIfUserFaints < Battle::Move
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if Settings::MECHANICS_GENERATION >= 7 && user.effects[PBEffects::DestinyBondPrevious]
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -670,7 +670,7 @@ class Battle::Move::AttackerFaintsIfUserFaints < Battle::Move
def pbEffectGeneral(user)
user.effects[PBEffects::DestinyBond] = true
@battle.pbDisplay(_INTL("{1} is hoping to take its attacker down with it!",user.pbThis))
@battle.pbDisplay(_INTL("{1} is hoping to take its attacker down with it!", user.pbThis))
end
end
@@ -681,6 +681,6 @@ end
class Battle::Move::SetAttackerMovePPTo0IfUserFaints < Battle::Move
def pbEffectGeneral(user)
user.effects[PBEffects::Grudge] = true
@battle.pbDisplay(_INTL("{1} wants its target to bear a grudge!",user.pbThis))
@battle.pbDisplay(_INTL("{1} wants its target to bear a grudge!", user.pbThis))
end
end

View File

@@ -3,7 +3,7 @@
# Items stolen from wild Pokémon are kept after the battle.
#===============================================================================
class Battle::Move::UserTakesTargetItem < Battle::Move
def pbEffectAfterAllHits(user,target)
def pbEffectAfterAllHits(user, target)
return if user.wild? # Wild Pokémon can't thieve
return if user.fainted?
return if target.damageState.unaffected || target.damageState.substitute
@@ -20,7 +20,7 @@ class Battle::Move::UserTakesTargetItem < Battle::Move
else
target.pbRemoveItem(false)
end
@battle.pbDisplay(_INTL("{1} stole {2}'s {3}!",user.pbThis,target.pbThis(true),itemName))
@battle.pbDisplay(_INTL("{1} stole {2}'s {3}!", user.pbThis, target.pbThis(true), itemName))
user.pbHeldItemTriggerCheck
end
end
@@ -35,7 +35,7 @@ class Battle::Move::TargetTakesUserItem < Battle::Move
return super
end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !user.item || user.unlosableItem?(user.item)
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -51,7 +51,7 @@ class Battle::Move::TargetTakesUserItem < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
itemName = user.itemName
target.item = user.item
# Permanently steal the item from wild Pokémon
@@ -61,7 +61,7 @@ class Battle::Move::TargetTakesUserItem < Battle::Move
else
user.pbRemoveItem(false)
end
@battle.pbDisplay(_INTL("{1} received {2} from {3}!",target.pbThis,itemName,user.pbThis(true)))
@battle.pbDisplay(_INTL("{1} received {2} from {3}!", target.pbThis, itemName, user.pbThis(true)))
target.pbHeldItemTriggerCheck
end
end
@@ -71,7 +71,7 @@ end
# (Switcheroo, Trick)
#===============================================================================
class Battle::Move::UserTargetSwapItems < Battle::Move
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if user.wild?
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -107,7 +107,7 @@ class Battle::Move::UserTargetSwapItems < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
oldUserItem = user.item
oldUserItemName = user.itemName
oldTargetItem = target.item
@@ -122,9 +122,9 @@ class Battle::Move::UserTargetSwapItems < Battle::Move
if target.wild? && !user.initialItem && oldTargetItem == target.initialItem
user.setInitialItem(oldTargetItem)
end
@battle.pbDisplay(_INTL("{1} switched items with its opponent!",user.pbThis))
@battle.pbDisplay(_INTL("{1} obtained {2}.",user.pbThis,oldTargetItemName)) if oldTargetItem
@battle.pbDisplay(_INTL("{1} obtained {2}.",target.pbThis,oldUserItemName)) if oldUserItem
@battle.pbDisplay(_INTL("{1} switched items with its opponent!", user.pbThis))
@battle.pbDisplay(_INTL("{1} obtained {2}.", user.pbThis, oldTargetItemName)) if oldTargetItem
@battle.pbDisplay(_INTL("{1} obtained {2}.", target.pbThis, oldUserItemName)) if oldUserItem
user.pbHeldItemTriggerCheck
target.pbHeldItemTriggerCheck
end
@@ -136,7 +136,7 @@ end
class Battle::Move::RestoreUserConsumedItem < Battle::Move
def canSnatch?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !user.recycleItem
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -153,9 +153,9 @@ class Battle::Move::RestoreUserConsumedItem < Battle::Move
user.effects[PBEffects::PickupUse] = 0
itemName = GameData::Item.get(item).name
if itemName.starts_with_vowel?
@battle.pbDisplay(_INTL("{1} found an {2}!",user.pbThis,itemName))
@battle.pbDisplay(_INTL("{1} found an {2}!", user.pbThis, itemName))
else
@battle.pbDisplay(_INTL("{1} found a {2}!",user.pbThis,itemName))
@battle.pbDisplay(_INTL("{1} found a {2}!", user.pbThis, itemName))
end
user.pbHeldItemTriggerCheck
end
@@ -166,17 +166,17 @@ end
# If target has a losable item, damage is multiplied by 1.5.
#===============================================================================
class Battle::Move::RemoveTargetItem < Battle::Move
def pbBaseDamage(baseDmg,user,target)
def pbBaseDamage(baseDmg, user, target)
if Settings::MECHANICS_GENERATION >= 6 &&
target.item && !target.unlosableItem?(target.item)
# NOTE: Damage is still boosted even if target has Sticky Hold or a
# substitute.
baseDmg = (baseDmg*1.5).round
baseDmg = (baseDmg * 1.5).round
end
return baseDmg
end
def pbEffectAfterAllHits(user,target)
def pbEffectAfterAllHits(user, target)
return if user.wild? # Wild Pokémon can't knock off
return if user.fainted?
return if target.damageState.unaffected || target.damageState.substitute
@@ -184,7 +184,7 @@ class Battle::Move::RemoveTargetItem < Battle::Move
return if target.hasActiveAbility?(:STICKYHOLD) && !@battle.moldBreaker
itemName = target.itemName
target.pbRemoveItem(false)
@battle.pbDisplay(_INTL("{1} dropped its {2}!",target.pbThis,itemName))
@battle.pbDisplay(_INTL("{1} dropped its {2}!", target.pbThis, itemName))
end
end
@@ -192,12 +192,12 @@ end
# Target's berry/Gem is destroyed. (Incinerate)
#===============================================================================
class Battle::Move::DestroyTargetBerryOrGem < Battle::Move
def pbEffectWhenDealingDamage(user,target)
def pbEffectWhenDealingDamage(user, target)
return if target.damageState.substitute || target.damageState.berryWeakened
return if !target.item || (!target.item.is_berry? &&
!(Settings::MECHANICS_GENERATION >= 6 && target.item.is_gem?))
target.pbRemoveItem
@battle.pbDisplay(_INTL("{1}'s {2} was incinerated!",target.pbThis,target.itemName))
@battle.pbDisplay(_INTL("{1}'s {2} was incinerated!", target.pbThis, target.itemName))
end
end
@@ -251,16 +251,16 @@ class Battle::Move::StartTargetCannotUseItem < Battle::Move
def canMagicCoat?; return true; end
def pbFailsAgainstTarget?(user, target, show_message)
if target.effects[PBEffects::Embargo]>0
if target.effects[PBEffects::Embargo] > 0
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::Embargo] = 5
@battle.pbDisplay(_INTL("{1} can't use items anymore!",target.pbThis))
@battle.pbDisplay(_INTL("{1} can't use items anymore!", target.pbThis))
end
end
@@ -270,7 +270,7 @@ end
#===============================================================================
class Battle::Move::StartNegateHeldItems < Battle::Move
def pbEffectGeneral(user)
if @battle.field.effects[PBEffects::MagicRoom]>0
if @battle.field.effects[PBEffects::MagicRoom] > 0
@battle.field.effects[PBEffects::MagicRoom] = 0
@battle.pbDisplay(_INTL("The area returned to normal!"))
else
@@ -279,8 +279,8 @@ class Battle::Move::StartNegateHeldItems < Battle::Move
end
end
def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true)
return if @battle.field.effects[PBEffects::MagicRoom]>0 # No animation
def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true)
return if @battle.field.effects[PBEffects::MagicRoom] > 0 # No animation
super
end
end
@@ -374,7 +374,7 @@ end
# User consumes target's berry and gains its effect. (Bug Bite, Pluck)
#===============================================================================
class Battle::Move::UserConsumeTargetBerry < Battle::Move
def pbEffectAfterAllHits(user,target)
def pbEffectAfterAllHits(user, target)
return if user.fainted? || target.fainted?
return if target.damageState.unaffected || target.damageState.substitute
return if !target.item || !target.item.is_berry?
@@ -382,8 +382,8 @@ class Battle::Move::UserConsumeTargetBerry < Battle::Move
item = target.item
itemName = target.itemName
target.pbRemoveItem
@battle.pbDisplay(_INTL("{1} stole and ate its target's {2}!",user.pbThis,itemName))
user.pbHeldItemTriggerCheck(item,false)
@battle.pbDisplay(_INTL("{1} stole and ate its target's {2}!", user.pbThis, itemName))
user.pbHeldItemTriggerCheck(item, false)
end
end
@@ -391,114 +391,114 @@ end
# User flings its item at the target. Power/effect depend on the item. (Fling)
#===============================================================================
class Battle::Move::ThrowUserItemAtTarget < Battle::Move
def initialize(battle,move)
def initialize(battle, move)
super
# 80 => all Mega Stones
# 10 => all Berries
@flingPowers = {
130 => [:IRONBALL],
100 => [:HARDSTONE,:RAREBONE,
100 => [:HARDSTONE, :RAREBONE,
# Fossils
:ARMORFOSSIL,:CLAWFOSSIL,:COVERFOSSIL,:DOMEFOSSIL,:HELIXFOSSIL,
:JAWFOSSIL,:OLDAMBER,:PLUMEFOSSIL,:ROOTFOSSIL,:SAILFOSSIL,
:ARMORFOSSIL, :CLAWFOSSIL, :COVERFOSSIL, :DOMEFOSSIL, :HELIXFOSSIL,
:JAWFOSSIL, :OLDAMBER, :PLUMEFOSSIL, :ROOTFOSSIL, :SAILFOSSIL,
:SKULLFOSSIL],
90 => [:DEEPSEATOOTH,:GRIPCLAW,:THICKCLUB,
90 => [:DEEPSEATOOTH, :GRIPCLAW, :THICKCLUB,
# Plates
:DRACOPLATE,:DREADPLATE,:EARTHPLATE,:FISTPLATE,:FLAMEPLATE,
:ICICLEPLATE,:INSECTPLATE,:IRONPLATE,:MEADOWPLATE,:MINDPLATE,
:PIXIEPLATE,:SKYPLATE,:SPLASHPLATE,:SPOOKYPLATE,:STONEPLATE,
:TOXICPLATE,:ZAPPLATE],
80 => [:ASSAULTVEST,:CHIPPEDPOT,:CRACKEDPOT,:DAWNSTONE,:DUSKSTONE,
:ELECTIRIZER,:HEAVYDUTYBOOTS,:MAGMARIZER,:ODDKEYSTONE,:OVALSTONE,
:PROTECTOR,:QUICKCLAW,:RAZORCLAW,:SACHET,:SAFETYGOGGLES,
:SHINYSTONE,:STICKYBARB,:WEAKNESSPOLICY,:WHIPPEDDREAM],
70 => [:DRAGONFANG,:POISONBARB,
:DRACOPLATE, :DREADPLATE, :EARTHPLATE, :FISTPLATE, :FLAMEPLATE,
:ICICLEPLATE, :INSECTPLATE, :IRONPLATE, :MEADOWPLATE, :MINDPLATE,
:PIXIEPLATE, :SKYPLATE, :SPLASHPLATE, :SPOOKYPLATE, :STONEPLATE,
:TOXICPLATE, :ZAPPLATE],
80 => [:ASSAULTVEST, :CHIPPEDPOT, :CRACKEDPOT, :DAWNSTONE, :DUSKSTONE,
:ELECTIRIZER, :HEAVYDUTYBOOTS, :MAGMARIZER, :ODDKEYSTONE, :OVALSTONE,
:PROTECTOR, :QUICKCLAW, :RAZORCLAW, :SACHET, :SAFETYGOGGLES,
:SHINYSTONE, :STICKYBARB, :WEAKNESSPOLICY, :WHIPPEDDREAM],
70 => [:DRAGONFANG, :POISONBARB,
# EV-training items (Macho Brace is 60)
:POWERANKLET,:POWERBAND,:POWERBELT,:POWERBRACER,:POWERLENS,
:POWERANKLET, :POWERBAND, :POWERBELT, :POWERBRACER, :POWERLENS,
:POWERWEIGHT,
# Drives
:BURNDRIVE,:CHILLDRIVE,:DOUSEDRIVE,:SHOCKDRIVE],
60 => [:ADAMANTORB,:DAMPROCK,:GRISEOUSORB,:HEATROCK,:LEEK,:LUSTROUSORB,
:MACHOBRACE,:ROCKYHELMET,:STICK,:TERRAINEXTENDER],
50 => [:DUBIOUSDISC,:SHARPBEAK,
:BURNDRIVE, :CHILLDRIVE, :DOUSEDRIVE, :SHOCKDRIVE],
60 => [:ADAMANTORB, :DAMPROCK, :GRISEOUSORB, :HEATROCK, :LEEK, :LUSTROUSORB,
:MACHOBRACE, :ROCKYHELMET, :STICK, :TERRAINEXTENDER],
50 => [:DUBIOUSDISC, :SHARPBEAK,
# Memories
:BUGMEMORY,:DARKMEMORY,:DRAGONMEMORY,:ELECTRICMEMORY,:FAIRYMEMORY,
:FIGHTINGMEMORY,:FIREMEMORY,:FLYINGMEMORY,:GHOSTMEMORY,
:GRASSMEMORY,:GROUNDMEMORY,:ICEMEMORY,:POISONMEMORY,
:PSYCHICMEMORY,:ROCKMEMORY,:STEELMEMORY,:WATERMEMORY],
40 => [:EVIOLITE,:ICYROCK,:LUCKYPUNCH],
30 => [:ABSORBBULB,:ADRENALINEORB,:AMULETCOIN,:BINDINGBAND,:BLACKBELT,
:BLACKGLASSES,:BLACKSLUDGE,:BOTTLECAP,:CELLBATTERY,:CHARCOAL,
:CLEANSETAG,:DEEPSEASCALE,:DRAGONSCALE,:EJECTBUTTON,:ESCAPEROPE,
:EXPSHARE,:FLAMEORB,:FLOATSTONE,:FLUFFYTAIL,:GOLDBOTTLECAP,
:HEARTSCALE,:HONEY,:KINGSROCK,:LIFEORB,:LIGHTBALL,:LIGHTCLAY,
:LUCKYEGG,:LUMINOUSMOSS,:MAGNET,:METALCOAT,:METRONOME,
:MIRACLESEED,:MYSTICWATER,:NEVERMELTICE,:PASSORB,:POKEDOLL,
:POKETOY,:PRISMSCALE,:PROTECTIVEPADS,:RAZORFANG,:SACREDASH,
:SCOPELENS,:SHELLBELL,:SHOALSALT,:SHOALSHELL,:SMOKEBALL,:SNOWBALL,
:SOULDEW,:SPELLTAG,:TOXICORB,:TWISTEDSPOON,:UPGRADE,
:BUGMEMORY, :DARKMEMORY, :DRAGONMEMORY, :ELECTRICMEMORY, :FAIRYMEMORY,
:FIGHTINGMEMORY, :FIREMEMORY, :FLYINGMEMORY, :GHOSTMEMORY,
:GRASSMEMORY, :GROUNDMEMORY, :ICEMEMORY, :POISONMEMORY,
:PSYCHICMEMORY, :ROCKMEMORY, :STEELMEMORY, :WATERMEMORY],
40 => [:EVIOLITE, :ICYROCK, :LUCKYPUNCH],
30 => [:ABSORBBULB, :ADRENALINEORB, :AMULETCOIN, :BINDINGBAND, :BLACKBELT,
:BLACKGLASSES, :BLACKSLUDGE, :BOTTLECAP, :CELLBATTERY, :CHARCOAL,
:CLEANSETAG, :DEEPSEASCALE, :DRAGONSCALE, :EJECTBUTTON, :ESCAPEROPE,
:EXPSHARE, :FLAMEORB, :FLOATSTONE, :FLUFFYTAIL, :GOLDBOTTLECAP,
:HEARTSCALE, :HONEY, :KINGSROCK, :LIFEORB, :LIGHTBALL, :LIGHTCLAY,
:LUCKYEGG, :LUMINOUSMOSS, :MAGNET, :METALCOAT, :METRONOME,
:MIRACLESEED, :MYSTICWATER, :NEVERMELTICE, :PASSORB, :POKEDOLL,
:POKETOY, :PRISMSCALE, :PROTECTIVEPADS, :RAZORFANG, :SACREDASH,
:SCOPELENS, :SHELLBELL, :SHOALSALT, :SHOALSHELL, :SMOKEBALL, :SNOWBALL,
:SOULDEW, :SPELLTAG, :TOXICORB, :TWISTEDSPOON, :UPGRADE,
# Healing items
:ANTIDOTE,:AWAKENING,:BERRYJUICE,:BIGMALASADA,:BLUEFLUTE,
:BURNHEAL,:CASTELIACONE,:ELIXIR,:ENERGYPOWDER,:ENERGYROOT,:ETHER,
:FRESHWATER,:FULLHEAL,:FULLRESTORE,:HEALPOWDER,:HYPERPOTION,
:ICEHEAL,:LAVACOOKIE,:LEMONADE,:LUMIOSEGALETTE,:MAXELIXIR,
:MAXETHER,:MAXHONEY,:MAXPOTION,:MAXREVIVE,:MOOMOOMILK,:OLDGATEAU,
:PARALYZEHEAL,:PARLYZHEAL,:PEWTERCRUNCHIES,:POTION,:RAGECANDYBAR,
:REDFLUTE,:REVIVALHERB,:REVIVE,:SHALOURSABLE,:SODAPOP,
:SUPERPOTION,:SWEETHEART,:YELLOWFLUTE,
:ANTIDOTE, :AWAKENING, :BERRYJUICE, :BIGMALASADA, :BLUEFLUTE,
:BURNHEAL, :CASTELIACONE, :ELIXIR, :ENERGYPOWDER, :ENERGYROOT, :ETHER,
:FRESHWATER, :FULLHEAL, :FULLRESTORE, :HEALPOWDER, :HYPERPOTION,
:ICEHEAL, :LAVACOOKIE, :LEMONADE, :LUMIOSEGALETTE, :MAXELIXIR,
:MAXETHER, :MAXHONEY, :MAXPOTION, :MAXREVIVE, :MOOMOOMILK, :OLDGATEAU,
:PARALYZEHEAL, :PARLYZHEAL, :PEWTERCRUNCHIES, :POTION, :RAGECANDYBAR,
:REDFLUTE, :REVIVALHERB, :REVIVE, :SHALOURSABLE, :SODAPOP,
:SUPERPOTION, :SWEETHEART, :YELLOWFLUTE,
# Battle items
:XACCURACY,:XACCURACY2,:XACCURACY3,:XACCURACY6,
:XATTACK,:XATTACK2,:XATTACK3,:XATTACK6,
:XDEFEND,:XDEFEND2,:XDEFEND3,:XDEFEND6,
:XDEFENSE,:XDEFENSE2,:XDEFENSE3,:XDEFENSE6,
:XSPATK,:XSPATK2,:XSPATK3,:XSPATK6,
:XSPECIAL,:XSPECIAL2,:XSPECIAL3,:XSPECIAL6,
:XSPDEF,:XSPDEF2,:XSPDEF3,:XSPDEF6,
:XSPEED,:XSPEED2,:XSPEED3,:XSPEED6,
:DIREHIT,:DIREHIT2,:DIREHIT3,
:ABILITYURGE,:GUARDSPEC,:ITEMDROP,:ITEMURGE,:RESETURGE,
:XACCURACY, :XACCURACY2, :XACCURACY3, :XACCURACY6,
:XATTACK, :XATTACK2, :XATTACK3, :XATTACK6,
:XDEFEND, :XDEFEND2, :XDEFEND3, :XDEFEND6,
:XDEFENSE, :XDEFENSE2, :XDEFENSE3, :XDEFENSE6,
:XSPATK, :XSPATK2, :XSPATK3, :XSPATK6,
:XSPECIAL, :XSPECIAL2, :XSPECIAL3, :XSPECIAL6,
:XSPDEF, :XSPDEF2, :XSPDEF3, :XSPDEF6,
:XSPEED, :XSPEED2, :XSPEED3, :XSPEED6,
:DIREHIT, :DIREHIT2, :DIREHIT3,
:ABILITYURGE, :GUARDSPEC, :ITEMDROP, :ITEMURGE, :RESETURGE,
:MAXMUSHROOMS,
# Vitamins
:CALCIUM,:CARBOS,:HPUP,:IRON,:PPUP,:PPMAX,:PROTEIN,:ZINC,
:CALCIUM, :CARBOS, :HPUP, :IRON, :PPUP, :PPMAX, :PROTEIN, :ZINC,
:RARECANDY,
# Most evolution stones (see also 80)
:EVERSTONE,:FIRESTONE,:ICESTONE,:LEAFSTONE,:MOONSTONE,:SUNSTONE,
:THUNDERSTONE,:WATERSTONE,:SWEETAPPLE,:TARTAPPLE, :GALARICACUFF,
:EVERSTONE, :FIRESTONE, :ICESTONE, :LEAFSTONE, :MOONSTONE, :SUNSTONE,
:THUNDERSTONE, :WATERSTONE, :SWEETAPPLE, :TARTAPPLE, :GALARICACUFF,
:GALARICAWREATH,
# Repels
:MAXREPEL,:REPEL,:SUPERREPEL,
:MAXREPEL, :REPEL, :SUPERREPEL,
# Mulches
:AMAZEMULCH,:BOOSTMULCH,:DAMPMULCH,:GOOEYMULCH,:GROWTHMULCH,
:RICHMULCH,:STABLEMULCH,:SURPRISEMULCH,
:AMAZEMULCH, :BOOSTMULCH, :DAMPMULCH, :GOOEYMULCH, :GROWTHMULCH,
:RICHMULCH, :STABLEMULCH, :SURPRISEMULCH,
# Shards
:BLUESHARD,:GREENSHARD,:REDSHARD,:YELLOWSHARD,
:BLUESHARD, :GREENSHARD, :REDSHARD, :YELLOWSHARD,
# Valuables
:BALMMUSHROOM,:BIGMUSHROOM,:BIGNUGGET,:BIGPEARL,:COMETSHARD,
:NUGGET,:PEARL,:PEARLSTRING,:RELICBAND,:RELICCOPPER,:RELICCROWN,
:RELICGOLD,:RELICSILVER,:RELICSTATUE,:RELICVASE,:STARDUST,
:STARPIECE,:STRANGESOUVENIR,:TINYMUSHROOM,
:BALMMUSHROOM, :BIGMUSHROOM, :BIGNUGGET, :BIGPEARL, :COMETSHARD,
:NUGGET, :PEARL, :PEARLSTRING, :RELICBAND, :RELICCOPPER, :RELICCROWN,
:RELICGOLD, :RELICSILVER, :RELICSTATUE, :RELICVASE, :STARDUST,
:STARPIECE, :STRANGESOUVENIR, :TINYMUSHROOM,
# Exp Candies
:EXPCANDYXS, :EXPCANDYS, :EXPCANDYM, :EXPCANDYL, :EXPCANDYXL],
20 => [ # Feathers
:CLEVERFEATHER,:GENIUSFEATHER,:HEALTHFEATHER,:MUSCLEFEATHER,
:PRETTYFEATHER,:RESISTFEATHER,:SWIFTFEATHER,
:CLEVERWING,:GENIUSWING,:HEALTHWING,:MUSCLEWING,:PRETTYWING,
:RESISTWING,:SWIFTWING],
10 => [:AIRBALLOON,:BIGROOT,:BRIGHTPOWDER,:CHOICEBAND,:CHOICESCARF,
:CHOICESPECS,:DESTINYKNOT,:DISCOUNTCOUPON,:EXPERTBELT,:FOCUSBAND,
:FOCUSSASH,:LAGGINGTAIL,:LEFTOVERS,:MENTALHERB,:METALPOWDER,
:MUSCLEBAND,:POWERHERB,:QUICKPOWDER,:REAPERCLOTH,:REDCARD,
:RINGTARGET,:SHEDSHELL,:SILKSCARF,:SILVERPOWDER,:SMOOTHROCK,
:SOFTSAND,:SOOTHEBELL,:WHITEHERB,:WIDELENS,:WISEGLASSES,:ZOOMLENS,
:CLEVERFEATHER, :GENIUSFEATHER, :HEALTHFEATHER, :MUSCLEFEATHER,
:PRETTYFEATHER, :RESISTFEATHER, :SWIFTFEATHER,
:CLEVERWING, :GENIUSWING, :HEALTHWING, :MUSCLEWING, :PRETTYWING,
:RESISTWING, :SWIFTWING],
10 => [:AIRBALLOON, :BIGROOT, :BRIGHTPOWDER, :CHOICEBAND, :CHOICESCARF,
:CHOICESPECS, :DESTINYKNOT, :DISCOUNTCOUPON, :EXPERTBELT, :FOCUSBAND,
:FOCUSSASH, :LAGGINGTAIL, :LEFTOVERS, :MENTALHERB, :METALPOWDER,
:MUSCLEBAND, :POWERHERB, :QUICKPOWDER, :REAPERCLOTH, :REDCARD,
:RINGTARGET, :SHEDSHELL, :SILKSCARF, :SILVERPOWDER, :SMOOTHROCK,
:SOFTSAND, :SOOTHEBELL, :WHITEHERB, :WIDELENS, :WISEGLASSES, :ZOOMLENS,
# Terrain seeds
:ELECTRICSEED,:GRASSYSEED,:MISTYSEED,:PSYCHICSEED,
:ELECTRICSEED, :GRASSYSEED, :MISTYSEED, :PSYCHICSEED,
# Nectar
:PINKNECTAR,:PURPLENECTAR,:REDNECTAR,:YELLOWNECTAR,
:PINKNECTAR, :PURPLENECTAR, :REDNECTAR, :YELLOWNECTAR,
# Incenses
:FULLINCENSE,:LAXINCENSE,:LUCKINCENSE,:ODDINCENSE,:PUREINCENSE,
:ROCKINCENSE,:ROSEINCENSE,:SEAINCENSE,:WAVEINCENSE,
:FULLINCENSE, :LAXINCENSE, :LUCKINCENSE, :ODDINCENSE, :PUREINCENSE,
:ROCKINCENSE, :ROSEINCENSE, :SEAINCENSE, :WAVEINCENSE,
# Scarves
:BLUESCARF,:GREENSCARF,:PINKSCARF,:REDSCARF,:YELLOWSCARF,
:BLUESCARF, :GREENSCARF, :PINKSCARF, :REDSCARF, :YELLOWSCARF,
# Mints
:LONELYMINT, :ADAMANTMINT, :NAUGHTYMINT, :BRAVEMINT, :BOLDMINT,
:IMPISHMINT, :LAXMINT, :RELAXEDMINT, :MODESTMINT, :MILDMINT,
@@ -527,7 +527,7 @@ class Battle::Move::ThrowUserItemAtTarget < Battle::Move
@willFail = true if !flingableItem
end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if @willFail
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -539,13 +539,13 @@ class Battle::Move::ThrowUserItemAtTarget < Battle::Move
super
pbCheckFlingSuccess(user)
if !@willFail
@battle.pbDisplay(_INTL("{1} flung its {2}!",user.pbThis,user.itemName))
@battle.pbDisplay(_INTL("{1} flung its {2}!", user.pbThis, user.itemName))
end
end
def pbNumHits(user,targets); return 1; end
def pbNumHits(user, targets); return 1; end
def pbBaseDamage(baseDmg,user,target)
def pbBaseDamage(baseDmg, user, target)
return 0 if !user.item
return 10 if user.item.is_berry?
return 80 if user.item.is_mega_stone?
@@ -554,36 +554,36 @@ class Battle::Move::ThrowUserItemAtTarget < Battle::Move
ret = 10 if ret < 10
return ret
end
@flingPowers.each do |power,items|
@flingPowers.each do |power, items|
return power if items.include?(user.item_id)
end
return 10
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
return if target.damageState.substitute
return if target.hasActiveAbility?(:SHIELDDUST) && !@battle.moldBreaker
case user.item_id
when :POISONBARB
target.pbPoison(user) if target.pbCanPoison?(user,false,self)
target.pbPoison(user) if target.pbCanPoison?(user, false, self)
when :TOXICORB
target.pbPoison(user,nil,true) if target.pbCanPoison?(user,false,self)
target.pbPoison(user, nil, true) if target.pbCanPoison?(user, false, self)
when :FLAMEORB
target.pbBurn(user) if target.pbCanBurn?(user,false,self)
target.pbBurn(user) if target.pbCanBurn?(user, false, self)
when :LIGHTBALL
target.pbParalyze(user) if target.pbCanParalyze?(user,false,self)
target.pbParalyze(user) if target.pbCanParalyze?(user, false, self)
when :KINGSROCK, :RAZORFANG
target.pbFlinch(user)
else
target.pbHeldItemTriggerCheck(user.item,true)
target.pbHeldItemTriggerCheck(user.item, true)
end
end
def pbEndOfMoveUsageEffect(user,targets,numHits,switchedBattlers)
def pbEndOfMoveUsageEffect(user, targets, numHits, switchedBattlers)
# NOTE: The item is consumed even if this move was Protected against or it
# missed. The item is not consumed if the target was switched out by
# an effect like a target's Red Card.
# NOTE: There is no item consumption animation.
user.pbConsumeItem(true,true,false) if user.item
user.pbConsumeItem(true, true, false) if user.item
end
end

View File

@@ -6,11 +6,11 @@ class Battle::Move::RedirectAllMovesToUser < Battle::Move
def pbEffectGeneral(user)
user.effects[PBEffects::FollowMe] = 1
user.allAllies.each do |b|
next if b.effects[PBEffects::FollowMe]<user.effects[PBEffects::FollowMe]
user.effects[PBEffects::FollowMe] = b.effects[PBEffects::FollowMe]+1
next if b.effects[PBEffects::FollowMe] < user.effects[PBEffects::FollowMe]
user.effects[PBEffects::FollowMe] = b.effects[PBEffects::FollowMe] + 1
end
user.effects[PBEffects::RagePowder] = true if powderMove?
@battle.pbDisplay(_INTL("{1} became the center of attention!",user.pbThis))
@battle.pbDisplay(_INTL("{1} became the center of attention!", user.pbThis))
end
end
@@ -21,13 +21,13 @@ end
class Battle::Move::RedirectAllMovesToTarget < Battle::Move
def canMagicCoat?; return true; end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::Spotlight] = 1
target.allAllies.each do |b|
next if b.effects[PBEffects::Spotlight]<target.effects[PBEffects::Spotlight]
target.effects[PBEffects::Spotlight] = b.effects[PBEffects::Spotlight]+1
next if b.effects[PBEffects::Spotlight] < target.effects[PBEffects::Spotlight]
target.effects[PBEffects::Spotlight] = b.effects[PBEffects::Spotlight] + 1
end
@battle.pbDisplay(_INTL("{1} became the center of attention!",target.pbThis))
@battle.pbDisplay(_INTL("{1} became the center of attention!", target.pbThis))
end
end
@@ -44,20 +44,20 @@ end
# but I think that's silly so I've omitted that effect.
#===============================================================================
class Battle::Move::RandomlyDamageOrHealTarget < Battle::Move
def pbOnStartUse(user,targets)
def pbOnStartUse(user, targets)
@presentDmg = 0 # 0 = heal, >0 = damage
r = @battle.pbRandom(100)
if r<40
if r < 40
@presentDmg = 40
elsif r<70
elsif r < 70
@presentDmg = 80
elsif r<80
elsif r < 80
@presentDmg = 120
end
end
def pbFailsAgainstTarget?(user, target, show_message)
return false if @presentDmg>0
return false if @presentDmg > 0
if !target.canHeal?
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
@@ -66,22 +66,22 @@ class Battle::Move::RandomlyDamageOrHealTarget < Battle::Move
end
def pbDamagingMove?
return false if @presentDmg==0
return false if @presentDmg == 0
return super
end
def pbBaseDamage(baseDmg,user,target)
def pbBaseDamage(baseDmg, user, target)
return @presentDmg
end
def pbEffectAgainstTarget(user,target)
return if @presentDmg>0
target.pbRecoverHP(target.totalhp/4)
@battle.pbDisplay(_INTL("{1}'s HP was restored.",target.pbThis))
def pbEffectAgainstTarget(user, target)
return if @presentDmg > 0
target.pbRecoverHP(target.totalhp / 4)
@battle.pbDisplay(_INTL("{1}'s HP was restored.", target.pbThis))
end
def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true)
hitNum = 1 if @presentDmg==0 # Healing anim
def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true)
hitNum = 1 if @presentDmg == 0 # Healing anim
super
end
end
@@ -92,18 +92,18 @@ end
#===============================================================================
class Battle::Move::HealAllyOrDamageFoe < Battle::Move
def pbTarget(user)
return GameData::Target.get(:NearFoe) if user.effects[PBEffects::HealBlock]>0
return GameData::Target.get(:NearFoe) if user.effects[PBEffects::HealBlock] > 0
return super
end
def pbOnStartUse(user,targets)
def pbOnStartUse(user, targets)
@healing = false
@healing = !user.opposes?(targets[0]) if targets.length>0
@healing = !user.opposes?(targets[0]) if targets.length > 0
end
def pbFailsAgainstTarget?(user, target, show_message)
return false if !@healing
if target.effects[PBEffects::Substitute]>0 && !ignoresSubstitute?(user)
if target.effects[PBEffects::Substitute] > 0 && !ignoresSubstitute?(user)
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
@@ -119,13 +119,13 @@ class Battle::Move::HealAllyOrDamageFoe < Battle::Move
return super
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
return if !@healing
target.pbRecoverHP(target.totalhp/2)
@battle.pbDisplay(_INTL("{1}'s HP was restored.",target.pbThis))
target.pbRecoverHP(target.totalhp / 2)
@battle.pbDisplay(_INTL("{1}'s HP was restored.", target.pbThis))
end
def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true)
def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true)
hitNum = 1 if @healing # Healing anim
super
end
@@ -148,11 +148,11 @@ class Battle::Move::CurseTargetOrLowerUserSpd1RaiseUserAtkDef1 < Battle::Move
return super
end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
return false if user.pbHasType?(:GHOST)
if !user.pbCanLowerStatStage?(:SPEED,user,self) &&
!user.pbCanRaiseStatStage?(:ATTACK,user,self) &&
!user.pbCanRaiseStatStage?(:DEFENSE,user,self)
if !user.pbCanLowerStatStage?(:SPEED, user, self) &&
!user.pbCanRaiseStatStage?(:ATTACK, user, self) &&
!user.pbCanRaiseStatStage?(:DEFENSE, user, self)
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -170,30 +170,30 @@ class Battle::Move::CurseTargetOrLowerUserSpd1RaiseUserAtkDef1 < Battle::Move
def pbEffectGeneral(user)
return if user.pbHasType?(:GHOST)
# Non-Ghost effect
if user.pbCanLowerStatStage?(:SPEED,user,self)
user.pbLowerStatStage(:SPEED,1,user)
if user.pbCanLowerStatStage?(:SPEED, user, self)
user.pbLowerStatStage(:SPEED, 1, user)
end
showAnim = true
if user.pbCanRaiseStatStage?(:ATTACK,user,self)
if user.pbRaiseStatStage(:ATTACK,1,user,showAnim)
if user.pbCanRaiseStatStage?(:ATTACK, user, self)
if user.pbRaiseStatStage(:ATTACK, 1, user, showAnim)
showAnim = false
end
end
if user.pbCanRaiseStatStage?(:DEFENSE,user,self)
user.pbRaiseStatStage(:DEFENSE,1,user,showAnim)
if user.pbCanRaiseStatStage?(:DEFENSE, user, self)
user.pbRaiseStatStage(:DEFENSE, 1, user, showAnim)
end
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
return if !user.pbHasType?(:GHOST)
# Ghost effect
@battle.pbDisplay(_INTL("{1} cut its own HP and laid a curse on {2}!",user.pbThis,target.pbThis(true)))
@battle.pbDisplay(_INTL("{1} cut its own HP and laid a curse on {2}!", user.pbThis, target.pbThis(true)))
target.effects[PBEffects::Curse] = true
user.pbReduceHP(user.totalhp/2, false, false)
user.pbReduceHP(user.totalhp / 2, false, false)
user.pbItemHPHealCheck
end
def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true)
def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true)
hitNum = 1 if !user.pbHasType?(:GHOST) # Non-Ghost anim
super
end
@@ -203,9 +203,9 @@ end
# Effect depends on the environment. (Secret Power)
#===============================================================================
class Battle::Move::EffectDependsOnEnvironment < Battle::Move
def flinchingMove?; return [6,10,12].include?(@secretPower); end
def flinchingMove?; return [6, 10, 12].include?(@secretPower); end
def pbOnStartUse(user,targets)
def pbOnStartUse(user, targets)
# NOTE: This is Gen 7's list plus some of Gen 6 plus a bit of my own.
@secretPower = 0 # Body Slam, paralysis
case @battle.field.terrain
@@ -249,46 +249,46 @@ class Battle::Move::EffectDependsOnEnvironment < Battle::Move
# method is called per hit and this move's additional effect only occurs
# once per use, after all the hits have happened (two hits are possible
# via Parental Bond).
def pbEffectAfterAllHits(user,target)
def pbEffectAfterAllHits(user, target)
return if target.fainted?
return if target.damageState.unaffected || target.damageState.substitute
chance = pbAdditionalEffectChance(user,target)
return if @battle.pbRandom(100)>=chance
chance = pbAdditionalEffectChance(user, target)
return if @battle.pbRandom(100) >= chance
case @secretPower
when 2
target.pbSleep if target.pbCanSleep?(user,false,self)
target.pbSleep if target.pbCanSleep?(user, false, self)
when 10
target.pbBurn(user) if target.pbCanBurn?(user,false,self)
target.pbBurn(user) if target.pbCanBurn?(user, false, self)
when 0, 1
target.pbParalyze(user) if target.pbCanParalyze?(user,false,self)
target.pbParalyze(user) if target.pbCanParalyze?(user, false, self)
when 9
target.pbFreeze if target.pbCanFreeze?(user,false,self)
target.pbFreeze if target.pbCanFreeze?(user, false, self)
when 5
if target.pbCanLowerStatStage?(:ATTACK,user,self)
target.pbLowerStatStage(:ATTACK,1,user)
if target.pbCanLowerStatStage?(:ATTACK, user, self)
target.pbLowerStatStage(:ATTACK, 1, user)
end
when 14
if target.pbCanLowerStatStage?(:DEFENSE,user,self)
target.pbLowerStatStage(:DEFENSE,1,user)
if target.pbCanLowerStatStage?(:DEFENSE, user, self)
target.pbLowerStatStage(:DEFENSE, 1, user)
end
when 3
if target.pbCanLowerStatStage?(:SPECIAL_ATTACK,user,self)
target.pbLowerStatStage(:SPECIAL_ATTACK,1,user)
if target.pbCanLowerStatStage?(:SPECIAL_ATTACK, user, self)
target.pbLowerStatStage(:SPECIAL_ATTACK, 1, user)
end
when 4, 6, 12
if target.pbCanLowerStatStage?(:SPEED,user,self)
target.pbLowerStatStage(:SPEED,1,user)
if target.pbCanLowerStatStage?(:SPEED, user, self)
target.pbLowerStatStage(:SPEED, 1, user)
end
when 8
if target.pbCanLowerStatStage?(:ACCURACY,user,self)
target.pbLowerStatStage(:ACCURACY,1,user)
if target.pbCanLowerStatStage?(:ACCURACY, user, self)
target.pbLowerStatStage(:ACCURACY, 1, user)
end
when 7, 11, 13
target.pbFlinch(user)
end
end
def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true)
def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true)
id = :BODYSLAM # Environment-specific anim
case @secretPower
when 1 then id = :THUNDERSHOCK if GameData::Move.exists?(:THUNDERSHOCK)
@@ -347,9 +347,9 @@ class Battle::Move::TargetNextFireMoveDamagesTarget < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::Powder] = true
@battle.pbDisplay(_INTL("{1} is covered in powder!",user.pbThis))
@battle.pbDisplay(_INTL("{1} is covered in powder!", user.pbThis))
end
end
@@ -357,12 +357,12 @@ end
# Power is doubled if Fusion Flare has already been used this round. (Fusion Bolt)
#===============================================================================
class Battle::Move::DoublePowerAfterFusionFlare < Battle::Move
def pbChangeUsageCounters(user,specialUsage)
def pbChangeUsageCounters(user, specialUsage)
@doublePower = @battle.field.effects[PBEffects::FusionFlare]
super
end
def pbBaseDamageMultiplier(damageMult,user,target)
def pbBaseDamageMultiplier(damageMult, user, target)
damageMult *= 2 if @doublePower
return damageMult
end
@@ -371,8 +371,8 @@ class Battle::Move::DoublePowerAfterFusionFlare < Battle::Move
@battle.field.effects[PBEffects::FusionBolt] = true
end
def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true)
hitNum = 1 if (targets.length>0 && targets[0].damageState.critical) ||
def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true)
hitNum = 1 if (targets.length > 0 && targets[0].damageState.critical) ||
@doublePower # Charged anim
super
end
@@ -382,12 +382,12 @@ end
# Power is doubled if Fusion Bolt has already been used this round. (Fusion Flare)
#===============================================================================
class Battle::Move::DoublePowerAfterFusionBolt < Battle::Move
def pbChangeUsageCounters(user,specialUsage)
def pbChangeUsageCounters(user, specialUsage)
@doublePower = @battle.field.effects[PBEffects::FusionBolt]
super
end
def pbBaseDamageMultiplier(damageMult,user,target)
def pbBaseDamageMultiplier(damageMult, user, target)
damageMult *= 2 if @doublePower
return damageMult
end
@@ -396,8 +396,8 @@ class Battle::Move::DoublePowerAfterFusionBolt < Battle::Move
@battle.field.effects[PBEffects::FusionFlare] = true
end
def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true)
hitNum = 1 if (targets.length>0 && targets[0].damageState.critical) ||
def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true)
hitNum = 1 if (targets.length > 0 && targets[0].damageState.critical) ||
@doublePower # Charged anim
super
end
@@ -418,9 +418,9 @@ class Battle::Move::PowerUpAllyMove < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::HelpingHand] = true
@battle.pbDisplay(_INTL("{1} is ready to help {2}!",user.pbThis,target.pbThis(true)))
@battle.pbDisplay(_INTL("{1} is ready to help {2}!", user.pbThis, target.pbThis(true)))
end
end
@@ -429,23 +429,23 @@ end
# (Counter)
#===============================================================================
class Battle::Move::CounterPhysicalDamage < Battle::Move::FixedDamageMove
def pbAddTarget(targets,user)
def pbAddTarget(targets, user)
t = user.effects[PBEffects::CounterTarget]
return if t<0 || !user.opposes?(t)
user.pbAddTarget(targets,user,@battle.battlers[t],self,false)
return if t < 0 || !user.opposes?(t)
user.pbAddTarget(targets, user, @battle.battlers[t], self, false)
end
def pbMoveFailed?(user,targets)
if targets.length==0
def pbMoveFailed?(user, targets)
if targets.length == 0
@battle.pbDisplay(_INTL("But there was no target..."))
return true
end
return false
end
def pbFixedDamage(user,target)
dmg = user.effects[PBEffects::Counter]*2
dmg = 1 if dmg==0
def pbFixedDamage(user, target)
dmg = user.effects[PBEffects::Counter] * 2
dmg = 1 if dmg == 0
return dmg
end
end
@@ -455,23 +455,23 @@ end
# (Mirror Coat)
#===============================================================================
class Battle::Move::CounterSpecialDamage < Battle::Move::FixedDamageMove
def pbAddTarget(targets,user)
def pbAddTarget(targets, user)
t = user.effects[PBEffects::MirrorCoatTarget]
return if t<0 || !user.opposes?(t)
user.pbAddTarget(targets,user,@battle.battlers[t],self,false)
return if t < 0 || !user.opposes?(t)
user.pbAddTarget(targets, user, @battle.battlers[t], self, false)
end
def pbMoveFailed?(user,targets)
if targets.length==0
def pbMoveFailed?(user, targets)
if targets.length == 0
@battle.pbDisplay(_INTL("But there was no target..."))
return true
end
return false
end
def pbFixedDamage(user,target)
dmg = user.effects[PBEffects::MirrorCoat]*2
dmg = 1 if dmg==0
def pbFixedDamage(user, target)
dmg = user.effects[PBEffects::MirrorCoat] * 2
dmg = 1 if dmg == 0
return dmg
end
end
@@ -481,24 +481,24 @@ end
# the power. (Metal Burst)
#===============================================================================
class Battle::Move::CounterDamagePlusHalf < Battle::Move::FixedDamageMove
def pbAddTarget(targets,user)
return if user.lastFoeAttacker.length==0
def pbAddTarget(targets, user)
return if user.lastFoeAttacker.length == 0
lastAttacker = user.lastFoeAttacker.last
return if lastAttacker<0 || !user.opposes?(lastAttacker)
user.pbAddTarget(targets,user,@battle.battlers[lastAttacker],self,false)
return if lastAttacker < 0 || !user.opposes?(lastAttacker)
user.pbAddTarget(targets, user, @battle.battlers[lastAttacker], self, false)
end
def pbMoveFailed?(user,targets)
if targets.length==0
def pbMoveFailed?(user, targets)
if targets.length == 0
@battle.pbDisplay(_INTL("But there was no target..."))
return true
end
return false
end
def pbFixedDamage(user,target)
dmg = (user.lastHPLostFromFoe*1.5).floor
dmg = 1 if dmg==0
def pbFixedDamage(user, target)
dmg = (user.lastHPLostFromFoe * 1.5).floor
dmg = 1 if dmg == 0
return dmg
end
end
@@ -510,9 +510,9 @@ end
class Battle::Move::UserAddStockpileRaiseDefSpDef1 < Battle::Move
def canSnatch?; return true; end
def pbMoveFailed?(user,targets)
if user.effects[PBEffects::Stockpile]>=3
@battle.pbDisplay(_INTL("{1} can't stockpile any more!",user.pbThis))
def pbMoveFailed?(user, targets)
if user.effects[PBEffects::Stockpile] >= 3
@battle.pbDisplay(_INTL("{1} can't stockpile any more!", user.pbThis))
return true
end
return false
@@ -521,16 +521,16 @@ class Battle::Move::UserAddStockpileRaiseDefSpDef1 < Battle::Move
def pbEffectGeneral(user)
user.effects[PBEffects::Stockpile] += 1
@battle.pbDisplay(_INTL("{1} stockpiled {2}!",
user.pbThis,user.effects[PBEffects::Stockpile]))
user.pbThis, user.effects[PBEffects::Stockpile]))
showAnim = true
if user.pbCanRaiseStatStage?(:DEFENSE,user,self)
if user.pbRaiseStatStage(:DEFENSE,1,user,showAnim)
if user.pbCanRaiseStatStage?(:DEFENSE, user, self)
if user.pbRaiseStatStage(:DEFENSE, 1, user, showAnim)
user.effects[PBEffects::StockpileDef] += 1
showAnim = false
end
end
if user.pbCanRaiseStatStage?(:SPECIAL_DEFENSE,user,self)
if user.pbRaiseStatStage(:SPECIAL_DEFENSE,1,user,showAnim)
if user.pbCanRaiseStatStage?(:SPECIAL_DEFENSE, user, self)
if user.pbRaiseStatStage(:SPECIAL_DEFENSE, 1, user, showAnim)
user.effects[PBEffects::StockpileSpDef] += 1
end
end
@@ -542,33 +542,33 @@ end
# 0. Decreases the user's Defense and Special Defense by X stages each. (Spit Up)
#===============================================================================
class Battle::Move::PowerDependsOnUserStockpile < Battle::Move
def pbMoveFailed?(user,targets)
if user.effects[PBEffects::Stockpile]==0
def pbMoveFailed?(user, targets)
if user.effects[PBEffects::Stockpile] == 0
@battle.pbDisplay(_INTL("But it failed to spit up a thing!"))
return true
end
return false
end
def pbBaseDamage(baseDmg,user,target)
return 100*user.effects[PBEffects::Stockpile]
def pbBaseDamage(baseDmg, user, target)
return 100 * user.effects[PBEffects::Stockpile]
end
def pbEffectAfterAllHits(user,target)
return if user.fainted? || user.effects[PBEffects::Stockpile]==0
def pbEffectAfterAllHits(user, target)
return if user.fainted? || user.effects[PBEffects::Stockpile] == 0
return if target.damageState.unaffected
@battle.pbDisplay(_INTL("{1}'s stockpiled effect wore off!",user.pbThis))
@battle.pbDisplay(_INTL("{1}'s stockpiled effect wore off!", user.pbThis))
return if @battle.pbAllFainted?(target.idxOwnSide)
showAnim = true
if user.effects[PBEffects::StockpileDef]>0 &&
user.pbCanLowerStatStage?(:DEFENSE,user,self)
if user.pbLowerStatStage(:DEFENSE,user.effects[PBEffects::StockpileDef],user,showAnim)
if user.effects[PBEffects::StockpileDef] > 0 &&
user.pbCanLowerStatStage?(:DEFENSE, user, self)
if user.pbLowerStatStage(:DEFENSE, user.effects[PBEffects::StockpileDef], user, showAnim)
showAnim = false
end
end
if user.effects[PBEffects::StockpileSpDef]>0 &&
user.pbCanLowerStatStage?(:SPECIAL_DEFENSE,user,self)
user.pbLowerStatStage(:SPECIAL_DEFENSE,user.effects[PBEffects::StockpileSpDef],user,showAnim)
if user.effects[PBEffects::StockpileSpDef] > 0 &&
user.pbCanLowerStatStage?(:SPECIAL_DEFENSE, user, self)
user.pbLowerStatStage(:SPECIAL_DEFENSE, user.effects[PBEffects::StockpileSpDef], user, showAnim)
end
user.effects[PBEffects::Stockpile] = 0
user.effects[PBEffects::StockpileDef] = 0
@@ -584,14 +584,14 @@ class Battle::Move::HealUserDependingOnUserStockpile < Battle::Move
def healingMove?; return true; end
def canSnatch?; return true; end
def pbMoveFailed?(user,targets)
if user.effects[PBEffects::Stockpile]==0
def pbMoveFailed?(user, targets)
if user.effects[PBEffects::Stockpile] == 0
@battle.pbDisplay(_INTL("But it failed to swallow a thing!"))
return true
end
if !user.canHeal? &&
user.effects[PBEffects::StockpileDef]==0 &&
user.effects[PBEffects::StockpileSpDef]==0
user.effects[PBEffects::StockpileDef] == 0 &&
user.effects[PBEffects::StockpileSpDef] == 0
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -600,25 +600,25 @@ class Battle::Move::HealUserDependingOnUserStockpile < Battle::Move
def pbEffectGeneral(user)
hpGain = 0
case [user.effects[PBEffects::Stockpile],1].max
when 1 then hpGain = user.totalhp/4
when 2 then hpGain = user.totalhp/2
case [user.effects[PBEffects::Stockpile], 1].max
when 1 then hpGain = user.totalhp / 4
when 2 then hpGain = user.totalhp / 2
when 3 then hpGain = user.totalhp
end
if user.pbRecoverHP(hpGain)>0
@battle.pbDisplay(_INTL("{1}'s HP was restored.",user.pbThis))
if user.pbRecoverHP(hpGain) > 0
@battle.pbDisplay(_INTL("{1}'s HP was restored.", user.pbThis))
end
@battle.pbDisplay(_INTL("{1}'s stockpiled effect wore off!",user.pbThis))
@battle.pbDisplay(_INTL("{1}'s stockpiled effect wore off!", user.pbThis))
showAnim = true
if user.effects[PBEffects::StockpileDef]>0 &&
user.pbCanLowerStatStage?(:DEFENSE,user,self)
if user.pbLowerStatStage(:DEFENSE,user.effects[PBEffects::StockpileDef],user,showAnim)
if user.effects[PBEffects::StockpileDef] > 0 &&
user.pbCanLowerStatStage?(:DEFENSE, user, self)
if user.pbLowerStatStage(:DEFENSE, user.effects[PBEffects::StockpileDef], user, showAnim)
showAnim = false
end
end
if user.effects[PBEffects::StockpileSpDef]>0 &&
user.pbCanLowerStatStage?(:SPECIAL_DEFENSE,user,self)
user.pbLowerStatStage(:SPECIAL_DEFENSE,user.effects[PBEffects::StockpileSpDef],user,showAnim)
if user.effects[PBEffects::StockpileSpDef] > 0 &&
user.pbCanLowerStatStage?(:SPECIAL_DEFENSE, user, self)
user.pbLowerStatStage(:SPECIAL_DEFENSE, user.effects[PBEffects::StockpileSpDef], user, showAnim)
end
user.effects[PBEffects::Stockpile] = 0
user.effects[PBEffects::StockpileDef] = 0
@@ -632,7 +632,7 @@ end
# swamp on the opposing side.
#===============================================================================
class Battle::Move::GrassPledge < Battle::Move::PledgeMove
def initialize(battle,move)
def initialize(battle, move)
super
# [Function code to combo with, effect, override type, override animation]
@combos = [["FirePledge", :SeaOfFire, :FIRE, :FIREPLEDGE],
@@ -646,7 +646,7 @@ end
# user's side or a sea of fire on the opposing side.
#===============================================================================
class Battle::Move::FirePledge < Battle::Move::PledgeMove
def initialize(battle,move)
def initialize(battle, move)
super
# [Function code to combo with, effect, override type, override animation]
@combos = [["WaterPledge", :Rainbow, :WATER, :WATERPLEDGE],
@@ -660,7 +660,7 @@ end
# opposing side or a rainbow on the user's side.
#===============================================================================
class Battle::Move::WaterPledge < Battle::Move::PledgeMove
def initialize(battle,move)
def initialize(battle, move)
super
# [Function code to combo with, effect, override type, override animation]
@combos = [["GrassPledge", :Swamp, :GRASS, :GRASSPLEDGE],
@@ -674,7 +674,7 @@ end
class Battle::Move::UseLastMoveUsed < Battle::Move
def callsAnotherMove?; return true; end
def initialize(battle,move)
def initialize(battle, move)
super
@moveBlacklist = [
# Struggle, Belch
@@ -738,12 +738,12 @@ class Battle::Move::UseLastMoveUsed < Battle::Move
end
end
def pbChangeUsageCounters(user,specialUsage)
def pbChangeUsageCounters(user, specialUsage)
super
@copied_move = @battle.lastMoveUsed
end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !@copied_move ||
@moveBlacklist.include?(GameData::Move.get(@copied_move).function_code)
@battle.pbDisplay(_INTL("But it failed!"))
@@ -773,11 +773,11 @@ class Battle::Move::UseLastMoveUsedByTarget < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
user.pbUseMoveSimple(target.lastRegularMoveUsed,target.index)
def pbEffectAgainstTarget(user, target)
user.pbUseMoveSimple(target.lastRegularMoveUsed, target.index)
end
def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true)
def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true)
# No animation
end
end
@@ -790,7 +790,7 @@ class Battle::Move::UseMoveTargetIsAboutToUse < Battle::Move
def ignoresSubstitute?(user); return true; end
def callsAnotherMove?; return true; end
def initialize(battle,move)
def initialize(battle, move)
super
@moveBlacklist = [
"UserTakesTargetItem", # Covet, Thief
@@ -818,7 +818,7 @@ class Battle::Move::UseMoveTargetIsAboutToUse < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
user.effects[PBEffects::MeFirst] = true
user.pbUseMoveSimple(@battle.choices[target.index][2].id)
user.effects[PBEffects::MeFirst] = false
@@ -834,7 +834,7 @@ end
class Battle::Move::UseMoveDependingOnEnvironment < Battle::Move
def callsAnotherMove?; return true; end
def pbOnStartUse(user,targets)
def pbOnStartUse(user, targets)
# NOTE: It's possible in theory to not have the move Nature Power wants to
# turn into, but what self-respecting game wouldn't at least have Tri
# Attack in it?
@@ -882,7 +882,7 @@ class Battle::Move::UseMoveDependingOnEnvironment < Battle::Move
end
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
@battle.pbDisplay(_INTL("{1} turned into {2}!", @name, GameData::Move.get(@npMove).name))
user.pbUseMoveSimple(@npMove, target.index)
end
@@ -894,7 +894,7 @@ end
class Battle::Move::UseRandomMove < Battle::Move
def callsAnotherMove?; return true; end
def initialize(battle,move)
def initialize(battle, move)
super
@moveBlacklist = [
"FlinchTargetFailsIfUserNotAsleep", # Snore
@@ -977,7 +977,7 @@ class Battle::Move::UseRandomMove < Battle::Move
]
end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
@metronomeMove = nil
move_keys = GameData::Move.keys
# NOTE: You could be really unlucky and roll blacklisted moves 1000 times in
@@ -1009,7 +1009,7 @@ end
class Battle::Move::UseRandomMoveFromUserParty < Battle::Move
def callsAnotherMove?; return true; end
def initialize(battle,move)
def initialize(battle, move)
super
@moveBlacklist = [
# Struggle, Belch
@@ -1092,11 +1092,11 @@ class Battle::Move::UseRandomMoveFromUserParty < Battle::Move
end
end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
@assistMoves = []
# NOTE: This includes the Pokémon of ally trainers in multi battles.
@battle.pbParty(user.index).each_with_index do |pkmn,i|
next if !pkmn || i==user.pokemonIndex
@battle.pbParty(user.index).each_with_index do |pkmn, i|
next if !pkmn || i == user.pokemonIndex
next if Settings::MECHANICS_GENERATION >= 6 && pkmn.egg?
pkmn.moves.each do |move|
next if @moveBlacklist.include?(move.function_code)
@@ -1104,7 +1104,7 @@ class Battle::Move::UseRandomMoveFromUserParty < Battle::Move
@assistMoves.push(move.id)
end
end
if @assistMoves.length==0
if @assistMoves.length == 0
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -1124,7 +1124,7 @@ class Battle::Move::UseRandomUserMoveIfAsleep < Battle::Move
def usableWhenAsleep?; return true; end
def callsAnotherMove?; return true; end
def initialize(battle,move)
def initialize(battle, move)
super
@moveBlacklist = [
"MultiTurnAttackPreventSleeping", # Uproar
@@ -1165,14 +1165,14 @@ class Battle::Move::UseRandomUserMoveIfAsleep < Battle::Move
]
end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
@sleepTalkMoves = []
user.eachMoveWithIndex do |m,i|
user.eachMoveWithIndex do |m, i|
next if @moveBlacklist.include?(m.function)
next if !@battle.pbCanChooseMove?(user.index,i,false,true)
next if !@battle.pbCanChooseMove?(user.index, i, false, true)
@sleepTalkMoves.push(i)
end
if !user.asleep? || @sleepTalkMoves.length==0
if !user.asleep? || @sleepTalkMoves.length == 0
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -1181,7 +1181,7 @@ class Battle::Move::UseRandomUserMoveIfAsleep < Battle::Move
def pbEffectGeneral(user)
choice = @sleepTalkMoves[@battle.pbRandom(@sleepTalkMoves.length)]
user.pbUseMoveSimple(user.moves[choice].id,user.pbDirectOpposing.index)
user.pbUseMoveSimple(user.moves[choice].id, user.pbDirectOpposing.index)
end
end
@@ -1192,7 +1192,7 @@ end
class Battle::Move::BounceBackProblemCausingStatusMoves < Battle::Move
def pbEffectGeneral(user)
user.effects[PBEffects::MagicCoat] = true
@battle.pbDisplay(_INTL("{1} shrouded itself with Magic Coat!",user.pbThis))
@battle.pbDisplay(_INTL("{1} shrouded itself with Magic Coat!", user.pbThis))
end
end
@@ -1203,10 +1203,10 @@ class Battle::Move::StealAndUseBeneficialStatusMove < Battle::Move
def pbEffectGeneral(user)
user.effects[PBEffects::Snatch] = 1
@battle.allBattlers.each do |b|
next if b.effects[PBEffects::Snatch]<user.effects[PBEffects::Snatch]
user.effects[PBEffects::Snatch] = b.effects[PBEffects::Snatch]+1
next if b.effects[PBEffects::Snatch] < user.effects[PBEffects::Snatch]
user.effects[PBEffects::Snatch] = b.effects[PBEffects::Snatch] + 1
end
@battle.pbDisplay(_INTL("{1} waits for a target to make a move!",user.pbThis))
@battle.pbDisplay(_INTL("{1} waits for a target to make a move!", user.pbThis))
end
end
@@ -1217,7 +1217,7 @@ end
class Battle::Move::ReplaceMoveThisBattleWithTargetLastMoveUsed < Battle::Move
def ignoresSubstitute?(user); return true; end
def initialize(battle,move)
def initialize(battle, move)
super
@moveBlacklist = [
"UseRandomMove", # Metronome
@@ -1230,7 +1230,7 @@ class Battle::Move::ReplaceMoveThisBattleWithTargetLastMoveUsed < Battle::Move
]
end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if user.effects[PBEffects::Transform] || !user.pbHasMove?(@id)
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -1250,12 +1250,12 @@ class Battle::Move::ReplaceMoveThisBattleWithTargetLastMoveUsed < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
user.eachMoveWithIndex do |m,i|
next if m.id!=@id
def pbEffectAgainstTarget(user, target)
user.eachMoveWithIndex do |m, i|
next if m.id != @id
newMove = Pokemon::Move.new(target.lastRegularMoveUsed)
user.moves[i] = Battle::Move.from_pokemon_move(@battle,newMove)
@battle.pbDisplay(_INTL("{1} learned {2}!",user.pbThis,newMove.name))
user.moves[i] = Battle::Move.from_pokemon_move(@battle, newMove)
@battle.pbDisplay(_INTL("{1} learned {2}!", user.pbThis, newMove.name))
user.pbCheckFormOnMovesetChange
break
end
@@ -1268,7 +1268,7 @@ end
class Battle::Move::ReplaceMoveWithTargetLastMoveUsed < Battle::Move
def ignoresSubstitute?(user); return true; end
def initialize(battle,move)
def initialize(battle, move)
super
@moveBlacklist = [
"ReplaceMoveWithTargetLastMoveUsed", # Sketch (this move)
@@ -1277,7 +1277,7 @@ class Battle::Move::ReplaceMoveWithTargetLastMoveUsed < Battle::Move
]
end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if user.effects[PBEffects::Transform] || !user.pbHasMove?(@id)
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -1297,13 +1297,13 @@ class Battle::Move::ReplaceMoveWithTargetLastMoveUsed < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
user.eachMoveWithIndex do |m,i|
next if m.id!=@id
def pbEffectAgainstTarget(user, target)
user.eachMoveWithIndex do |m, i|
next if m.id != @id
newMove = Pokemon::Move.new(target.lastRegularMoveUsed)
user.pokemon.moves[i] = newMove
user.moves[i] = Battle::Move.from_pokemon_move(@battle,newMove)
@battle.pbDisplay(_INTL("{1} learned {2}!",user.pbThis,newMove.name))
user.moves[i] = Battle::Move.from_pokemon_move(@battle, newMove)
@battle.pbDisplay(_INTL("{1} learned {2}!", user.pbThis, newMove.name))
user.pbCheckFormOnMovesetChange
break
end

View File

@@ -2,7 +2,7 @@
# User flees from battle. (Teleport (Gen 7-))
#===============================================================================
class Battle::Move::FleeFromBattle < Battle::Move
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !@battle.pbCanRun?(user.index)
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -11,7 +11,7 @@ class Battle::Move::FleeFromBattle < Battle::Move
end
def pbEffectGeneral(user)
@battle.pbDisplay(_INTL("{1} fled from battle!",user.pbThis))
@battle.pbDisplay(_INTL("{1} fled from battle!", user.pbThis))
@battle.decision = 3 # Escaped
end
end
@@ -21,7 +21,7 @@ end
# (Teleport (Gen 8+))
#===============================================================================
class Battle::Move::SwitchOutUserStatusMove < Battle::Move
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if user.wild?
if !@battle.pbCanRun?(user.index)
@battle.pbDisplay(_INTL("But it failed!"))
@@ -34,15 +34,15 @@ class Battle::Move::SwitchOutUserStatusMove < Battle::Move
return false
end
def pbEndOfMoveUsageEffect(user,targets,numHits,switchedBattlers)
def pbEndOfMoveUsageEffect(user, targets, numHits, switchedBattlers)
return if user.wild?
@battle.pbDisplay(_INTL("{1} went back to {2}!",user.pbThis,
@battle.pbDisplay(_INTL("{1} went back to {2}!", user.pbThis,
@battle.pbGetOwnerName(user.index)))
@battle.pbPursuit(user.index)
return if user.fainted?
newPkmn = @battle.pbGetReplacementPokemonIndex(user.index) # Owner chooses
return if newPkmn<0
@battle.pbRecallAndReplace(user.index,newPkmn)
return if newPkmn < 0
@battle.pbRecallAndReplace(user.index, newPkmn)
@battle.pbClearChoice(user.index) # Replacement Pokémon does nothing this round
@battle.moldBreaker = false
@battle.pbOnBattlerEnteringBattle(user.index)
@@ -51,7 +51,7 @@ class Battle::Move::SwitchOutUserStatusMove < Battle::Move
def pbEffectGeneral(user)
if user.wild?
@battle.pbDisplay(_INTL("{1} fled from battle!",user.pbThis))
@battle.pbDisplay(_INTL("{1} fled from battle!", user.pbThis))
@battle.decision = 3 # Escaped
end
end
@@ -62,21 +62,21 @@ end
# (U-turn, Volt Switch)
#===============================================================================
class Battle::Move::SwitchOutUserDamagingMove < Battle::Move
def pbEndOfMoveUsageEffect(user,targets,numHits,switchedBattlers)
return if user.fainted? || numHits==0 || @battle.pbAllFainted?(user.idxOpposingSide)
def pbEndOfMoveUsageEffect(user, targets, numHits, switchedBattlers)
return if user.fainted? || numHits == 0 || @battle.pbAllFainted?(user.idxOpposingSide)
targetSwitched = true
targets.each do |b|
targetSwitched = false if !switchedBattlers.include?(b.index)
end
return if targetSwitched
return if !@battle.pbCanChooseNonActive?(user.index)
@battle.pbDisplay(_INTL("{1} went back to {2}!",user.pbThis,
@battle.pbDisplay(_INTL("{1} went back to {2}!", user.pbThis,
@battle.pbGetOwnerName(user.index)))
@battle.pbPursuit(user.index)
return if user.fainted?
newPkmn = @battle.pbGetReplacementPokemonIndex(user.index) # Owner chooses
return if newPkmn<0
@battle.pbRecallAndReplace(user.index,newPkmn)
return if newPkmn < 0
@battle.pbRecallAndReplace(user.index, newPkmn)
@battle.pbClearChoice(user.index) # Replacement Pokémon does nothing this round
@battle.moldBreaker = false
@battle.pbOnBattlerEnteringBattle(user.index)
@@ -89,28 +89,28 @@ end
# switches out. Ignores trapping moves. (Parting Shot)
#===============================================================================
class Battle::Move::LowerTargetAtkSpAtk1SwitchOutUser < Battle::Move::TargetMultiStatDownMove
def initialize(battle,move)
def initialize(battle, move)
super
@statDown = [:ATTACK,1,:SPECIAL_ATTACK,1]
@statDown = [:ATTACK, 1, :SPECIAL_ATTACK, 1]
end
def pbEndOfMoveUsageEffect(user,targets,numHits,switchedBattlers)
def pbEndOfMoveUsageEffect(user, targets, numHits, switchedBattlers)
switcher = user
targets.each do |b|
next if switchedBattlers.include?(b.index)
switcher = b if b.effects[PBEffects::MagicCoat] || b.effects[PBEffects::MagicBounce]
end
return if switcher.fainted? || numHits==0
return if switcher.fainted? || numHits == 0
return if !@battle.pbCanChooseNonActive?(switcher.index)
@battle.pbDisplay(_INTL("{1} went back to {2}!",switcher.pbThis,
@battle.pbDisplay(_INTL("{1} went back to {2}!", switcher.pbThis,
@battle.pbGetOwnerName(switcher.index)))
@battle.pbPursuit(switcher.index)
return if switcher.fainted?
newPkmn = @battle.pbGetReplacementPokemonIndex(switcher.index) # Owner chooses
return if newPkmn<0
@battle.pbRecallAndReplace(switcher.index,newPkmn)
return if newPkmn < 0
@battle.pbRecallAndReplace(switcher.index, newPkmn)
@battle.pbClearChoice(switcher.index) # Replacement Pokémon does nothing this round
@battle.moldBreaker = false if switcher.index==user.index
@battle.moldBreaker = false if switcher.index == user.index
@battle.pbOnBattlerEnteringBattle(switcher.index)
switchedBattlers.push(switcher.index)
end
@@ -121,7 +121,7 @@ end
# replacement. (Baton Pass)
#===============================================================================
class Battle::Move::SwitchOutUserPassOnEffects < Battle::Move
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !@battle.pbCanChooseNonActive?(user.index)
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -129,13 +129,13 @@ class Battle::Move::SwitchOutUserPassOnEffects < Battle::Move
return false
end
def pbEndOfMoveUsageEffect(user,targets,numHits,switchedBattlers)
return if user.fainted? || numHits==0
def pbEndOfMoveUsageEffect(user, targets, numHits, switchedBattlers)
return if user.fainted? || numHits == 0
return if !@battle.pbCanChooseNonActive?(user.index)
@battle.pbPursuit(user.index)
return if user.fainted?
newPkmn = @battle.pbGetReplacementPokemonIndex(user.index) # Owner chooses
return if newPkmn<0
return if newPkmn < 0
@battle.pbRecallAndReplace(user.index, newPkmn, false, true)
@battle.pbClearChoice(user.index) # Replacement Pokémon does nothing this round
@battle.moldBreaker = false
@@ -175,14 +175,14 @@ class Battle::Move::SwitchOutTargetStatusMove < Battle::Move
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
if @battle.wildBattle? && target.level>user.level
if @battle.wildBattle? && target.level > user.level
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
if @battle.trainerBattle?
canSwitch = false
@battle.eachInTeamFromBattlerIndex(target.index) do |_pkmn,i|
next if !@battle.pbCanSwitchLax?(target.index,i)
@battle.eachInTeamFromBattlerIndex(target.index) do |_pkmn, i|
next if !@battle.pbCanSwitchLax?(target.index, i)
canSwitch = true
break
end
@@ -205,10 +205,10 @@ class Battle::Move::SwitchOutTargetStatusMove < Battle::Move
next if b.fainted? || b.damageState.unaffected
next if b.effects[PBEffects::Ingrain]
next if b.hasActiveAbility?(:SUCTIONCUPS) && !@battle.moldBreaker
newPkmn = @battle.pbGetReplacementPokemonIndex(b.index,true) # Random
next if newPkmn<0
newPkmn = @battle.pbGetReplacementPokemonIndex(b.index, true) # Random
next if newPkmn < 0
@battle.pbRecallAndReplace(b.index, newPkmn, true)
@battle.pbDisplay(_INTL("{1} was dragged out!",b.pbThis))
@battle.pbDisplay(_INTL("{1} was dragged out!", b.pbThis))
@battle.pbClearChoice(b.index) # Replacement Pokémon does nothing this round
@battle.pbOnBattlerEnteringBattle(b.index)
switched_battlers.push(b.index)
@@ -224,9 +224,9 @@ end
# For damaging moves. (Circle Throw, Dragon Tail)
#===============================================================================
class Battle::Move::SwitchOutTargetDamagingMove < Battle::Move
def pbEffectAgainstTarget(user,target)
if @battle.wildBattle? && target.level<=user.level && @battle.canRun &&
(target.effects[PBEffects::Substitute]==0 || ignoresSubstitute?(user))
def pbEffectAgainstTarget(user, target)
if @battle.wildBattle? && target.level <= user.level && @battle.canRun &&
(target.effects[PBEffects::Substitute] == 0 || ignoresSubstitute?(user))
@battle.decision = 3
end
end
@@ -238,10 +238,10 @@ class Battle::Move::SwitchOutTargetDamagingMove < Battle::Move
next if b.fainted? || b.damageState.unaffected || b.damageState.substitute
next if b.effects[PBEffects::Ingrain]
next if b.hasActiveAbility?(:SUCTIONCUPS) && !@battle.moldBreaker
newPkmn = @battle.pbGetReplacementPokemonIndex(b.index,true) # Random
next if newPkmn<0
newPkmn = @battle.pbGetReplacementPokemonIndex(b.index, true) # Random
next if newPkmn < 0
@battle.pbRecallAndReplace(b.index, newPkmn, true)
@battle.pbDisplay(_INTL("{1} was dragged out!",b.pbThis))
@battle.pbDisplay(_INTL("{1} was dragged out!", b.pbThis))
@battle.pbClearChoice(b.index) # Replacement Pokémon does nothing this round
@battle.pbOnBattlerEnteringBattle(b.index)
switched_battlers.push(b.index)
@@ -255,36 +255,36 @@ end
# at end of each round.
#===============================================================================
class Battle::Move::BindTarget < Battle::Move
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
return if target.fainted? || target.damageState.substitute
return if target.effects[PBEffects::Trapping]>0
return if target.effects[PBEffects::Trapping] > 0
# Set trapping effect duration and info
if user.hasActiveItem?(:GRIPCLAW)
target.effects[PBEffects::Trapping] = (Settings::MECHANICS_GENERATION >= 5) ? 8 : 6
else
target.effects[PBEffects::Trapping] = 5+@battle.pbRandom(2)
target.effects[PBEffects::Trapping] = 5 + @battle.pbRandom(2)
end
target.effects[PBEffects::TrappingMove] = @id
target.effects[PBEffects::TrappingUser] = user.index
# Message
msg = _INTL("{1} was trapped in the vortex!",target.pbThis)
msg = _INTL("{1} was trapped in the vortex!", target.pbThis)
case @id
when :BIND
msg = _INTL("{1} was squeezed by {2}!",target.pbThis,user.pbThis(true))
msg = _INTL("{1} was squeezed by {2}!", target.pbThis, user.pbThis(true))
when :CLAMP
msg = _INTL("{1} clamped {2}!",user.pbThis,target.pbThis(true))
msg = _INTL("{1} clamped {2}!", user.pbThis, target.pbThis(true))
when :FIRESPIN
msg = _INTL("{1} was trapped in the fiery vortex!",target.pbThis)
msg = _INTL("{1} was trapped in the fiery vortex!", target.pbThis)
when :INFESTATION
msg = _INTL("{1} has been afflicted with an infestation by {2}!",target.pbThis,user.pbThis(true))
msg = _INTL("{1} has been afflicted with an infestation by {2}!", target.pbThis, user.pbThis(true))
when :MAGMASTORM
msg = _INTL("{1} became trapped by Magma Storm!",target.pbThis)
msg = _INTL("{1} became trapped by Magma Storm!", target.pbThis)
when :SANDTOMB
msg = _INTL("{1} became trapped by Sand Tomb!",target.pbThis)
msg = _INTL("{1} became trapped by Sand Tomb!", target.pbThis)
when :WHIRLPOOL
msg = _INTL("{1} became trapped in the vortex!",target.pbThis)
msg = _INTL("{1} became trapped in the vortex!", target.pbThis)
when :WRAP
msg = _INTL("{1} was wrapped by {2}!",target.pbThis,user.pbThis(true))
msg = _INTL("{1} was wrapped by {2}!", target.pbThis, user.pbThis(true))
end
@battle.pbDisplay(msg)
end
@@ -298,7 +298,7 @@ end
class Battle::Move::BindTargetDoublePowerIfTargetUnderwater < Battle::Move::BindTarget
def hitsDivingTargets?; return true; end
def pbModifyDamage(damageMult,user,target)
def pbModifyDamage(damageMult, user, target)
damageMult *= 2 if target.inTwoTurnAttack?("TwoTurnAttackInvulnerableUnderwater")
return damageMult
end
@@ -313,7 +313,7 @@ class Battle::Move::TrapTargetInBattle < Battle::Move
def pbFailsAgainstTarget?(user, target, show_message)
return false if damagingMove?
if target.effects[PBEffects::MeanLook]>=0
if target.effects[PBEffects::MeanLook] >= 0
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
@@ -324,18 +324,18 @@ class Battle::Move::TrapTargetInBattle < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
return if damagingMove?
target.effects[PBEffects::MeanLook] = user.index
@battle.pbDisplay(_INTL("{1} can no longer escape!",target.pbThis))
@battle.pbDisplay(_INTL("{1} can no longer escape!", target.pbThis))
end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.fainted? || target.damageState.substitute
return if target.effects[PBEffects::MeanLook]>=0
return if target.effects[PBEffects::MeanLook] >= 0
return if Settings::MORE_TYPE_EFFECTS && target.pbHasType?(:GHOST)
target.effects[PBEffects::MeanLook] = user.index
@battle.pbDisplay(_INTL("{1} can no longer escape!",target.pbThis))
@battle.pbDisplay(_INTL("{1} can no longer escape!", target.pbThis))
end
end
@@ -383,8 +383,8 @@ end
# No Pokémon can switch out or flee until the end of the next round. (Fairy Lock)
#===============================================================================
class Battle::Move::TrapAllBattlersInBattleForOneTurn < Battle::Move
def pbMoveFailed?(user,targets)
if @battle.field.effects[PBEffects::FairyLock]>0
def pbMoveFailed?(user, targets)
if @battle.field.effects[PBEffects::FairyLock] > 0
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -403,12 +403,12 @@ end
# (Handled in Battle's pbAttackPhase): Makes this attack happen before switching.
#===============================================================================
class Battle::Move::PursueSwitchingFoe < Battle::Move
def pbAccuracyCheck(user,target)
def pbAccuracyCheck(user, target)
return true if @battle.switching
return super
end
def pbBaseDamage(baseDmg,user,target)
def pbBaseDamage(baseDmg, user, target)
baseDmg *= 2 if @battle.switching
return baseDmg
end
@@ -421,21 +421,21 @@ end
class Battle::Move::UsedAfterUserTakesPhysicalDamage < Battle::Move
def pbDisplayChargeMessage(user)
user.effects[PBEffects::ShellTrap] = true
@battle.pbCommonAnimation("ShellTrap",user)
@battle.pbDisplay(_INTL("{1} set a shell trap!",user.pbThis))
@battle.pbCommonAnimation("ShellTrap", user)
@battle.pbDisplay(_INTL("{1} set a shell trap!", user.pbThis))
end
def pbDisplayUseMessage(user)
super if user.tookPhysicalHit
end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !user.effects[PBEffects::ShellTrap]
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
if !user.tookPhysicalHit
@battle.pbDisplay(_INTL("{1}'s shell trap didn't work!",user.pbThis))
@battle.pbDisplay(_INTL("{1}'s shell trap didn't work!", user.pbThis))
return true
end
return false
@@ -447,7 +447,7 @@ end
# If an ally is about to use the same move, make it go next, ignoring priority.
#===============================================================================
class Battle::Move::UsedAfterAllyRoundWithDoublePower < Battle::Move
def pbBaseDamage(baseDmg,user,target)
def pbBaseDamage(baseDmg, user, target)
baseDmg *= 2 if user.pbOwnSide.effects[PBEffects::Round]
return baseDmg
end
@@ -455,8 +455,8 @@ class Battle::Move::UsedAfterAllyRoundWithDoublePower < Battle::Move
def pbEffectGeneral(user)
user.pbOwnSide.effects[PBEffects::Round] = true
user.allAllies.each do |b|
next if @battle.choices[b.index][0]!=:UseMove || b.movedThisRound?
next if @battle.choices[b.index][2].function!=@function
next if @battle.choices[b.index][0] != :UseMove || b.movedThisRound?
next if @battle.choices[b.index][2].function != @function
b.effects[PBEffects::MoveNext] = true
b.effects[PBEffects::Quash] = 0
break
@@ -487,10 +487,10 @@ class Battle::Move::TargetActsNext < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::MoveNext] = true
target.effects[PBEffects::Quash] = 0
@battle.pbDisplay(_INTL("{1} took the kind offer!",target.pbThis))
@battle.pbDisplay(_INTL("{1} took the kind offer!", target.pbThis))
end
end
@@ -509,30 +509,30 @@ class Battle::Move::TargetActsLast < Battle::Move
# Target is already maximally Quashed and will move last anyway
highestQuash = 0
@battle.allBattlers.each do |b|
next if b.effects[PBEffects::Quash]<=highestQuash
next if b.effects[PBEffects::Quash] <= highestQuash
highestQuash = b.effects[PBEffects::Quash]
end
if highestQuash>0 && target.effects[PBEffects::Quash]==highestQuash
if highestQuash > 0 && target.effects[PBEffects::Quash] == highestQuash
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
# Target was already going to move last
if highestQuash==0 && @battle.pbPriority.last.index==target.index
if highestQuash == 0 && @battle.pbPriority.last.index == target.index
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
highestQuash = 0
@battle.allBattlers.each do |b|
next if b.effects[PBEffects::Quash]<=highestQuash
next if b.effects[PBEffects::Quash] <= highestQuash
highestQuash = b.effects[PBEffects::Quash]
end
target.effects[PBEffects::Quash] = highestQuash+1
target.effects[PBEffects::Quash] = highestQuash + 1
target.effects[PBEffects::MoveNext] = false
@battle.pbDisplay(_INTL("{1}'s move was postponed!",target.pbThis))
@battle.pbDisplay(_INTL("{1}'s move was postponed!", target.pbThis))
end
end
@@ -542,7 +542,7 @@ end
class Battle::Move::TargetUsesItsLastUsedMoveAgain < Battle::Move
def ignoresSubstitute?(user); return true; end
def initialize(battle,move)
def initialize(battle, move)
super
@moveBlacklist = [
"MultiTurnAttackBideThenReturnDoubleDamage", # Bide
@@ -596,9 +596,9 @@ class Battle::Move::TargetUsesItsLastUsedMoveAgain < Battle::Move
return true
end
targetMove = @battle.choices[target.index][2]
if targetMove && (targetMove.function=="FailsIfUserDamagedThisTurn" || # Focus Punch
targetMove.function=="UsedAfterUserTakesPhysicalDamage" || # Shell Trap
targetMove.function=="BurnAttackerBeforeUserActs") # Beak Blast
if targetMove && (targetMove.function == "FailsIfUserDamagedThisTurn" || # Focus Punch
targetMove.function == "UsedAfterUserTakesPhysicalDamage" || # Shell Trap
targetMove.function == "BurnAttackerBeforeUserActs") # Beak Blast
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
@@ -607,17 +607,17 @@ class Battle::Move::TargetUsesItsLastUsedMoveAgain < Battle::Move
return true
end
idxMove = -1
target.eachMoveWithIndex do |m,i|
idxMove = i if m.id==target.lastRegularMoveUsed
target.eachMoveWithIndex do |m, i|
idxMove = i if m.id == target.lastRegularMoveUsed
end
if target.moves[idxMove].pp==0 && target.moves[idxMove].total_pp>0
if target.moves[idxMove].pp == 0 && target.moves[idxMove].total_pp > 0
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::Instruct] = true
end
end
@@ -628,17 +628,17 @@ end
#===============================================================================
class Battle::Move::StartSlowerBattlersActFirst < Battle::Move
def pbEffectGeneral(user)
if @battle.field.effects[PBEffects::TrickRoom]>0
if @battle.field.effects[PBEffects::TrickRoom] > 0
@battle.field.effects[PBEffects::TrickRoom] = 0
@battle.pbDisplay(_INTL("{1} reverted the dimensions!",user.pbThis))
@battle.pbDisplay(_INTL("{1} reverted the dimensions!", user.pbThis))
else
@battle.field.effects[PBEffects::TrickRoom] = 5
@battle.pbDisplay(_INTL("{1} twisted the dimensions!",user.pbThis))
@battle.pbDisplay(_INTL("{1} twisted the dimensions!", user.pbThis))
end
end
def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true)
return if @battle.field.effects[PBEffects::TrickRoom]>0 # No animation
def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true)
return if @battle.field.effects[PBEffects::TrickRoom] > 0 # No animation
super
end
end
@@ -710,15 +710,15 @@ class Battle::Move::DisableTargetLastMoveUsed < Battle::Move
def canMagicCoat?; return true; end
def pbFailsAgainstTarget?(user, target, show_message)
if target.effects[PBEffects::Disable]>0 || !target.lastRegularMoveUsed
if target.effects[PBEffects::Disable] > 0 || !target.lastRegularMoveUsed
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
return true if pbMoveFailedAromaVeil?(user, target, show_message)
canDisable = false
target.eachMove do |m|
next if m.id!=target.lastRegularMoveUsed
next if m.pp==0 && m.total_pp>0
next if m.id != target.lastRegularMoveUsed
next if m.pp == 0 && m.total_pp > 0
canDisable = true
break
end
@@ -729,10 +729,10 @@ class Battle::Move::DisableTargetLastMoveUsed < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::Disable] = 5
target.effects[PBEffects::DisableMove] = target.lastRegularMoveUsed
@battle.pbDisplay(_INTL("{1}'s {2} was disabled!",target.pbThis,
@battle.pbDisplay(_INTL("{1}'s {2} was disabled!", target.pbThis,
GameData::Move.get(target.lastRegularMoveUsed).name))
target.pbItemStatusCureCheck
end
@@ -754,9 +754,9 @@ class Battle::Move::DisableTargetUsingSameMoveConsecutively < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::Torment] = true
@battle.pbDisplay(_INTL("{1} was subjected to torment!",target.pbThis))
@battle.pbDisplay(_INTL("{1} was subjected to torment!", target.pbThis))
target.pbItemStatusCureCheck
end
end
@@ -768,7 +768,7 @@ class Battle::Move::DisableTargetUsingDifferentMove < Battle::Move
def ignoresSubstitute?(user); return true; end
def canMagicCoat?; return true; end
def initialize(battle,move)
def initialize(battle, move)
super
@moveBlacklist = [
"DisableTargetUsingDifferentMove", # Encore
@@ -796,7 +796,7 @@ class Battle::Move::DisableTargetUsingDifferentMove < Battle::Move
end
def pbFailsAgainstTarget?(user, target, show_message)
if target.effects[PBEffects::Encore]>0
if target.effects[PBEffects::Encore] > 0
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
@@ -812,8 +812,8 @@ class Battle::Move::DisableTargetUsingDifferentMove < Battle::Move
return true if pbMoveFailedAromaVeil?(user, target, show_message)
canEncore = false
target.eachMove do |m|
next if m.id!=target.lastRegularMoveUsed
next if m.pp==0 && m.total_pp>0
next if m.id != target.lastRegularMoveUsed
next if m.pp == 0 && m.total_pp > 0
canEncore = true
break
end
@@ -824,10 +824,10 @@ class Battle::Move::DisableTargetUsingDifferentMove < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::Encore] = 4
target.effects[PBEffects::EncoreMove] = target.lastRegularMoveUsed
@battle.pbDisplay(_INTL("{1} received an encore!",target.pbThis))
@battle.pbDisplay(_INTL("{1} received an encore!", target.pbThis))
target.pbItemStatusCureCheck
end
end
@@ -840,7 +840,7 @@ class Battle::Move::DisableTargetStatusMoves < Battle::Move
def canMagicCoat?; return true; end
def pbFailsAgainstTarget?(user, target, show_message)
if target.effects[PBEffects::Taunt]>0
if target.effects[PBEffects::Taunt] > 0
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
@@ -862,9 +862,9 @@ class Battle::Move::DisableTargetStatusMoves < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::Taunt] = 4
@battle.pbDisplay(_INTL("{1} fell for the taunt!",target.pbThis))
@battle.pbDisplay(_INTL("{1} fell for the taunt!", target.pbThis))
target.pbItemStatusCureCheck
end
end
@@ -876,7 +876,7 @@ class Battle::Move::DisableTargetHealingMoves < Battle::Move
def canMagicCoat?; return true; end
def pbFailsAgainstTarget?(user, target, show_message)
if target.effects[PBEffects::HealBlock]>0
if target.effects[PBEffects::HealBlock] > 0
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
@@ -884,9 +884,9 @@ class Battle::Move::DisableTargetHealingMoves < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::HealBlock] = 5
@battle.pbDisplay(_INTL("{1} was prevented from healing!",target.pbThis))
@battle.pbDisplay(_INTL("{1} was prevented from healing!", target.pbThis))
target.pbItemStatusCureCheck
end
end
@@ -895,10 +895,10 @@ end
# Target cannot use sound-based moves for 2 more rounds. (Throat Chop)
#===============================================================================
class Battle::Move::DisableTargetSoundMoves < Battle::Move
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.fainted? || target.damageState.substitute
@battle.pbDisplay(_INTL("The effects of {1} prevent {2} from using certain moves!",
@name,target.pbThis(true))) if target.effects[PBEffects::ThroatChop]==0
@name, target.pbThis(true))) if target.effects[PBEffects::ThroatChop] == 0
target.effects[PBEffects::ThroatChop] = 3
end
end
@@ -909,7 +909,7 @@ end
class Battle::Move::DisableTargetMovesKnownByUser < Battle::Move
def canSnatch?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if user.effects[PBEffects::Imprison]
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -919,6 +919,6 @@ class Battle::Move::DisableTargetMovesKnownByUser < Battle::Move
def pbEffectGeneral(user)
user.effects[PBEffects::Imprison] = true
@battle.pbDisplay(_INTL("{1} sealed any moves its target shares with it!",user.pbThis))
@battle.pbDisplay(_INTL("{1} sealed any moves its target shares with it!", user.pbThis))
end
end

View File

@@ -84,9 +84,9 @@ class Battle::Scene
def pbGraphicsUpdate
# Update lineup animations
if @animations.length>0
if @animations.length > 0
shouldCompact = false
@animations.each_with_index do |a,i|
@animations.each_with_index do |a, i|
a.update
if a.animDone?
a.dispose
@@ -100,7 +100,7 @@ class Battle::Scene
@sprites["battle_bg"].update if @sprites["battle_bg"].respond_to?("update")
Graphics.update
@frameCounter += 1
@frameCounter = @frameCounter%(Graphics.frame_rate*12/20)
@frameCounter = @frameCounter % (Graphics.frame_rate * 12 / 20)
end
def pbInputUpdate
@@ -113,7 +113,7 @@ class Battle::Scene
def pbFrameUpdate(cw = nil)
cw.update if cw
@battle.battlers.each_with_index do |b,i|
@battle.battlers.each_with_index do |b, i|
next if !b
@sprites["dataBox_#{i}"].update(@frameCounter) if @sprites["dataBox_#{i}"]
@sprites["pokemon_#{i}"].update(@frameCounter) if @sprites["pokemon_#{i}"]
@@ -122,7 +122,7 @@ class Battle::Scene
end
def pbRefresh
@battle.battlers.each_with_index do |b,i|
@battle.battlers.each_with_index do |b, i|
next if !b
@sprites["dataBox_#{i}"].refresh if @sprites["dataBox_#{i}"]
end
@@ -147,7 +147,7 @@ class Battle::Scene
#=============================================================================
# Returns whether the party line-ups are currently coming on-screen
def inPartyAnimation?
return @animations.length>0
return @animations.length > 0
end
#=============================================================================
@@ -157,11 +157,11 @@ class Battle::Scene
# NOTE: If you are not using fancy graphics for the command/fight menus, you
# will need to make "messageBox" also visible if the windowtype if
# COMMAND_BOX/FIGHT_BOX respectively.
@sprites["messageBox"].visible = (windowType==MESSAGE_BOX)
@sprites["messageWindow"].visible = (windowType==MESSAGE_BOX)
@sprites["commandWindow"].visible = (windowType==COMMAND_BOX)
@sprites["fightWindow"].visible = (windowType==FIGHT_BOX)
@sprites["targetWindow"].visible = (windowType==TARGET_BOX)
@sprites["messageBox"].visible = (windowType == MESSAGE_BOX)
@sprites["messageWindow"].visible = (windowType == MESSAGE_BOX)
@sprites["commandWindow"].visible = (windowType == COMMAND_BOX)
@sprites["fightWindow"].visible = (windowType == FIGHT_BOX)
@sprites["targetWindow"].visible = (windowType == TARGET_BOX)
end
# This is for the end of brief messages, which have been lingering on-screen
@@ -185,7 +185,7 @@ class Battle::Scene
# NOTE: A regular message is displayed for 1 second after it fully appears (or
# less if Back/Use is pressed). Disappears automatically after that time.
def pbDisplayMessage(msg,brief = false)
def pbDisplayMessage(msg, brief = false)
pbWaitMessage
pbShowWindow(MESSAGE_BOX)
cw = @sprites["messageWindow"]
@@ -235,7 +235,7 @@ class Battle::Scene
pbWaitMessage
pbShowWindow(MESSAGE_BOX)
cw = @sprites["messageWindow"]
cw.text = _INTL("{1}\1",msg)
cw.text = _INTL("{1}\1", msg)
PBDebug.log(msg)
yielded = false
timer = 0.0
@@ -269,19 +269,19 @@ class Battle::Scene
end
def pbDisplayConfirmMessage(msg)
return pbShowCommands(msg,[_INTL("Yes"),_INTL("No")],1)==0
return pbShowCommands(msg, [_INTL("Yes"), _INTL("No")], 1) == 0
end
def pbShowCommands(msg,commands,defaultValue)
def pbShowCommands(msg, commands, defaultValue)
pbWaitMessage
pbShowWindow(MESSAGE_BOX)
dw = @sprites["messageWindow"]
dw.text = msg
cw = Window_CommandPokemon.new(commands)
cw.height = Graphics.height - dw.height if cw.height > Graphics.height - dw.height
cw.x = Graphics.width-cw.width
cw.y = Graphics.height-cw.height-dw.height
cw.z = dw.z+1
cw.x = Graphics.width - cw.width
cw.y = Graphics.height - cw.height - dw.height
cw.z = dw.z + 1
cw.index = 0
cw.viewport = @viewport
PBDebug.log(msg)
@@ -289,7 +289,7 @@ class Battle::Scene
cw.visible = (!dw.busy?)
pbUpdate(cw)
dw.update
if Input.trigger?(Input::BACK) && defaultValue>=0
if Input.trigger?(Input::BACK) && defaultValue >= 0
if dw.busy?
pbPlayDecisionSE if dw.pausing?
dw.resume
@@ -314,8 +314,8 @@ class Battle::Scene
#=============================================================================
# Sprites
#=============================================================================
def pbAddSprite(id,x,y,filename,viewport)
sprite = @sprites[id] || IconSprite.new(x,y,viewport)
def pbAddSprite(id, x, y, filename, viewport)
sprite = @sprites[id] || IconSprite.new(x, y, viewport)
if filename
sprite.setBitmap(filename) rescue nil
end
@@ -323,7 +323,7 @@ class Battle::Scene
return sprite
end
def pbAddPlane(id,filename,viewport)
def pbAddPlane(id, filename, viewport)
sprite = AnimatedPlane.new(viewport)
if filename
sprite.setBitmap(filename)
@@ -337,12 +337,12 @@ class Battle::Scene
end
# Used by Ally Switch.
def pbSwapBattlerSprites(idxA,idxB)
def pbSwapBattlerSprites(idxA, idxB)
@sprites["pokemon_#{idxA}"], @sprites["pokemon_#{idxB}"] = @sprites["pokemon_#{idxB}"], @sprites["pokemon_#{idxA}"]
@sprites["shadow_#{idxA}"], @sprites["shadow_#{idxB}"] = @sprites["shadow_#{idxB}"], @sprites["shadow_#{idxA}"]
@lastCmd[idxA], @lastCmd[idxB] = @lastCmd[idxB], @lastCmd[idxA]
@lastMove[idxA], @lastMove[idxB] = @lastMove[idxB], @lastMove[idxA]
[idxA,idxB].each do |i|
[idxA, idxB].each do |i|
@sprites["pokemon_#{i}"].index = i
@sprites["pokemon_#{i}"].pbSetPosition
@sprites["shadow_#{i}"].index = i
@@ -379,22 +379,22 @@ class Battle::Scene
#=============================================================================
#
#=============================================================================
def pbSelectBattler(idxBattler,selectMode = 1)
numWindows = @battle.sideSizes.max*2
def pbSelectBattler(idxBattler, selectMode = 1)
numWindows = @battle.sideSizes.max * 2
for i in 0...numWindows
sel = (idxBattler.is_a?(Array)) ? !idxBattler[i].nil? : i==idxBattler
sel = (idxBattler.is_a?(Array)) ? !idxBattler[i].nil? : i == idxBattler
selVal = (sel) ? selectMode : 0
@sprites["dataBox_#{i}"].selected = selVal if @sprites["dataBox_#{i}"]
@sprites["pokemon_#{i}"].selected = selVal if @sprites["pokemon_#{i}"]
end
end
def pbChangePokemon(idxBattler,pkmn)
def pbChangePokemon(idxBattler, pkmn)
idxBattler = idxBattler.index if idxBattler.respond_to?("index")
pkmnSprite = @sprites["pokemon_#{idxBattler}"]
shadowSprite = @sprites["shadow_#{idxBattler}"]
back = !@battle.opposes?(idxBattler)
pkmnSprite.setPokemonBitmap(pkmn,back)
pkmnSprite.setPokemonBitmap(pkmn, back)
shadowSprite.setPokemonBitmap(pkmn)
# Set visibility of battler's shadow
shadowSprite.visible = pkmn.species_data.shows_shadow? if shadowSprite && !back

View File

@@ -14,10 +14,10 @@ class Battle::Scene
# Called whenever the battle begins.
def pbStartBattle(battle)
@battle = battle
@viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport.z = 99999
@lastCmd = Array.new(@battle.battlers.length,0)
@lastMove = Array.new(@battle.battlers.length,0)
@lastCmd = Array.new(@battle.battlers.length, 0)
@lastMove = Array.new(@battle.battlers.length, 0)
pbInitSprites
pbBattleIntroAnimation
end
@@ -27,12 +27,12 @@ class Battle::Scene
# The background image and each side's base graphic
pbCreateBackdropSprites
# Create message box graphic
messageBox = pbAddSprite("messageBox",0,Graphics.height-96,
"Graphics/Pictures/Battle/overlay_message",@viewport)
messageBox = pbAddSprite("messageBox", 0, Graphics.height - 96,
"Graphics/Pictures/Battle/overlay_message", @viewport)
messageBox.z = 195
# Create message window (displays the message)
msgWindow = Window_AdvancedTextPokemon.newWithSize("",
16,Graphics.height-96+2,Graphics.width-32,96,@viewport)
16, Graphics.height - 96 + 2, Graphics.width - 32, 96, @viewport)
msgWindow.z = 200
msgWindow.opacity = 0
msgWindow.baseColor = MESSAGE_BASE_COLOR
@@ -40,52 +40,52 @@ class Battle::Scene
msgWindow.letterbyletter = true
@sprites["messageWindow"] = msgWindow
# Create command window
@sprites["commandWindow"] = CommandMenu.new(@viewport,200)
@sprites["commandWindow"] = CommandMenu.new(@viewport, 200)
# Create fight window
@sprites["fightWindow"] = FightMenu.new(@viewport,200)
@sprites["fightWindow"] = FightMenu.new(@viewport, 200)
# Create targeting window
@sprites["targetWindow"] = TargetMenu.new(@viewport,200,@battle.sideSizes)
@sprites["targetWindow"] = TargetMenu.new(@viewport, 200, @battle.sideSizes)
pbShowWindow(MESSAGE_BOX)
# The party lineup graphics (bar and balls) for both sides
for side in 0...2
partyBar = pbAddSprite("partyBar_#{side}",0,0,
"Graphics/Pictures/Battle/overlay_lineup",@viewport)
partyBar = pbAddSprite("partyBar_#{side}", 0, 0,
"Graphics/Pictures/Battle/overlay_lineup", @viewport)
partyBar.z = 120
partyBar.mirror = true if side==0 # Player's lineup bar only
partyBar.mirror = true if side == 0 # Player's lineup bar only
partyBar.visible = false
for i in 0...NUM_BALLS
ball = pbAddSprite("partyBall_#{side}_#{i}",0,0,nil,@viewport)
ball = pbAddSprite("partyBall_#{side}_#{i}", 0, 0, nil, @viewport)
ball.z = 121
ball.visible = false
end
# Ability splash bars
if USE_ABILITY_SPLASH
@sprites["abilityBar_#{side}"] = AbilitySplashBar.new(side,@viewport)
@sprites["abilityBar_#{side}"] = AbilitySplashBar.new(side, @viewport)
end
end
# Player's and partner trainer's back sprite
@battle.player.each_with_index do |p,i|
pbCreateTrainerBackSprite(i,p.trainer_type,@battle.player.length)
@battle.player.each_with_index do |p, i|
pbCreateTrainerBackSprite(i, p.trainer_type, @battle.player.length)
end
# Opposing trainer(s) sprites
if @battle.trainerBattle?
@battle.opponent.each_with_index do |p,i|
pbCreateTrainerFrontSprite(i,p.trainer_type,@battle.opponent.length)
@battle.opponent.each_with_index do |p, i|
pbCreateTrainerFrontSprite(i, p.trainer_type, @battle.opponent.length)
end
end
# Data boxes and Pokémon sprites
@battle.battlers.each_with_index do |b,i|
@battle.battlers.each_with_index do |b, i|
next if !b
@sprites["dataBox_#{i}"] = PokemonDataBox.new(b,@battle.pbSideSize(i),@viewport)
@sprites["dataBox_#{i}"] = PokemonDataBox.new(b, @battle.pbSideSize(i), @viewport)
pbCreatePokemonSprite(i)
end
# Wild battle, so set up the Pokémon sprite(s) accordingly
if @battle.wildBattle?
@battle.pbParty(1).each_with_index do |pkmn,i|
index = i*2+1
pbChangePokemon(index,pkmn)
@battle.pbParty(1).each_with_index do |pkmn, i|
index = i * 2 + 1
pbChangePokemon(index, pkmn)
pkmnSprite = @sprites["pokemon_#{index}"]
pkmnSprite.tone = Tone.new(-80,-80,-80)
pkmnSprite.tone = Tone.new(-80, -80, -80)
pkmnSprite.visible = true
end
end
@@ -99,92 +99,92 @@ class Battle::Scene
# Put everything together into backdrop, bases and message bar filenames
backdropFilename = @battle.backdrop
baseFilename = @battle.backdrop
baseFilename = sprintf("%s_%s",baseFilename,@battle.backdropBase) if @battle.backdropBase
baseFilename = sprintf("%s_%s", baseFilename, @battle.backdropBase) if @battle.backdropBase
messageFilename = @battle.backdrop
if time
trialName = sprintf("%s_%s",backdropFilename,time)
if pbResolveBitmap(sprintf("Graphics/Battlebacks/"+trialName+"_bg"))
trialName = sprintf("%s_%s", backdropFilename, time)
if pbResolveBitmap(sprintf("Graphics/Battlebacks/" + trialName + "_bg"))
backdropFilename = trialName
end
trialName = sprintf("%s_%s",baseFilename,time)
if pbResolveBitmap(sprintf("Graphics/Battlebacks/"+trialName+"_base0"))
trialName = sprintf("%s_%s", baseFilename, time)
if pbResolveBitmap(sprintf("Graphics/Battlebacks/" + trialName + "_base0"))
baseFilename = trialName
end
trialName = sprintf("%s_%s",messageFilename,time)
if pbResolveBitmap(sprintf("Graphics/Battlebacks/"+trialName+"_message"))
trialName = sprintf("%s_%s", messageFilename, time)
if pbResolveBitmap(sprintf("Graphics/Battlebacks/" + trialName + "_message"))
messageFilename = trialName
end
end
if !pbResolveBitmap(sprintf("Graphics/Battlebacks/"+baseFilename+"_base0")) &&
if !pbResolveBitmap(sprintf("Graphics/Battlebacks/" + baseFilename + "_base0")) &&
@battle.backdropBase
baseFilename = @battle.backdropBase
if time
trialName = sprintf("%s_%s",baseFilename,time)
if pbResolveBitmap(sprintf("Graphics/Battlebacks/"+trialName+"_base0"))
trialName = sprintf("%s_%s", baseFilename, time)
if pbResolveBitmap(sprintf("Graphics/Battlebacks/" + trialName + "_base0"))
baseFilename = trialName
end
end
end
# Finalise filenames
battleBG = "Graphics/Battlebacks/"+backdropFilename+"_bg"
playerBase = "Graphics/Battlebacks/"+baseFilename+"_base0"
enemyBase = "Graphics/Battlebacks/"+baseFilename+"_base1"
messageBG = "Graphics/Battlebacks/"+messageFilename+"_message"
battleBG = "Graphics/Battlebacks/" + backdropFilename + "_bg"
playerBase = "Graphics/Battlebacks/" + baseFilename + "_base0"
enemyBase = "Graphics/Battlebacks/" + baseFilename + "_base1"
messageBG = "Graphics/Battlebacks/" + messageFilename + "_message"
# Apply graphics
bg = pbAddSprite("battle_bg",0,0,battleBG,@viewport)
bg = pbAddSprite("battle_bg", 0, 0, battleBG, @viewport)
bg.z = 0
bg = pbAddSprite("battle_bg2",-Graphics.width,0,battleBG,@viewport)
bg = pbAddSprite("battle_bg2", -Graphics.width, 0, battleBG, @viewport)
bg.z = 0
bg.mirror = true
for side in 0...2
baseX, baseY = Battle::Scene.pbBattlerPosition(side)
base = pbAddSprite("base_#{side}",baseX,baseY,
(side==0) ? playerBase : enemyBase,@viewport)
base.z = 1
base = pbAddSprite("base_#{side}", baseX, baseY,
(side == 0) ? playerBase : enemyBase, @viewport)
base.z = 1
if base.bitmap
base.ox = base.bitmap.width/2
base.oy = (side==0) ? base.bitmap.height : base.bitmap.height/2
base.ox = base.bitmap.width / 2
base.oy = (side == 0) ? base.bitmap.height : base.bitmap.height / 2
end
end
cmdBarBG = pbAddSprite("cmdBar_bg",0,Graphics.height-96,messageBG,@viewport)
cmdBarBG = pbAddSprite("cmdBar_bg", 0, Graphics.height - 96, messageBG, @viewport)
cmdBarBG.z = 180
end
def pbCreateTrainerBackSprite(idxTrainer,trainerType,numTrainers = 1)
if idxTrainer==0 # Player's sprite
def pbCreateTrainerBackSprite(idxTrainer, trainerType, numTrainers = 1)
if idxTrainer == 0 # Player's sprite
trainerFile = GameData::TrainerType.player_back_sprite_filename(trainerType)
else # Partner trainer's sprite
trainerFile = GameData::TrainerType.back_sprite_filename(trainerType)
end
spriteX, spriteY = Battle::Scene.pbTrainerPosition(0,idxTrainer,numTrainers)
trainer = pbAddSprite("player_#{idxTrainer+1}",spriteX,spriteY,trainerFile,@viewport)
spriteX, spriteY = Battle::Scene.pbTrainerPosition(0, idxTrainer, numTrainers)
trainer = pbAddSprite("player_#{idxTrainer + 1}", spriteX, spriteY, trainerFile, @viewport)
return if !trainer.bitmap
# Alter position of sprite
trainer.z = 80+idxTrainer
if trainer.bitmap.width>trainer.bitmap.height*2
trainer.z = 80 + idxTrainer
if trainer.bitmap.width > trainer.bitmap.height * 2
trainer.src_rect.x = 0
trainer.src_rect.width = trainer.bitmap.width/5
trainer.src_rect.width = trainer.bitmap.width / 5
end
trainer.ox = trainer.src_rect.width/2
trainer.ox = trainer.src_rect.width / 2
trainer.oy = trainer.bitmap.height
end
def pbCreateTrainerFrontSprite(idxTrainer,trainerType,numTrainers = 1)
def pbCreateTrainerFrontSprite(idxTrainer, trainerType, numTrainers = 1)
trainerFile = GameData::TrainerType.front_sprite_filename(trainerType)
spriteX, spriteY = Battle::Scene.pbTrainerPosition(1,idxTrainer,numTrainers)
trainer = pbAddSprite("trainer_#{idxTrainer+1}",spriteX,spriteY,trainerFile,@viewport)
spriteX, spriteY = Battle::Scene.pbTrainerPosition(1, idxTrainer, numTrainers)
trainer = pbAddSprite("trainer_#{idxTrainer + 1}", spriteX, spriteY, trainerFile, @viewport)
return if !trainer.bitmap
# Alter position of sprite
trainer.z = 7+idxTrainer
trainer.ox = trainer.src_rect.width/2
trainer.z = 7 + idxTrainer
trainer.ox = trainer.src_rect.width / 2
trainer.oy = trainer.bitmap.height
end
def pbCreatePokemonSprite(idxBattler)
sideSize = @battle.pbSideSize(idxBattler)
batSprite = BattlerSprite.new(@viewport,sideSize,idxBattler,@animations)
batSprite = BattlerSprite.new(@viewport, sideSize, idxBattler, @animations)
@sprites["pokemon_#{idxBattler}"] = batSprite
shaSprite = BattlerShadowSprite.new(@viewport,sideSize,idxBattler)
shaSprite = BattlerShadowSprite.new(@viewport, sideSize, idxBattler)
shaSprite.visible = false
@sprites["shadow_#{idxBattler}"] = shaSprite
end

View File

@@ -3,18 +3,18 @@ class Battle::Scene
# The player chooses a main command for a Pokémon
# Return values: -1=Cancel, 0=Fight, 1=Bag, 2=Pokémon, 3=Run, 4=Call
#=============================================================================
def pbCommandMenu(idxBattler,firstAction)
def pbCommandMenu(idxBattler, firstAction)
shadowTrainer = (GameData::Type.exists?(:SHADOW) && @battle.trainerBattle?)
cmds = [
_INTL("What will\n{1} do?",@battle.battlers[idxBattler].name),
_INTL("What will\n{1} do?", @battle.battlers[idxBattler].name),
_INTL("Fight"),
_INTL("Bag"),
_INTL("Pokémon"),
(shadowTrainer) ? _INTL("Call") : (firstAction) ? _INTL("Run") : _INTL("Cancel")
]
ret = pbCommandMenuEx(idxBattler,cmds,(shadowTrainer) ? 2 : (firstAction) ? 0 : 1)
ret = 4 if ret==3 && shadowTrainer # Convert "Run" to "Call"
ret = -1 if ret==3 && !firstAction # Convert "Run" to "Cancel"
ret = pbCommandMenuEx(idxBattler, cmds, (shadowTrainer) ? 2 : (firstAction) ? 0 : 1)
ret = 4 if ret == 3 && shadowTrainer # Convert "Run" to "Call"
ret = -1 if ret == 3 && !firstAction # Convert "Run" to "Cancel"
return ret
end
@@ -23,11 +23,11 @@ class Battle::Scene
# 2 = regular battle with "Call" (for Shadow Pokémon battles)
# 3 = Safari Zone
# 4 = Bug Catching Contest
def pbCommandMenuEx(idxBattler,texts,mode = 0)
def pbCommandMenuEx(idxBattler, texts, mode = 0)
pbShowWindow(COMMAND_BOX)
cw = @sprites["commandWindow"]
cw.setTexts(texts)
cw.setIndexAndMode(@lastCmd[idxBattler],mode)
cw.setIndexAndMode(@lastCmd[idxBattler], mode)
pbSelectBattler(idxBattler)
ret = -1
loop do
@@ -35,22 +35,22 @@ class Battle::Scene
pbUpdate(cw)
# Update selected command
if Input.trigger?(Input::LEFT)
cw.index -= 1 if (cw.index&1)==1
cw.index -= 1 if (cw.index & 1) == 1
elsif Input.trigger?(Input::RIGHT)
cw.index += 1 if (cw.index&1)==0
cw.index += 1 if (cw.index & 1) == 0
elsif Input.trigger?(Input::UP)
cw.index -= 2 if (cw.index&2)==2
cw.index -= 2 if (cw.index & 2) == 2
elsif Input.trigger?(Input::DOWN)
cw.index += 2 if (cw.index&2)==0
cw.index += 2 if (cw.index & 2) == 0
end
pbPlayCursorSE if cw.index!=oldIndex
pbPlayCursorSE if cw.index != oldIndex
# Actions
if Input.trigger?(Input::USE) # Confirm choice
pbPlayDecisionSE
ret = cw.index
@lastCmd[idxBattler] = ret
break
elsif Input.trigger?(Input::BACK) && mode==1 # Cancel
elsif Input.trigger?(Input::BACK) && mode == 1 # Cancel
pbPlayCancelSE
break
elsif Input.trigger?(Input::F9) && $DEBUG # Debug menu
@@ -65,7 +65,7 @@ class Battle::Scene
#=============================================================================
# The player chooses a move for a Pokémon to use
#=============================================================================
def pbFightMenu(idxBattler,megaEvoPossible = false)
def pbFightMenu(idxBattler, megaEvoPossible = false)
battler = @battle.battlers[idxBattler]
cw = @sprites["fightWindow"]
cw.battler = battler
@@ -74,7 +74,7 @@ class Battle::Scene
moveIndex = @lastMove[idxBattler]
end
cw.shiftMode = (@battle.pbCanShift?(idxBattler)) ? 1 : 0
cw.setIndexAndMode(moveIndex,(megaEvoPossible) ? 1 : 0)
cw.setIndexAndMode(moveIndex, (megaEvoPossible) ? 1 : 0)
needFullRefresh = true
needRefresh = false
loop do
@@ -87,7 +87,7 @@ class Battle::Scene
if needRefresh
if megaEvoPossible
newMode = (@battle.pbRegisteredMegaEvolution?(idxBattler)) ? 2 : 1
cw.mode = newMode if newMode!=cw.mode
cw.mode = newMode if newMode != cw.mode
end
needRefresh = false
end
@@ -96,19 +96,19 @@ class Battle::Scene
pbUpdate(cw)
# Update selected command
if Input.trigger?(Input::LEFT)
cw.index -= 1 if (cw.index&1)==1
cw.index -= 1 if (cw.index & 1) == 1
elsif Input.trigger?(Input::RIGHT)
if battler.moves[cw.index+1] && battler.moves[cw.index+1].id
cw.index += 1 if (cw.index&1)==0
if battler.moves[cw.index + 1] && battler.moves[cw.index + 1].id
cw.index += 1 if (cw.index & 1) == 0
end
elsif Input.trigger?(Input::UP)
cw.index -= 2 if (cw.index&2)==2
cw.index -= 2 if (cw.index & 2) == 2
elsif Input.trigger?(Input::DOWN)
if battler.moves[cw.index+2] && battler.moves[cw.index+2].id
cw.index += 2 if (cw.index&2)==0
if battler.moves[cw.index + 2] && battler.moves[cw.index + 2].id
cw.index += 2 if (cw.index & 2) == 0
end
end
pbPlayCursorSE if cw.index!=oldIndex
pbPlayCursorSE if cw.index != oldIndex
# Actions
if Input.trigger?(Input::USE) # Confirm choice
pbPlayDecisionSE
@@ -126,7 +126,7 @@ class Battle::Scene
needRefresh = true
end
elsif Input.trigger?(Input::SPECIAL) # Shift
if cw.shiftMode>0
if cw.shiftMode > 0
pbPlayDecisionSE
break if yield -3
needRefresh = true
@@ -140,7 +140,7 @@ class Battle::Scene
# Opens the party screen to choose a Pokémon to switch in (or just view its
# summary screens)
#=============================================================================
def pbPartyScreen(idxBattler,canCancel = false)
def pbPartyScreen(idxBattler, canCancel = false)
# Fade out and hide all sprites
visibleSprites = pbFadeOutAndHide(@sprites)
# Get player's party
@@ -149,14 +149,14 @@ class Battle::Scene
modParty = @battle.pbPlayerDisplayParty(idxBattler)
# Start party screen
scene = PokemonParty_Scene.new
switchScreen = PokemonPartyScreen.new(scene,modParty)
switchScreen.pbStartScene(_INTL("Choose a Pokémon."),@battle.pbNumPositions(0,0))
switchScreen = PokemonPartyScreen.new(scene, modParty)
switchScreen.pbStartScene(_INTL("Choose a Pokémon."), @battle.pbNumPositions(0, 0))
# Loop while in party screen
loop do
# Select a Pokémon
scene.pbSetHelpText(_INTL("Choose a Pokémon."))
idxParty = switchScreen.pbChoosePokemon
if idxParty<0
if idxParty < 0
next if !canCancel
break
end
@@ -167,29 +167,29 @@ class Battle::Scene
commands[cmdSwitch = commands.length] = _INTL("Switch In") if modParty[idxParty].able?
commands[cmdSummary = commands.length] = _INTL("Summary")
commands[commands.length] = _INTL("Cancel")
command = scene.pbShowCommands(_INTL("Do what with {1}?",modParty[idxParty].name),commands)
if cmdSwitch>=0 && command==cmdSwitch # Switch In
command = scene.pbShowCommands(_INTL("Do what with {1}?", modParty[idxParty].name), commands)
if cmdSwitch >= 0 && command == cmdSwitch # Switch In
idxPartyRet = -1
partyPos.each_with_index do |pos,i|
next if pos!=idxParty+partyStart
partyPos.each_with_index do |pos, i|
next if pos != idxParty + partyStart
idxPartyRet = i
break
end
break if yield idxPartyRet, switchScreen
elsif cmdSummary>=0 && command==cmdSummary # Summary
scene.pbSummary(idxParty,true)
elsif cmdSummary >= 0 && command == cmdSummary # Summary
scene.pbSummary(idxParty, true)
end
end
# Close party screen
switchScreen.pbEndScene
# Fade back into battle screen
pbFadeInAndShow(@sprites,visibleSprites)
pbFadeInAndShow(@sprites, visibleSprites)
end
#=============================================================================
# Opens the Bag screen and chooses an item to use
#=============================================================================
def pbItemMenu(idxBattler,_firstAction)
def pbItemMenu(idxBattler, _firstAction)
# Fade out and hide all sprites
visibleSprites = pbFadeOutAndHide(@sprites)
# Set Bag starting positions
@@ -216,10 +216,10 @@ class Battle::Scene
useType = item.battle_use
cmdUse = -1
commands = []
commands[cmdUse = commands.length] = _INTL("Use") if useType && useType!=0
commands[cmdUse = commands.length] = _INTL("Use") if useType && useType != 0
commands[commands.length] = _INTL("Cancel")
command = itemScene.pbShowCommands(_INTL("{1} is selected.",itemName),commands)
next unless cmdUse>=0 && command==cmdUse # Use
command = itemScene.pbShowCommands(_INTL("{1} is selected.", itemName), commands)
next unless cmdUse >= 0 && command == cmdUse # Use
# Use types:
# 0 = not usable in battle
# 1 = use on Pokémon (lots of items, Blue Flute)
@@ -233,11 +233,11 @@ class Battle::Scene
# are the only available Pokémon/battler to use the item on
case useType
when 1 # Use on Pokémon
if @battle.pbTeamLengthFromBattlerIndex(idxBattler)==1
if @battle.pbTeamLengthFromBattlerIndex(idxBattler) == 1
break if yield item.id, useType, @battle.battlers[idxBattler].pokemonIndex, -1, itemScene
end
when 3 # Use on battler
if @battle.pbPlayerBattlerCount==1
if @battle.pbPlayerBattlerCount == 1
break if yield item.id, useType, @battle.battlers[idxBattler].pokemonIndex, -1, itemScene
end
end
@@ -250,38 +250,38 @@ class Battle::Scene
modParty = @battle.pbPlayerDisplayParty(idxBattler)
# Start party screen
pkmnScene = PokemonParty_Scene.new
pkmnScreen = PokemonPartyScreen.new(pkmnScene,modParty)
pkmnScreen.pbStartScene(_INTL("Use on which Pokémon?"),@battle.pbNumPositions(0,0))
pkmnScreen = PokemonPartyScreen.new(pkmnScene, modParty)
pkmnScreen.pbStartScene(_INTL("Use on which Pokémon?"), @battle.pbNumPositions(0, 0))
idxParty = -1
# Loop while in party screen
loop do
# Select a Pokémon
pkmnScene.pbSetHelpText(_INTL("Use on which Pokémon?"))
idxParty = pkmnScreen.pbChoosePokemon
break if idxParty<0
break if idxParty < 0
idxPartyRet = -1
partyPos.each_with_index do |pos,i|
next if pos!=idxParty+partyStart
partyPos.each_with_index do |pos, i|
next if pos != idxParty + partyStart
idxPartyRet = i
break
end
next if idxPartyRet<0
next if idxPartyRet < 0
pkmn = party[idxPartyRet]
next if !pkmn || pkmn.egg?
idxMove = -1
if useType==2 # Use on Pokémon's move
idxMove = pkmnScreen.pbChooseMove(pkmn,_INTL("Restore which move?"))
next if idxMove<0
if useType == 2 # Use on Pokémon's move
idxMove = pkmnScreen.pbChooseMove(pkmn, _INTL("Restore which move?"))
next if idxMove < 0
end
break if yield item.id, useType, idxPartyRet, idxMove, pkmnScene
end
pkmnScene.pbEndScene
break if idxParty>=0
break if idxParty >= 0
# Cancelled choosing a Pokémon; show the Bag screen again
itemScene.pbFadeInScene
when 4 # Use on opposing battler (Poké Balls)
idxTarget = -1
if @battle.pbOpposingBattlerCount(idxBattler)==1
if @battle.pbOpposingBattlerCount(idxBattler) == 1
@battle.allOtherSideBattlers(idxBattler).each { |b| idxTarget = b.index }
break if yield item.id, useType, idxTarget, -1, itemScene
else
@@ -292,8 +292,8 @@ class Battle::Scene
tempVisibleSprites = visibleSprites.clone
tempVisibleSprites["commandWindow"] = false
tempVisibleSprites["targetWindow"] = true
idxTarget = pbChooseTarget(idxBattler,GameData::Target.get(:Foe),tempVisibleSprites)
if idxTarget>=0
idxTarget = pbChooseTarget(idxBattler, GameData::Target.get(:Foe), tempVisibleSprites)
if idxTarget >= 0
break if yield item.id, useType, idxTarget, -1, self
end
# Target invalid/cancelled choosing a target; show the Bag screen again
@@ -312,7 +312,7 @@ class Battle::Scene
# Close Bag screen
itemScene.pbEndScene
# Fade back into battle screen (if not already showing it)
pbFadeInAndShow(@sprites,visibleSprites) if !wasTargeting
pbFadeInAndShow(@sprites, visibleSprites) if !wasTargeting
end
#=============================================================================
@@ -322,7 +322,7 @@ class Battle::Scene
# target.
# nil means can't select that position, "" means can select that position but
# there is no battler there, otherwise is a battler's name.
def pbCreateTargetTexts(idxBattler,target_data)
def pbCreateTargetTexts(idxBattler, target_data)
texts = Array.new(@battle.battlers.length) do |i|
next nil if !@battle.battlers[i]
showName = false
@@ -331,15 +331,15 @@ class Battle::Scene
# other targets are handled by the "else" part.
case target_data.id
when :None, :User, :RandomNearFoe
showName = (i==idxBattler)
showName = (i == idxBattler)
when :UserSide
showName = !@battle.opposes?(i,idxBattler)
showName = !@battle.opposes?(i, idxBattler)
when :FoeSide
showName = @battle.opposes?(i,idxBattler)
showName = @battle.opposes?(i, idxBattler)
when :BothSides
showName = true
else
showName = @battle.pbMoveCanTarget?(i,idxBattler,target_data)
showName = @battle.pbMoveCanTarget?(i, idxBattler, target_data)
end
next nil if !showName
next (@battle.battlers[i].fainted?) ? "" : @battle.battlers[i].name
@@ -349,22 +349,22 @@ class Battle::Scene
# Returns the initial position of the cursor when choosing a target for a move
# in a non-single battle.
def pbFirstTarget(idxBattler,target_data)
def pbFirstTarget(idxBattler, target_data)
case target_data.id
when :NearAlly
@battle.allSameSideBattlers(idxBattler).each do |b|
next if b.index==idxBattler || !@battle.nearBattlers?(b,idxBattler)
next if b.index == idxBattler || !@battle.nearBattlers?(b, idxBattler)
next if b.fainted?
return b.index
end
@battle.allSameSideBattlers(idxBattler).each do |b|
next if b.index==idxBattler || !@battle.nearBattlers?(b,idxBattler)
next if b.index == idxBattler || !@battle.nearBattlers?(b, idxBattler)
return b.index
end
when :NearFoe, :NearOther
indices = @battle.pbGetOpposingIndicesInOrder(idxBattler)
indices.each { |i| return i if @battle.nearBattlers?(i,idxBattler) && !@battle.battlers[i].fainted? }
indices.each { |i| return i if @battle.nearBattlers?(i,idxBattler) }
indices.each { |i| return i if @battle.nearBattlers?(i, idxBattler) && !@battle.battlers[i].fainted? }
indices.each { |i| return i if @battle.nearBattlers?(i, idxBattler) }
when :Foe, :Other
indices = @battle.pbGetOpposingIndicesInOrder(idxBattler)
indices.each { |i| return i if !@battle.battlers[i].fainted? }
@@ -373,37 +373,37 @@ class Battle::Scene
return idxBattler # Target the user initially
end
def pbChooseTarget(idxBattler,target_data,visibleSprites = nil)
def pbChooseTarget(idxBattler, target_data, visibleSprites = nil)
pbShowWindow(TARGET_BOX)
cw = @sprites["targetWindow"]
# Create an array of battler names (only valid targets are named)
texts = pbCreateTargetTexts(idxBattler,target_data)
texts = pbCreateTargetTexts(idxBattler, target_data)
# Determine mode based on target_data
mode = (target_data.num_targets == 1) ? 0 : 1
cw.setDetails(texts,mode)
cw.index = pbFirstTarget(idxBattler,target_data)
pbSelectBattler((mode==0) ? cw.index : texts,2) # Select initial battler/data box
pbFadeInAndShow(@sprites,visibleSprites) if visibleSprites
cw.setDetails(texts, mode)
cw.index = pbFirstTarget(idxBattler, target_data)
pbSelectBattler((mode == 0) ? cw.index : texts, 2) # Select initial battler/data box
pbFadeInAndShow(@sprites, visibleSprites) if visibleSprites
ret = -1
loop do
oldIndex = cw.index
pbUpdate(cw)
# Update selected command
if mode==0 # Choosing just one target, can change index
if mode == 0 # Choosing just one target, can change index
if Input.trigger?(Input::LEFT) || Input.trigger?(Input::RIGHT)
inc = ((cw.index%2)==0) ? -2 : 2
inc = ((cw.index % 2) == 0) ? -2 : 2
inc *= -1 if Input.trigger?(Input::RIGHT)
indexLength = @battle.sideSizes[cw.index%2]*2
indexLength = @battle.sideSizes[cw.index % 2] * 2
newIndex = cw.index
loop do
newIndex += inc
break if newIndex<0 || newIndex>=indexLength
break if newIndex < 0 || newIndex >= indexLength
next if texts[newIndex].nil?
cw.index = newIndex
break
end
elsif (Input.trigger?(Input::UP) && (cw.index%2)==0) ||
(Input.trigger?(Input::DOWN) && (cw.index%2)==1)
elsif (Input.trigger?(Input::UP) && (cw.index % 2) == 0) ||
(Input.trigger?(Input::DOWN) && (cw.index % 2) == 1)
tryIndex = @battle.pbGetOpposingIndicesInOrder(cw.index)
tryIndex.each do |idxBattlerTry|
next if texts[idxBattlerTry].nil?
@@ -411,9 +411,9 @@ class Battle::Scene
break
end
end
if cw.index!=oldIndex
if cw.index != oldIndex
pbPlayCursorSE
pbSelectBattler(cw.index,2) # Select the new battler/data box
pbSelectBattler(cw.index, 2) # Select the new battler/data box
end
end
if Input.trigger?(Input::USE) # Confirm
@@ -436,12 +436,12 @@ class Battle::Scene
# Called whenever a Pokémon should forget a move. It should return -1 if the
# selection is canceled, or 0 to 3 to indicate the move to forget. It should
# not allow HM moves to be forgotten.
def pbForgetMove(pkmn,moveToLearn)
def pbForgetMove(pkmn, moveToLearn)
ret = -1
pbFadeOutIn {
scene = PokemonSummary_Scene.new
screen = PokemonSummaryScreen.new(scene)
ret = screen.pbStartForgetScreen([pkmn],0,moveToLearn)
ret = screen.pbStartForgetScreen([pkmn], 0, moveToLearn)
}
return ret
end
@@ -449,7 +449,7 @@ class Battle::Scene
#=============================================================================
# Opens the nicknaming screen for a newly caught Pokémon
#=============================================================================
def pbNameEntry(helpText,pkmn)
def pbNameEntry(helpText, pkmn)
return pbEnterPokemonName(helpText, 0, Pokemon::MAX_NAME_SIZE, "", pkmn)
end

View File

@@ -4,7 +4,7 @@ class Battle::Scene
#=============================================================================
def pbBattleIntroAnimation
# Make everything appear
introAnim = Animation::Intro.new(@sprites,@viewport,@battle)
introAnim = Animation::Intro.new(@sprites, @viewport, @battle)
loop do
introAnim.update
pbUpdate
@@ -19,8 +19,8 @@ class Battle::Scene
# entrance animation. Be sure to set it up like a Pokémon entrance
# animation, i.e. add them to @animations so that they can play out
# while party lineups appear and messages show.
pbShowPartyLineup(0,true)
pbShowPartyLineup(1,true)
pbShowPartyLineup(0, true)
pbShowPartyLineup(1, true)
return
end
# Wild battle: play wild Pokémon's intro animations (including cry), show
@@ -28,14 +28,14 @@ class Battle::Scene
# shiny animation(s)
# Set up data box animation
for i in 0...@battle.sideSizes[1]
idxBattler = 2*i+1
idxBattler = 2 * i + 1
next if !@battle.battlers[idxBattler]
dataBoxAnim = Animation::DataBoxAppear.new(@sprites,@viewport,idxBattler)
dataBoxAnim = Animation::DataBoxAppear.new(@sprites, @viewport, idxBattler)
@animations.push(dataBoxAnim)
end
# Set up wild Pokémon returning to normal colour and playing intro
# animations (including cry)
@animations.push(Animation::Intro2.new(@sprites,@viewport,@battle.sideSizes[1]))
@animations.push(Animation::Intro2.new(@sprites, @viewport, @battle.sideSizes[1]))
# Play all the animations
while inPartyAnimation?
pbUpdate
@@ -43,7 +43,7 @@ class Battle::Scene
# Show shiny animation for wild Pokémon
if @battle.showAnims
for i in 0...@battle.sideSizes[1]
idxBattler = 2*i+1
idxBattler = 2 * i + 1
next if !@battle.battlers[idxBattler] || !@battle.battlers[idxBattler].shiny?
if Settings::SUPER_SHINY && @battle.battlers[idxBattler].super_shiny?
pbCommonAnimation("SuperShiny", @battle.battlers[idxBattler])
@@ -57,9 +57,9 @@ class Battle::Scene
#=============================================================================
# Animates a party lineup appearing for the given side
#=============================================================================
def pbShowPartyLineup(side,fullAnim = false)
@animations.push(Animation::LineupAppear.new(@sprites,@viewport,
side,@battle.pbParty(side),@battle.pbPartyStarts(side),fullAnim))
def pbShowPartyLineup(side, fullAnim = false)
@animations.push(Animation::LineupAppear.new(@sprites, @viewport,
side, @battle.pbParty(side), @battle.pbPartyStarts(side), fullAnim))
if !fullAnim
while inPartyAnimation?
pbUpdate
@@ -74,7 +74,7 @@ class Battle::Scene
#=============================================================================
def pbShowOpponent(idxTrainer)
# Set up trainer appearing animation
appearAnim = Animation::TrainerAppear.new(@sprites,@viewport,idxTrainer)
appearAnim = Animation::TrainerAppear.new(@sprites, @viewport, idxTrainer)
@animations.push(appearAnim)
# Play the animation
while inPartyAnimation?
@@ -88,8 +88,8 @@ class Battle::Scene
# animation for it if relevant.
# sendOuts is an array; each element is itself an array: [idxBattler,pkmn]
#=============================================================================
def pbSendOutBattlers(sendOuts,startBattle = false)
return if sendOuts.length==0
def pbSendOutBattlers(sendOuts, startBattle = false)
return if sendOuts.length == 0
# If party balls are still appearing, wait for them to finish showing up, as
# the FadeAnimation will make them disappear.
while inPartyAnimation?
@@ -99,29 +99,29 @@ class Battle::Scene
# Make all trainers and party lineups disappear (player-side trainers may
# animate throwing a Poké Ball)
if @battle.opposes?(sendOuts[0][0])
fadeAnim = Animation::TrainerFade.new(@sprites,@viewport,startBattle)
fadeAnim = Animation::TrainerFade.new(@sprites, @viewport, startBattle)
else
fadeAnim = Animation::PlayerFade.new(@sprites,@viewport,startBattle)
fadeAnim = Animation::PlayerFade.new(@sprites, @viewport, startBattle)
end
# For each battler being sent out, set the battler's sprite and create two
# animations (the Poké Ball moving and battler appearing from it, and its
# data box appearing)
sendOutAnims = []
sendOuts.each_with_index do |b,i|
sendOuts.each_with_index do |b, i|
pkmn = @battle.battlers[b[0]].effects[PBEffects::Illusion] || b[1]
pbChangePokemon(b[0],pkmn)
pbChangePokemon(b[0], pkmn)
pbRefresh
if @battle.opposes?(b[0])
sendOutAnim = Animation::PokeballTrainerSendOut.new(@sprites,@viewport,
@battle.pbGetOwnerIndexFromBattlerIndex(b[0])+1,
@battle.battlers[b[0]],startBattle,i)
sendOutAnim = Animation::PokeballTrainerSendOut.new(@sprites, @viewport,
@battle.pbGetOwnerIndexFromBattlerIndex(b[0]) + 1,
@battle.battlers[b[0]], startBattle, i)
else
sendOutAnim = Animation::PokeballPlayerSendOut.new(@sprites,@viewport,
@battle.pbGetOwnerIndexFromBattlerIndex(b[0])+1,
@battle.battlers[b[0]],startBattle,i)
sendOutAnim = Animation::PokeballPlayerSendOut.new(@sprites, @viewport,
@battle.pbGetOwnerIndexFromBattlerIndex(b[0]) + 1,
@battle.battlers[b[0]], startBattle, i)
end
dataBoxAnim = Animation::DataBoxAppear.new(@sprites,@viewport,b[0])
sendOutAnims.push([sendOutAnim,dataBoxAnim,false])
dataBoxAnim = Animation::DataBoxAppear.new(@sprites, @viewport, b[0])
sendOutAnims.push([sendOutAnim, dataBoxAnim, false])
end
# Play all animations
loop do
@@ -159,7 +159,7 @@ class Battle::Scene
def pbRecall(idxBattler)
@briefMessage = false
# Recall animation
recallAnim = Animation::BattlerRecall.new(@sprites,@viewport,idxBattler)
recallAnim = Animation::BattlerRecall.new(@sprites, @viewport, idxBattler)
loop do
recallAnim.update if recallAnim
pbUpdate
@@ -167,7 +167,7 @@ class Battle::Scene
end
recallAnim.dispose
# Data box disappear animation
dataBoxAnim = Animation::DataBoxDisappear.new(@sprites,@viewport,idxBattler)
dataBoxAnim = Animation::DataBoxDisappear.new(@sprites, @viewport, idxBattler)
loop do
dataBoxAnim.update
pbUpdate
@@ -181,10 +181,10 @@ class Battle::Scene
#=============================================================================
def pbShowAbilitySplash(battler)
return if !USE_ABILITY_SPLASH
side = battler.index%2
side = battler.index % 2
pbHideAbilitySplash(battler) if @sprites["abilityBar_#{side}"].visible
@sprites["abilityBar_#{side}"].battler = battler
abilitySplashAnim = Animation::AbilitySplashAppear.new(@sprites,@viewport,side)
abilitySplashAnim = Animation::AbilitySplashAppear.new(@sprites, @viewport, side)
loop do
abilitySplashAnim.update
pbUpdate
@@ -195,9 +195,9 @@ class Battle::Scene
def pbHideAbilitySplash(battler)
return if !USE_ABILITY_SPLASH
side = battler.index%2
side = battler.index % 2
return if !@sprites["abilityBar_#{side}"].visible
abilitySplashAnim = Animation::AbilitySplashDisappear.new(@sprites,@viewport,side)
abilitySplashAnim = Animation::AbilitySplashDisappear.new(@sprites, @viewport, side)
loop do
abilitySplashAnim.update
pbUpdate
@@ -216,23 +216,23 @@ class Battle::Scene
#=============================================================================
# Shows a HP-changing common animation and animates a data box's HP bar.
# Called by def pbReduceHP, def pbRecoverHP.
def pbHPChanged(battler,oldHP,showAnim = false)
def pbHPChanged(battler, oldHP, showAnim = false)
@briefMessage = false
if battler.hp>oldHP
pbCommonAnimation("HealthUp",battler) if showAnim && @battle.showAnims
elsif battler.hp<oldHP
pbCommonAnimation("HealthDown",battler) if showAnim && @battle.showAnims
if battler.hp > oldHP
pbCommonAnimation("HealthUp", battler) if showAnim && @battle.showAnims
elsif battler.hp < oldHP
pbCommonAnimation("HealthDown", battler) if showAnim && @battle.showAnims
end
@sprites["dataBox_#{battler.index}"].animateHP(oldHP,battler.hp,battler.totalhp)
@sprites["dataBox_#{battler.index}"].animateHP(oldHP, battler.hp, battler.totalhp)
while @sprites["dataBox_#{battler.index}"].animatingHP
pbUpdate
end
end
def pbDamageAnimation(battler,effectiveness = 0)
def pbDamageAnimation(battler, effectiveness = 0)
@briefMessage = false
# Damage animation
damageAnim = Animation::BattlerDamage.new(@sprites,@viewport,battler.index,effectiveness)
damageAnim = Animation::BattlerDamage.new(@sprites, @viewport, battler.index, effectiveness)
loop do
damageAnim.update
pbUpdate
@@ -249,9 +249,9 @@ class Battle::Scene
# Set up animations
damageAnims = []
targets.each do |t|
anim = Animation::BattlerDamage.new(@sprites,@viewport,t[0].index,t[2])
anim = Animation::BattlerDamage.new(@sprites, @viewport, t[0].index, t[2])
damageAnims.push(anim)
@sprites["dataBox_#{t[0].index}"].animateHP(t[1],t[0].hp,t[0].totalhp)
@sprites["dataBox_#{t[0].index}"].animateHP(t[1], t[0].hp, t[0].totalhp)
end
# Update loop
loop do
@@ -278,13 +278,13 @@ class Battle::Scene
#=============================================================================
# Animates a data box's Exp bar
#=============================================================================
def pbEXPBar(battler,startExp,endExp,tempExp1,tempExp2)
def pbEXPBar(battler, startExp, endExp, tempExp1, tempExp2)
return if !battler || endExp == startExp
startExpLevel = tempExp1-startExp
endExpLevel = tempExp2-startExp
expRange = endExp-startExp
startExpLevel = tempExp1 - startExp
endExpLevel = tempExp2 - startExp
expRange = endExp - startExp
dataBox = @sprites["dataBox_#{battler.index}"]
dataBox.animateExp(startExpLevel,endExpLevel,expRange)
dataBox.animateExp(startExpLevel, endExpLevel, expRange)
while dataBox.animatingExp
pbUpdate
end
@@ -293,14 +293,14 @@ class Battle::Scene
#=============================================================================
# Shows stats windows upon a Pokémon levelling up
#=============================================================================
def pbLevelUp(pkmn,_battler,oldTotalHP,oldAttack,oldDefense,oldSpAtk,oldSpDef,oldSpeed)
def pbLevelUp(pkmn, _battler, oldTotalHP, oldAttack, oldDefense, oldSpAtk, oldSpDef, oldSpeed)
pbTopRightWindow(
_INTL("Max. HP<r>+{1}\r\nAttack<r>+{2}\r\nDefense<r>+{3}\r\nSp. Atk<r>+{4}\r\nSp. Def<r>+{5}\r\nSpeed<r>+{6}",
pkmn.totalhp-oldTotalHP,pkmn.attack-oldAttack,pkmn.defense-oldDefense,
pkmn.spatk-oldSpAtk,pkmn.spdef-oldSpDef,pkmn.speed-oldSpeed))
pkmn.totalhp - oldTotalHP, pkmn.attack - oldAttack, pkmn.defense - oldDefense,
pkmn.spatk - oldSpAtk, pkmn.spdef - oldSpDef, pkmn.speed - oldSpeed))
pbTopRightWindow(
_INTL("Max. HP<r>{1}\r\nAttack<r>{2}\r\nDefense<r>{3}\r\nSp. Atk<r>{4}\r\nSp. Def<r>{5}\r\nSpeed<r>{6}",
pkmn.totalhp,pkmn.attack,pkmn.defense,pkmn.spatk,pkmn.spdef,pkmn.speed))
pkmn.totalhp, pkmn.attack, pkmn.defense, pkmn.spatk, pkmn.spdef, pkmn.speed))
end
#=============================================================================
@@ -309,8 +309,8 @@ class Battle::Scene
def pbFaintBattler(battler)
@briefMessage = false
# Pokémon plays cry and drops down, data box disappears
faintAnim = Animation::BattlerFaint.new(@sprites,@viewport,battler.index,@battle)
dataBoxAnim = Animation::DataBoxDisappear.new(@sprites,@viewport,battler.index)
faintAnim = Animation::BattlerFaint.new(@sprites, @viewport, battler.index, @battle)
dataBoxAnim = Animation::DataBoxDisappear.new(@sprites, @viewport, battler.index)
loop do
faintAnim.update
dataBoxAnim.update
@@ -324,10 +324,10 @@ class Battle::Scene
#=============================================================================
# Animates throwing a Poké Ball at a Pokémon in an attempt to catch it
#=============================================================================
def pbThrow(ball,shakes,critical,targetBattler,showPlayer = false)
def pbThrow(ball, shakes, critical, targetBattler, showPlayer = false)
@briefMessage = false
captureAnim = Animation::PokeballThrowCapture.new(@sprites,@viewport,
ball,shakes,critical,@battle.battlers[targetBattler],showPlayer)
captureAnim = Animation::PokeballThrowCapture.new(@sprites, @viewport,
ball, shakes, critical, @battle.battlers[targetBattler], showPlayer)
loop do
captureAnim.update
pbUpdate
@@ -343,7 +343,7 @@ class Battle::Scene
i = 0
loop do
pbUpdate
break if i>=Graphics.frame_rate*3.5 # 3.5 seconds
break if i >= Graphics.frame_rate * 3.5 # 3.5 seconds
i += 1
end
pbMEStop
@@ -355,20 +355,20 @@ class Battle::Scene
ball = @sprites["captureBall"]
return if !ball
# Data box disappear animation
dataBoxAnim = Animation::DataBoxDisappear.new(@sprites,@viewport,idxBattler)
dataBoxAnim = Animation::DataBoxDisappear.new(@sprites, @viewport, idxBattler)
loop do
dataBoxAnim.update
ball.opacity -= 12*20/Graphics.frame_rate if ball.opacity>0
ball.opacity -= 12 * 20 / Graphics.frame_rate if ball.opacity > 0
pbUpdate
break if dataBoxAnim.animDone? && ball.opacity<=0
break if dataBoxAnim.animDone? && ball.opacity <= 0
end
dataBoxAnim.dispose
end
def pbThrowAndDeflect(ball,idxBattler)
def pbThrowAndDeflect(ball, idxBattler)
@briefMessage = false
throwAnim = Animation::PokeballThrowDeflect.new(@sprites,@viewport,
ball,@battle.battlers[idxBattler])
throwAnim = Animation::PokeballThrowDeflect.new(@sprites, @viewport,
ball, @battle.battlers[idxBattler])
loop do
throwAnim.update
pbUpdate
@@ -403,17 +403,17 @@ class Battle::Scene
#=============================================================================
# Returns the animation ID to use for a given move/user. Returns nil if that
# move has no animations defined for it.
def pbFindMoveAnimDetails(move2anim,moveID,idxUser,hitNum = 0)
def pbFindMoveAnimDetails(move2anim, moveID, idxUser, hitNum = 0)
real_move_id = GameData::Move.get(moveID).id
noFlip = false
if (idxUser&1)==0 # On player's side
if (idxUser & 1) == 0 # On player's side
anim = move2anim[0][real_move_id]
else # On opposing side
anim = move2anim[1][real_move_id]
noFlip = true if anim
anim = move2anim[0][real_move_id] if !anim
end
return [anim+hitNum,noFlip] if anim
return [anim + hitNum, noFlip] if anim
return nil
end
@@ -483,8 +483,8 @@ class Battle::Scene
# Plays a move/common animation
#=============================================================================
# Plays a move animation.
def pbAnimation(moveID,user,targets,hitNum = 0)
animID = pbFindMoveAnimation(moveID,user.index,hitNum)
def pbAnimation(moveID, user, targets, hitNum = 0)
animID = pbFindMoveAnimation(moveID, user.index, hitNum)
return if !animID
anim = animID[0]
target = (targets && targets.is_a?(Array)) ? targets[0] : targets
@@ -492,27 +492,27 @@ class Battle::Scene
return if !animations
pbSaveShadows {
if animID[1] # On opposing side and using OppMove animation
pbAnimationCore(animations[anim],target,user,true)
pbAnimationCore(animations[anim], target, user, true)
else # On player's side, and/or using Move animation
pbAnimationCore(animations[anim],user,target)
pbAnimationCore(animations[anim], user, target)
end
}
end
# Plays a common animation.
def pbCommonAnimation(animName,user = nil,target = nil)
def pbCommonAnimation(animName, user = nil, target = nil)
return if nil_or_empty?(animName)
target = target[0] if target && target.is_a?(Array)
animations = pbLoadBattleAnimations
return if !animations
animations.each do |a|
next if !a || a.name!="Common:"+animName
pbAnimationCore(a,user,(target!=nil) ? target : user)
next if !a || a.name != "Common:" + animName
pbAnimationCore(a, user, (target != nil) ? target : user)
return
end
end
def pbAnimationCore(animation,user,target,oppMove = false)
def pbAnimationCore(animation, user, target, oppMove = false)
return if !animation
@briefMessage = false
userSprite = (user) ? @sprites["pokemon_#{user.index}"] : nil
@@ -523,7 +523,7 @@ class Battle::Scene
oldTargetX = (targetSprite) ? targetSprite.x : oldUserX
oldTargetY = (targetSprite) ? targetSprite.y : oldUserY
# Create the animation player
animPlayer = PBAnimationPlayerX.new(animation,user,target,self,oppMove)
animPlayer = PBAnimationPlayerX.new(animation, user, target, self, oppMove)
# Apply a transformation to the animation based on where the user and target
# actually are. Get the centres of each sprite.
userHeight = (userSprite && userSprite.bitmap && !userSprite.bitmap.disposed?) ? userSprite.bitmap.height : 128

View File

@@ -20,7 +20,7 @@ class Battle::Scene::MenuBase
@y = 0
@z = 0
@visible = false
@color = Color.new(0,0,0,0)
@color = Color.new(0, 0, 0, 0)
@index = 0
@mode = 0
@disposed = false
@@ -61,27 +61,27 @@ class Battle::Scene::MenuBase
oldValue = @index
@index = value
@cmdWindow.index = @index if @cmdWindow
refresh if @index!=oldValue
refresh if @index != oldValue
end
def mode=(value)
oldValue = @mode
@mode = value
refresh if @mode!=oldValue
refresh if @mode != oldValue
end
def addSprite(key,sprite)
def addSprite(key, sprite)
@sprites[key] = sprite
@visibility[key] = true
end
def setIndexAndMode(index,mode)
def setIndexAndMode(index, mode)
oldIndex = @index
oldMode = @mode
@index = index
@mode = mode
@cmdWindow.index = @index if @cmdWindow
refresh if @index!=oldIndex || @mode!=oldMode
refresh if @index != oldIndex || @mode != oldMode
end
def refresh; end
@@ -106,52 +106,52 @@ class Battle::Scene::CommandMenu < Battle::Scene::MenuBase
USE_GRAPHICS = true
# Lists of which button graphics to use in different situations/types of battle.
MODES = [
[0,2,1,3], # 0 = Regular battle
[0,2,1,9], # 1 = Regular battle with "Cancel" instead of "Run"
[0,2,1,4], # 2 = Regular battle with "Call" instead of "Run"
[5,7,6,3], # 3 = Safari Zone
[0,8,1,3] # 4 = Bug Catching Contest
[0, 2, 1, 3], # 0 = Regular battle
[0, 2, 1, 9], # 1 = Regular battle with "Cancel" instead of "Run"
[0, 2, 1, 4], # 2 = Regular battle with "Call" instead of "Run"
[5, 7, 6, 3], # 3 = Safari Zone
[0, 8, 1, 3] # 4 = Bug Catching Contest
]
def initialize(viewport,z)
def initialize(viewport, z)
super(viewport)
self.x = 0
self.y = Graphics.height-96
self.y = Graphics.height - 96
# Create message box (shows "What will X do?")
@msgBox = Window_UnformattedTextPokemon.newWithSize("",
self.x+16,self.y+2,220,Graphics.height-self.y,viewport)
self.x + 16, self.y + 2, 220, Graphics.height - self.y, viewport)
@msgBox.baseColor = TEXT_BASE_COLOR
@msgBox.shadowColor = TEXT_SHADOW_COLOR
@msgBox.windowskin = nil
addSprite("msgBox",@msgBox)
addSprite("msgBox", @msgBox)
if USE_GRAPHICS
# Create background graphic
background = IconSprite.new(self.x,self.y,viewport)
background = IconSprite.new(self.x, self.y, viewport)
background.setBitmap("Graphics/Pictures/Battle/overlay_command")
addSprite("background",background)
addSprite("background", background)
# Create bitmaps
@buttonBitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/cursor_command"))
# Create action buttons
@buttons = Array.new(4) do |i| # 4 command options, therefore 4 buttons
button = SpriteWrapper.new(viewport)
button.bitmap = @buttonBitmap.bitmap
button.x = self.x+Graphics.width-260
button.x += (((i%2)==0) ? 0 : @buttonBitmap.width/2-4)
button.y = self.y+6
button.y += (((i/2)==0) ? 0 : BUTTON_HEIGHT-4)
button.src_rect.width = @buttonBitmap.width/2
button.x = self.x + Graphics.width - 260
button.x += (i.even? ? 0 : @buttonBitmap.width / 2 - 4)
button.y = self.y + 6
button.y += (((i / 2) == 0) ? 0 : BUTTON_HEIGHT - 4)
button.src_rect.width = @buttonBitmap.width / 2
button.src_rect.height = BUTTON_HEIGHT
addSprite("button_#{i}",button)
addSprite("button_#{i}", button)
next button
end
else
# Create command window (shows Fight/Bag/Pokémon/Run)
@cmdWindow = Window_CommandPokemon.newWithSize([],
self.x+Graphics.width-240,self.y,240,Graphics.height-self.y,viewport)
self.x + Graphics.width - 240, self.y, 240, Graphics.height - self.y, viewport)
@cmdWindow.columns = 2
@cmdWindow.columnSpacing = 4
@cmdWindow.ignore_input = true
addSprite("cmdWindow",@cmdWindow)
addSprite("cmdWindow", @cmdWindow)
end
self.z = z
refresh
@@ -173,7 +173,7 @@ class Battle::Scene::CommandMenu < Battle::Scene::MenuBase
return if USE_GRAPHICS
commands = []
for i in 1..4
commands.push(value[i]) if value[i] && value[i]!=nil
commands.push(value[i]) if value[i] && value[i] != nil
end
@cmdWindow.commands = commands
end
@@ -182,9 +182,9 @@ class Battle::Scene::CommandMenu < Battle::Scene::MenuBase
return if !USE_GRAPHICS
for i in 0...@buttons.length
button = @buttons[i]
button.src_rect.x = (i==@index) ? @buttonBitmap.width/2 : 0
button.src_rect.y = MODES[@mode][i]*BUTTON_HEIGHT
button.z = self.z + ((i==@index) ? 3 : 2)
button.src_rect.x = (i == @index) ? @buttonBitmap.width / 2 : 0
button.src_rect.y = MODES[@mode][i] * BUTTON_HEIGHT
button.z = self.z + ((i == @index) ? 3 : 2)
end
end
@@ -216,16 +216,16 @@ class Battle::Scene::FightMenu < Battle::Scene::MenuBase
TYPE_ICON_HEIGHT = 28
# Text colours of PP of selected move
PP_COLORS = [
Color.new(248,72,72),Color.new(136,48,48), # Red, zero PP
Color.new(248,136,32),Color.new(144,72,24), # Orange, 1/4 of total PP or less
Color.new(248,192,0),Color.new(144,104,0), # Yellow, 1/2 of total PP or less
TEXT_BASE_COLOR,TEXT_SHADOW_COLOR # Black, more than 1/2 of total PP
Color.new(248, 72, 72), Color.new(136, 48, 48), # Red, zero PP
Color.new(248, 136, 32), Color.new(144, 72, 24), # Orange, 1/4 of total PP or less
Color.new(248, 192, 0), Color.new(144, 104, 0), # Yellow, 1/2 of total PP or less
TEXT_BASE_COLOR, TEXT_SHADOW_COLOR # Black, more than 1/2 of total PP
]
def initialize(viewport,z)
def initialize(viewport, z)
super(viewport)
self.x = 0
self.y = Graphics.height-96
self.y = Graphics.height - 96
@battler = nil
@shiftMode = 0
# NOTE: @mode is for the display of the Mega Evolution button.
@@ -237,70 +237,70 @@ class Battle::Scene::FightMenu < Battle::Scene::MenuBase
@megaEvoBitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/cursor_mega"))
@shiftBitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/cursor_shift"))
# Create background graphic
background = IconSprite.new(0,Graphics.height-96,viewport)
background = IconSprite.new(0, Graphics.height - 96, viewport)
background.setBitmap("Graphics/Pictures/Battle/overlay_fight")
addSprite("background",background)
addSprite("background", background)
# Create move buttons
@buttons = Array.new(Pokemon::MAX_MOVES) do |i|
button = SpriteWrapper.new(viewport)
button.bitmap = @buttonBitmap.bitmap
button.x = self.x+4
button.x += (((i%2)==0) ? 0 : @buttonBitmap.width/2-4)
button.y = self.y+6
button.y += (((i/2)==0) ? 0 : BUTTON_HEIGHT-4)
button.src_rect.width = @buttonBitmap.width/2
button.x = self.x + 4
button.x += (i.even? ? 0 : @buttonBitmap.width / 2 - 4)
button.y = self.y + 6
button.y += (((i / 2) == 0) ? 0 : BUTTON_HEIGHT - 4)
button.src_rect.width = @buttonBitmap.width / 2
button.src_rect.height = BUTTON_HEIGHT
addSprite("button_#{i}",button)
addSprite("button_#{i}", button)
next button
end
# Create overlay for buttons (shows move names)
@overlay = BitmapSprite.new(Graphics.width,Graphics.height-self.y,viewport)
@overlay = BitmapSprite.new(Graphics.width, Graphics.height - self.y, viewport)
@overlay.x = self.x
@overlay.y = self.y
pbSetNarrowFont(@overlay.bitmap)
addSprite("overlay",@overlay)
addSprite("overlay", @overlay)
# Create overlay for selected move's info (shows move's PP)
@infoOverlay = BitmapSprite.new(Graphics.width,Graphics.height-self.y,viewport)
@infoOverlay = BitmapSprite.new(Graphics.width, Graphics.height - self.y, viewport)
@infoOverlay.x = self.x
@infoOverlay.y = self.y
pbSetNarrowFont(@infoOverlay.bitmap)
addSprite("infoOverlay",@infoOverlay)
addSprite("infoOverlay", @infoOverlay)
# Create type icon
@typeIcon = SpriteWrapper.new(viewport)
@typeIcon.bitmap = @typeBitmap.bitmap
@typeIcon.x = self.x+416
@typeIcon.y = self.y+20
@typeIcon.x = self.x + 416
@typeIcon.y = self.y + 20
@typeIcon.src_rect.height = TYPE_ICON_HEIGHT
addSprite("typeIcon",@typeIcon)
addSprite("typeIcon", @typeIcon)
# Create Mega Evolution button
@megaButton = SpriteWrapper.new(viewport)
@megaButton.bitmap = @megaEvoBitmap.bitmap
@megaButton.x = self.x+120
@megaButton.y = self.y-@megaEvoBitmap.height/2
@megaButton.src_rect.height = @megaEvoBitmap.height/2
addSprite("megaButton",@megaButton)
@megaButton.x = self.x + 120
@megaButton.y = self.y - @megaEvoBitmap.height / 2
@megaButton.src_rect.height = @megaEvoBitmap.height / 2
addSprite("megaButton", @megaButton)
# Create Shift button
@shiftButton = SpriteWrapper.new(viewport)
@shiftButton.bitmap = @shiftBitmap.bitmap
@shiftButton.x = self.x+4
@shiftButton.y = self.y-@shiftBitmap.height
addSprite("shiftButton",@shiftButton)
@shiftButton.x = self.x + 4
@shiftButton.y = self.y - @shiftBitmap.height
addSprite("shiftButton", @shiftButton)
else
# Create message box (shows type and PP of selected move)
@msgBox = Window_AdvancedTextPokemon.newWithSize("",
self.x+320,self.y,Graphics.width-320,Graphics.height-self.y,viewport)
self.x + 320, self.y, Graphics.width - 320, Graphics.height - self.y, viewport)
@msgBox.baseColor = TEXT_BASE_COLOR
@msgBox.shadowColor = TEXT_SHADOW_COLOR
pbSetNarrowFont(@msgBox.contents)
addSprite("msgBox",@msgBox)
addSprite("msgBox", @msgBox)
# Create command window (shows moves)
@cmdWindow = Window_CommandPokemon.newWithSize([],
self.x,self.y,320,Graphics.height-self.y,viewport)
self.x, self.y, 320, Graphics.height - self.y, viewport)
@cmdWindow.columns = 2
@cmdWindow.columnSpacing = 4
@cmdWindow.ignore_input = true
pbSetNarrowFont(@cmdWindow.contents)
addSprite("cmdWindow",@cmdWindow)
addSprite("cmdWindow", @cmdWindow)
end
self.z = z
end
@@ -331,7 +331,7 @@ class Battle::Scene::FightMenu < Battle::Scene::MenuBase
def shiftMode=(value)
oldValue = @shiftMode
@shiftMode = value
refreshShiftButton if @shiftMode!=oldValue
refreshShiftButton if @shiftMode != oldValue
end
def refreshButtonNames
@@ -348,10 +348,10 @@ class Battle::Scene::FightMenu < Battle::Scene::MenuBase
# Draw move names onto overlay
@overlay.bitmap.clear
textPos = []
@buttons.each_with_index do |button,i|
@buttons.each_with_index do |button, i|
next if !@visibility["button_#{i}"]
x = button.x-self.x+button.src_rect.width/2
y = button.y-self.y+2
x = button.x - self.x + button.src_rect.width / 2
y = button.y - self.y + 2
moveNameBase = TEXT_BASE_COLOR
if GET_MOVE_TEXT_COLOR_FROM_MOVE_BUTTON && moves[i].display_type(@battler)
# NOTE: This takes a color from a particular pixel in the button
@@ -359,26 +359,26 @@ class Battle::Scene::FightMenu < Battle::Scene::MenuBase
# The pixel is at coordinates 10,34 in the button box. If you
# change the graphic, you may want to change the below line of
# code to ensure the font is an appropriate color.
moveNameBase = button.bitmap.get_pixel(10,button.src_rect.y+34)
moveNameBase = button.bitmap.get_pixel(10, button.src_rect.y + 34)
end
textPos.push([moves[i].name,x,y,2,moveNameBase,TEXT_SHADOW_COLOR])
textPos.push([moves[i].name, x, y, 2, moveNameBase, TEXT_SHADOW_COLOR])
end
pbDrawTextPositions(@overlay.bitmap,textPos)
pbDrawTextPositions(@overlay.bitmap, textPos)
end
def refreshSelection
moves = (@battler) ? @battler.moves : []
if USE_GRAPHICS
# Choose appropriate button graphics and z positions
@buttons.each_with_index do |button,i|
@buttons.each_with_index do |button, i|
if !moves[i]
@visibility["button_#{i}"] = false
next
end
@visibility["button_#{i}"] = true
button.src_rect.x = (i==@index) ? @buttonBitmap.width/2 : 0
button.src_rect.x = (i == @index) ? @buttonBitmap.width / 2 : 0
button.src_rect.y = GameData::Type.get(moves[i].display_type(@battler)).icon_position * BUTTON_HEIGHT
button.z = self.z + ((i==@index) ? 4 : 3)
button.z = self.z + ((i == @index) ? 4 : 3)
end
end
refreshMoveData(moves[@index])
@@ -388,11 +388,11 @@ class Battle::Scene::FightMenu < Battle::Scene::MenuBase
# Write PP and type of the selected move
if !USE_GRAPHICS
moveType = GameData::Type.get(move.display_type(@battler)).name
if move.total_pp<=0
@msgBox.text = _INTL("PP: ---<br>TYPE/{1}",moveType)
if move.total_pp <= 0
@msgBox.text = _INTL("PP: ---<br>TYPE/{1}", moveType)
else
@msgBox.text = _ISPRINTF("PP: {1: 2d}/{2: 2d}<br>TYPE/{3:s}",
move.pp,move.total_pp,moveType)
move.pp, move.total_pp, moveType)
end
return
end
@@ -406,12 +406,12 @@ class Battle::Scene::FightMenu < Battle::Scene::MenuBase
type_number = GameData::Type.get(move.display_type(@battler)).icon_position
@typeIcon.src_rect.y = type_number * TYPE_ICON_HEIGHT
# PP text
if move.total_pp>0
ppFraction = [(4.0*move.pp/move.total_pp).ceil,3].min
if move.total_pp > 0
ppFraction = [(4.0 * move.pp / move.total_pp).ceil, 3].min
textPos = []
textPos.push([_INTL("PP: {1}/{2}",move.pp,move.total_pp),
448,44,2,PP_COLORS[ppFraction*2],PP_COLORS[ppFraction*2+1]])
pbDrawTextPositions(@infoOverlay.bitmap,textPos)
textPos.push([_INTL("PP: {1}/{2}", move.pp, move.total_pp),
448, 44, 2, PP_COLORS[ppFraction * 2], PP_COLORS[ppFraction * 2 + 1]])
pbDrawTextPositions(@infoOverlay.bitmap, textPos)
end
end
@@ -450,57 +450,57 @@ class Battle::Scene::TargetMenu < Battle::Scene::MenuBase
# Lists of which button graphics to use in different situations/types of battle.
MODES = [
[0,2,1,3], # 0 = Regular battle
[0,2,1,9], # 1 = Regular battle with "Cancel" instead of "Run"
[0,2,1,4], # 2 = Regular battle with "Call" instead of "Run"
[5,7,6,3], # 3 = Safari Zone
[0,8,1,3] # 4 = Bug Catching Contest
[0, 2, 1, 3], # 0 = Regular battle
[0, 2, 1, 9], # 1 = Regular battle with "Cancel" instead of "Run"
[0, 2, 1, 4], # 2 = Regular battle with "Call" instead of "Run"
[5, 7, 6, 3], # 3 = Safari Zone
[0, 8, 1, 3] # 4 = Bug Catching Contest
]
CMD_BUTTON_WIDTH_SMALL = 170
TEXT_BASE_COLOR = Color.new(240,248,224)
TEXT_SHADOW_COLOR = Color.new(64,64,64)
TEXT_BASE_COLOR = Color.new(240, 248, 224)
TEXT_SHADOW_COLOR = Color.new(64, 64, 64)
def initialize(viewport,z,sideSizes)
def initialize(viewport, z, sideSizes)
super(viewport)
@sideSizes = sideSizes
maxIndex = (@sideSizes[0]>@sideSizes[1]) ? (@sideSizes[0]-1)*2 : @sideSizes[1]*2-1
@smallButtons = (@sideSizes.max>2)
maxIndex = (@sideSizes[0] > @sideSizes[1]) ? (@sideSizes[0] - 1) * 2 : @sideSizes[1] * 2 - 1
@smallButtons = (@sideSizes.max > 2)
self.x = 0
self.y = Graphics.height-96
self.y = Graphics.height - 96
@texts = []
# NOTE: @mode is for which buttons are shown as selected.
# 0=select 1 button (@index), 1=select all buttons with text
# Create bitmaps
@buttonBitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/cursor_target"))
# Create target buttons
@buttons = Array.new(maxIndex+1) do |i|
numButtons = @sideSizes[i%2]
next if numButtons<=i/2
@buttons = Array.new(maxIndex + 1) do |i|
numButtons = @sideSizes[i % 2]
next if numButtons <= i / 2
# NOTE: Battler indexes go from left to right from the perspective of
# that side's trainer, so inc is different for each side for the
# same value of i/2.
inc = ((i%2)==0) ? i/2 : numButtons-1-i/2
inc = ((i % 2) == 0) ? i / 2 : numButtons - 1 - i / 2
button = SpriteWrapper.new(viewport)
button.bitmap = @buttonBitmap.bitmap
button.src_rect.width = (@smallButtons) ? CMD_BUTTON_WIDTH_SMALL : @buttonBitmap.width/2
button.src_rect.width = (@smallButtons) ? CMD_BUTTON_WIDTH_SMALL : @buttonBitmap.width / 2
button.src_rect.height = BUTTON_HEIGHT
if @smallButtons
button.x = self.x+170-[0,82,166][numButtons-1]
button.x = self.x + 170 - [0, 82, 166][numButtons - 1]
else
button.x = self.x+138-[0,116][numButtons-1]
button.x = self.x + 138 - [0, 116][numButtons - 1]
end
button.x += (button.src_rect.width-4)*inc
button.y = self.y+6
button.y += (BUTTON_HEIGHT-4)*((i+1)%2)
addSprite("button_#{i}",button)
button.x += (button.src_rect.width - 4) * inc
button.y = self.y + 6
button.y += (BUTTON_HEIGHT - 4) * ((i + 1) % 2)
addSprite("button_#{i}", button)
next button
end
# Create overlay (shows target names)
@overlay = BitmapSprite.new(Graphics.width,Graphics.height-self.y,viewport)
@overlay = BitmapSprite.new(Graphics.width, Graphics.height - self.y, viewport)
@overlay.x = self.x
@overlay.y = self.y
pbSetNarrowFont(@overlay.bitmap)
addSprite("overlay",@overlay)
addSprite("overlay", @overlay)
self.z = z
refresh
end
@@ -515,7 +515,7 @@ class Battle::Scene::TargetMenu < Battle::Scene::MenuBase
@overlay.z += 5 if @overlay
end
def setDetails(texts,mode)
def setDetails(texts, mode)
@texts = texts
@mode = mode
refresh
@@ -523,30 +523,30 @@ class Battle::Scene::TargetMenu < Battle::Scene::MenuBase
def refreshButtons
# Choose appropriate button graphics and z positions
@buttons.each_with_index do |button,i|
@buttons.each_with_index do |button, i|
next if !button
sel = false
buttonType = 0
if @texts[i]
sel ||= (@mode==0 && i==@index)
sel ||= (@mode==1)
buttonType = ((i%2)==0) ? 1 : 2
sel ||= (@mode == 0 && i == @index)
sel ||= (@mode == 1)
buttonType = ((i % 2) == 0) ? 1 : 2
end
buttonType = 2*buttonType + ((@smallButtons) ? 1 : 0)
button.src_rect.x = (sel) ? @buttonBitmap.width/2 : 0
button.src_rect.y = buttonType*BUTTON_HEIGHT
buttonType = 2 * buttonType + ((@smallButtons) ? 1 : 0)
button.src_rect.x = (sel) ? @buttonBitmap.width / 2 : 0
button.src_rect.y = buttonType * BUTTON_HEIGHT
button.z = self.z + ((sel) ? 3 : 2)
end
# Draw target names onto overlay
@overlay.bitmap.clear
textpos = []
@buttons.each_with_index do |button,i|
@buttons.each_with_index do |button, i|
next if !button || nil_or_empty?(@texts[i])
x = button.x-self.x+button.src_rect.width/2
y = button.y-self.y+2
textpos.push([@texts[i],x,y,2,TEXT_BASE_COLOR,TEXT_SHADOW_COLOR])
x = button.x - self.x + button.src_rect.width / 2
y = button.y - self.y + 2
textpos.push([@texts[i], x, y, 2, TEXT_BASE_COLOR, TEXT_SHADOW_COLOR])
end
pbDrawTextPositions(@overlay.bitmap,textpos)
pbDrawTextPositions(@overlay.bitmap, textpos)
end
def refresh

View File

@@ -12,14 +12,14 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper
# Maximum time in seconds to make a change to the HP bar.
HP_BAR_CHANGE_TIME = 1.0
STATUS_ICON_HEIGHT = 16
NAME_BASE_COLOR = Color.new(72,72,72)
NAME_SHADOW_COLOR = Color.new(184,184,184)
MALE_BASE_COLOR = Color.new(48,96,216)
NAME_BASE_COLOR = Color.new(72, 72, 72)
NAME_SHADOW_COLOR = Color.new(184, 184, 184)
MALE_BASE_COLOR = Color.new(48, 96, 216)
MALE_SHADOW_COLOR = NAME_SHADOW_COLOR
FEMALE_BASE_COLOR = Color.new(248,88,40)
FEMALE_BASE_COLOR = Color.new(248, 88, 40)
FEMALE_SHADOW_COLOR = NAME_SHADOW_COLOR
def initialize(battler,sideSize,viewport = nil)
def initialize(battler, sideSize, viewport = nil)
super(viewport)
@battler = battler
@sprites = {}
@@ -39,18 +39,18 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper
end
def initializeDataBoxGraphic(sideSize)
onPlayerSide = ((@battler.index%2)==0)
onPlayerSide = ((@battler.index % 2) == 0)
# Get the data box graphic and set whether the HP numbers/Exp bar are shown
if sideSize==1 # One Pokémon on side, use the regular dara box BG
if sideSize == 1 # One Pokémon on side, use the regular dara box BG
bgFilename = ["Graphics/Pictures/Battle/databox_normal",
"Graphics/Pictures/Battle/databox_normal_foe"][@battler.index%2]
"Graphics/Pictures/Battle/databox_normal_foe"][@battler.index % 2]
if onPlayerSide
@showHP = true
@showExp = true
end
else # Multiple Pokémon on side, use the thin dara box BG
bgFilename = ["Graphics/Pictures/Battle/databox_thin",
"Graphics/Pictures/Battle/databox_thin_foe"][@battler.index%2]
"Graphics/Pictures/Battle/databox_thin_foe"][@battler.index % 2]
end
@databoxBitmap.dispose if @databoxBitmap
@databoxBitmap = AnimatedBitmap.new(bgFilename)
@@ -80,23 +80,23 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper
@hpBarBitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/overlay_hp"))
@expBarBitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/overlay_exp"))
# Create sprite to draw HP numbers on
@hpNumbers = BitmapSprite.new(124,16,viewport)
@hpNumbers = BitmapSprite.new(124, 16, viewport)
pbSetSmallFont(@hpNumbers.bitmap)
@sprites["hpNumbers"] = @hpNumbers
# Create sprite wrapper that displays HP bar
@hpBar = SpriteWrapper.new(viewport)
@hpBar.bitmap = @hpBarBitmap.bitmap
@hpBar.src_rect.height = @hpBarBitmap.height/3
@hpBar.src_rect.height = @hpBarBitmap.height / 3
@sprites["hpBar"] = @hpBar
# Create sprite wrapper that displays Exp bar
@expBar = SpriteWrapper.new(viewport)
@expBar.bitmap = @expBarBitmap.bitmap
@sprites["expBar"] = @expBar
# Create sprite wrapper that displays everything except the above
@contents = BitmapWrapper.new(@databoxBitmap.width,@databoxBitmap.height)
@contents = BitmapWrapper.new(@databoxBitmap.width, @databoxBitmap.height)
self.bitmap = @contents
self.visible = false
self.z = 150+((@battler.index)/2)*5
self.z = 150 + ((@battler.index) / 2) * 5
pbSetSystemFont(self.bitmap)
end
@@ -112,23 +112,23 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper
def x=(value)
super
@hpBar.x = value+@spriteBaseX+102
@expBar.x = value+@spriteBaseX+6
@hpNumbers.x = value+@spriteBaseX+80
@hpBar.x = value + @spriteBaseX + 102
@expBar.x = value + @spriteBaseX + 6
@hpNumbers.x = value + @spriteBaseX + 80
end
def y=(value)
super
@hpBar.y = value+40
@expBar.y = value+74
@hpNumbers.y = value+52
@hpBar.y = value + 40
@expBar.y = value + 74
@hpNumbers.y = value + 52
end
def z=(value)
super
@hpBar.z = value+1
@expBar.z = value+1
@hpNumbers.z = value+2
@hpBar.z = value + 1
@expBar.z = value + 1
@hpNumbers.z = value + 2
end
def opacity=(value)
@@ -164,43 +164,43 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper
def exp_fraction
return 0.0 if @rangeExp == 0
return (@animatingExp) ? @currentExp.to_f/@rangeExp : @battler.pokemon.exp_fraction
return (@animatingExp) ? @currentExp.to_f / @rangeExp : @battler.pokemon.exp_fraction
end
def animateHP(oldHP,newHP,rangeHP)
def animateHP(oldHP, newHP, rangeHP)
@currentHP = oldHP
@endHP = newHP
@rangeHP = rangeHP
# NOTE: A change in HP takes the same amount of time to animate, no matter
# how big a change it is.
@hpIncPerFrame = (newHP-oldHP).abs/(HP_BAR_CHANGE_TIME*Graphics.frame_rate)
@hpIncPerFrame = (newHP - oldHP).abs / (HP_BAR_CHANGE_TIME * Graphics.frame_rate)
# minInc is the smallest amount that HP is allowed to change per frame.
# This avoids a tiny change in HP still taking HP_BAR_CHANGE_TIME seconds.
minInc = (rangeHP*4)/(@hpBarBitmap.width*HP_BAR_CHANGE_TIME*Graphics.frame_rate)
@hpIncPerFrame = minInc if @hpIncPerFrame<minInc
minInc = (rangeHP * 4) / (@hpBarBitmap.width * HP_BAR_CHANGE_TIME * Graphics.frame_rate)
@hpIncPerFrame = minInc if @hpIncPerFrame < minInc
@animatingHP = true
end
def animateExp(oldExp,newExp,rangeExp)
def animateExp(oldExp, newExp, rangeExp)
return if rangeExp == 0
@currentExp = oldExp
@endExp = newExp
@rangeExp = rangeExp
# NOTE: Filling the Exp bar from empty to full takes EXP_BAR_FILL_TIME
# seconds no matter what. Filling half of it takes half as long, etc.
@expIncPerFrame = rangeExp/(EXP_BAR_FILL_TIME*Graphics.frame_rate)
@expIncPerFrame = rangeExp / (EXP_BAR_FILL_TIME * Graphics.frame_rate)
@animatingExp = true
pbSEPlay("Pkmn exp gain") if @showExp
end
def pbDrawNumber(number,btmp,startX,startY,align = 0)
def pbDrawNumber(number, btmp, startX, startY, align = 0)
# -1 means draw the / character
n = (number == -1) ? [10] : number.to_i.digits.reverse
charWidth = @numbersBitmap.width/11
charWidth = @numbersBitmap.width / 11
charHeight = @numbersBitmap.height
startX -= charWidth*n.length if align==1
startX -= charWidth * n.length if align == 1
n.each do |i|
btmp.blt(startX,startY,@numbersBitmap.bitmap,Rect.new(i*charWidth,0,charWidth,charHeight))
btmp.blt(startX, startY, @numbersBitmap.bitmap, Rect.new(i * charWidth, 0, charWidth, charHeight))
startX += charWidth
end
end
@@ -211,42 +211,42 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper
textPos = []
imagePos = []
# Draw background panel
self.bitmap.blt(0,0,@databoxBitmap.bitmap,Rect.new(0,0,@databoxBitmap.width,@databoxBitmap.height))
self.bitmap.blt(0, 0, @databoxBitmap.bitmap, Rect.new(0, 0, @databoxBitmap.width, @databoxBitmap.height))
# Draw Pokémon's name
nameWidth = self.bitmap.text_size(@battler.name).width
nameOffset = 0
nameOffset = nameWidth-116 if nameWidth>116
textPos.push([@battler.name,@spriteBaseX+8-nameOffset,0,false,NAME_BASE_COLOR,NAME_SHADOW_COLOR])
nameOffset = nameWidth - 116 if nameWidth > 116
textPos.push([@battler.name, @spriteBaseX + 8 - nameOffset, 0, false, NAME_BASE_COLOR, NAME_SHADOW_COLOR])
# Draw Pokémon's gender symbol
case @battler.displayGender
when 0 # Male
textPos.push([_INTL(""),@spriteBaseX+126,0,false,MALE_BASE_COLOR,MALE_SHADOW_COLOR])
textPos.push([_INTL(""), @spriteBaseX + 126, 0, false, MALE_BASE_COLOR, MALE_SHADOW_COLOR])
when 1 # Female
textPos.push([_INTL(""),@spriteBaseX+126,0,false,FEMALE_BASE_COLOR,FEMALE_SHADOW_COLOR])
textPos.push([_INTL(""), @spriteBaseX + 126, 0, false, FEMALE_BASE_COLOR, FEMALE_SHADOW_COLOR])
end
pbDrawTextPositions(self.bitmap,textPos)
pbDrawTextPositions(self.bitmap, textPos)
# Draw Pokémon's level
imagePos.push(["Graphics/Pictures/Battle/overlay_lv",@spriteBaseX+140,16])
pbDrawNumber(@battler.level,self.bitmap,@spriteBaseX+162,16)
imagePos.push(["Graphics/Pictures/Battle/overlay_lv", @spriteBaseX + 140, 16])
pbDrawNumber(@battler.level, self.bitmap, @spriteBaseX + 162, 16)
# Draw shiny icon
if @battler.shiny?
shinyX = (@battler.opposes?(0)) ? 206 : -6 # Foe's/player's
imagePos.push(["Graphics/Pictures/shiny",@spriteBaseX+shinyX,36])
imagePos.push(["Graphics/Pictures/shiny", @spriteBaseX + shinyX, 36])
end
# Draw Mega Evolution/Primal Reversion icon
if @battler.mega?
imagePos.push(["Graphics/Pictures/Battle/icon_mega",@spriteBaseX+8,34])
imagePos.push(["Graphics/Pictures/Battle/icon_mega", @spriteBaseX + 8, 34])
elsif @battler.primal?
primalX = (@battler.opposes?) ? 208 : -28 # Foe's/player's
if @battler.isSpecies?(:KYOGRE)
imagePos.push(["Graphics/Pictures/Battle/icon_primal_Kyogre",@spriteBaseX+primalX,4])
imagePos.push(["Graphics/Pictures/Battle/icon_primal_Kyogre", @spriteBaseX + primalX, 4])
elsif @battler.isSpecies?(:GROUDON)
imagePos.push(["Graphics/Pictures/Battle/icon_primal_Groudon",@spriteBaseX+primalX,4])
imagePos.push(["Graphics/Pictures/Battle/icon_primal_Groudon", @spriteBaseX + primalX, 4])
end
end
# Draw owned icon (foe Pokémon only)
if @battler.owned? && @battler.opposes?(0)
imagePos.push(["Graphics/Pictures/Battle/icon_own",@spriteBaseX+8,36])
imagePos.push(["Graphics/Pictures/Battle/icon_own", @spriteBaseX + 8, 36])
end
# Draw status icon
if @battler.status != :NONE
@@ -255,10 +255,10 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper
else
s = GameData::Status.get(@battler.status).icon_position
end
imagePos.push(["Graphics/Pictures/Battle/icon_statuses",@spriteBaseX+24,36,
imagePos.push(["Graphics/Pictures/Battle/icon_statuses", @spriteBaseX + 24, 36,
0, s * STATUS_ICON_HEIGHT, -1, STATUS_ICON_HEIGHT]) if s >= 0
end
pbDrawImagePositions(self.bitmap,imagePos)
pbDrawImagePositions(self.bitmap, imagePos)
refreshHP
refreshExp
end
@@ -268,24 +268,24 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper
return if !@battler.pokemon
# Show HP numbers
if @showHP
pbDrawNumber(self.hp,@hpNumbers.bitmap,54,2,1)
pbDrawNumber(-1,@hpNumbers.bitmap,54,2) # / char
pbDrawNumber(@battler.totalhp,@hpNumbers.bitmap,70,2)
pbDrawNumber(self.hp, @hpNumbers.bitmap, 54, 2, 1)
pbDrawNumber(-1, @hpNumbers.bitmap, 54, 2) # / char
pbDrawNumber(@battler.totalhp, @hpNumbers.bitmap, 70, 2)
end
# Resize HP bar
w = 0
if self.hp>0
w = @hpBarBitmap.width.to_f*self.hp/@battler.totalhp
w = 1 if w<1
if self.hp > 0
w = @hpBarBitmap.width.to_f * self.hp / @battler.totalhp
w = 1 if w < 1
# NOTE: The line below snaps the bar's width to the nearest 2 pixels, to
# fit in with the rest of the graphics which are doubled in size.
w = ((w/2.0).round)*2
w = ((w / 2.0).round) * 2
end
@hpBar.src_rect.width = w
hpColor = 0 # Green bar
hpColor = 1 if self.hp<=@battler.totalhp/2 # Yellow bar
hpColor = 2 if self.hp<=@battler.totalhp/4 # Red bar
@hpBar.src_rect.y = hpColor*@hpBarBitmap.height/3
hpColor = 1 if self.hp <= @battler.totalhp / 2 # Yellow bar
hpColor = 2 if self.hp <= @battler.totalhp / 4 # Red bar
@hpBar.src_rect.y = hpColor * @hpBarBitmap.height / 3
end
def refreshExp
@@ -293,22 +293,22 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper
w = exp_fraction * @expBarBitmap.width
# NOTE: The line below snaps the bar's width to the nearest 2 pixels, to
# fit in with the rest of the graphics which are doubled in size.
w = ((w/2).round)*2
w = ((w / 2).round) * 2
@expBar.src_rect.width = w
end
def updateHPAnimation
return if !@animatingHP
if @currentHP<@endHP # Gaining HP
if @currentHP < @endHP # Gaining HP
@currentHP += @hpIncPerFrame
@currentHP = @endHP if @currentHP>=@endHP
elsif @currentHP>@endHP # Losing HP
@currentHP = @endHP if @currentHP >= @endHP
elsif @currentHP > @endHP # Losing HP
@currentHP -= @hpIncPerFrame
@currentHP = @endHP if @currentHP<=@endHP
@currentHP = @endHP if @currentHP <= @endHP
end
# Refresh the HP bar/numbers
refreshHP
@animatingHP = false if @currentHP==@endHP
@animatingHP = false if @currentHP == @endHP
end
def updateExpAnimation
@@ -318,29 +318,29 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper
@animatingExp = false
return
end
if @currentExp<@endExp # Gaining Exp
if @currentExp < @endExp # Gaining Exp
@currentExp += @expIncPerFrame
@currentExp = @endExp if @currentExp>=@endExp
elsif @currentExp>@endExp # Losing Exp
@currentExp = @endExp if @currentExp >= @endExp
elsif @currentExp > @endExp # Losing Exp
@currentExp -= @expIncPerFrame
@currentExp = @endExp if @currentExp<=@endExp
@currentExp = @endExp if @currentExp <= @endExp
end
# Refresh the Exp bar
refreshExp
return if @currentExp!=@endExp # Exp bar still has more to animate
return if @currentExp != @endExp # Exp bar still has more to animate
# Exp bar is completely filled, level up with a flash and sound effect
if @currentExp>=@rangeExp
if @expFlash==0
if @currentExp >= @rangeExp
if @expFlash == 0
pbSEStop
@expFlash = Graphics.frame_rate/5
@expFlash = Graphics.frame_rate / 5
pbSEPlay("Pkmn exp full")
self.flash(Color.new(64,200,248,192),@expFlash)
self.flash(Color.new(64, 200, 248, 192), @expFlash)
for i in @sprites
i[1].flash(Color.new(64,200,248,192),@expFlash) if !i[1].disposed?
i[1].flash(Color.new(64, 200, 248, 192), @expFlash) if !i[1].disposed?
end
else
@expFlash -= 1
@animatingExp = false if @expFlash==0
@animatingExp = false if @expFlash == 0
end
else
pbSEStop
@@ -349,16 +349,16 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper
end
end
QUARTER_ANIM_PERIOD = Graphics.frame_rate*3/20
QUARTER_ANIM_PERIOD = Graphics.frame_rate * 3 / 20
def updatePositions(frameCounter)
self.x = @spriteX
self.y = @spriteY
# Data box bobbing while Pokémon is selected
if @selected==1 || @selected==2 # Choosing commands/targeted or damaged
case (frameCounter/QUARTER_ANIM_PERIOD).floor
when 1 then self.y = @spriteY-2
when 3 then self.y = @spriteY+2
if @selected == 1 || @selected == 2 # Choosing commands/targeted or damaged
case (frameCounter / QUARTER_ANIM_PERIOD).floor
when 1 then self.y = @spriteY - 2
when 3 then self.y = @spriteY + 2
end
end
end
@@ -383,10 +383,10 @@ end
class Battle::Scene::AbilitySplashBar < SpriteWrapper
attr_reader :battler
TEXT_BASE_COLOR = Color.new(0,0,0)
TEXT_SHADOW_COLOR = Color.new(248,248,248)
TEXT_BASE_COLOR = Color.new(0, 0, 0)
TEXT_SHADOW_COLOR = Color.new(248, 248, 248)
def initialize(side,viewport = nil)
def initialize(side, viewport = nil)
super(viewport)
@side = side
@battler = nil
@@ -394,15 +394,15 @@ class Battle::Scene::AbilitySplashBar < SpriteWrapper
@bgBitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/ability_bar"))
@bgSprite = SpriteWrapper.new(viewport)
@bgSprite.bitmap = @bgBitmap.bitmap
@bgSprite.src_rect.y = (side==0) ? 0 : @bgBitmap.height/2
@bgSprite.src_rect.height = @bgBitmap.height/2
@bgSprite.src_rect.y = (side == 0) ? 0 : @bgBitmap.height / 2
@bgSprite.src_rect.height = @bgBitmap.height / 2
# Create bitmap that displays the text
@contents = BitmapWrapper.new(@bgBitmap.width,@bgBitmap.height/2)
@contents = BitmapWrapper.new(@bgBitmap.width, @bgBitmap.height / 2)
self.bitmap = @contents
pbSetSystemFont(self.bitmap)
# Position the bar
self.x = (side==0) ? -Graphics.width/2 : Graphics.width
self.y = (side==0) ? 180 : 80
self.x = (side == 0) ? -Graphics.width / 2 : Graphics.width
self.y = (side == 0) ? 180 : 80
self.z = 120
self.visible = false
end
@@ -426,7 +426,7 @@ class Battle::Scene::AbilitySplashBar < SpriteWrapper
def z=(value)
super
@bgSprite.z = value-1
@bgSprite.z = value - 1
end
def opacity=(value)
@@ -453,14 +453,14 @@ class Battle::Scene::AbilitySplashBar < SpriteWrapper
self.bitmap.clear
return if !@battler
textPos = []
textX = (@side==0) ? 10 : self.bitmap.width-8
textX = (@side == 0) ? 10 : self.bitmap.width - 8
# Draw Pokémon's name
textPos.push([_INTL("{1}'s",@battler.name),textX,-4,@side==1,
TEXT_BASE_COLOR,TEXT_SHADOW_COLOR,true])
textPos.push([_INTL("{1}'s", @battler.name), textX, -4, @side == 1,
TEXT_BASE_COLOR, TEXT_SHADOW_COLOR, true])
# Draw Pokémon's ability
textPos.push([@battler.abilityName,textX,26,@side==1,
TEXT_BASE_COLOR,TEXT_SHADOW_COLOR,true])
pbDrawTextPositions(self.bitmap,textPos)
textPos.push([@battler.abilityName, textX, 26, @side == 1,
TEXT_BASE_COLOR, TEXT_SHADOW_COLOR, true])
pbDrawTextPositions(self.bitmap, textPos)
end
def update
@@ -480,7 +480,7 @@ class Battle::Scene::BattlerSprite < RPG::Sprite
attr_accessor :selected
attr_reader :sideSize
def initialize(viewport,sideSize,index,battleAnimations)
def initialize(viewport, sideSize, index, battleAnimations)
super(viewport)
@pkmn = nil
@sideSize = sideSize
@@ -511,12 +511,12 @@ class Battle::Scene::BattlerSprite < RPG::Sprite
def x=(value)
@spriteX = value
super(value+@spriteXExtra)
super(value + @spriteXExtra)
end
def y=(value)
@spriteY = value
super(value+@spriteYExtra)
super(value + @spriteYExtra)
end
def width; return (self.bitmap) ? self.bitmap.width : 0; end
@@ -530,27 +530,27 @@ class Battle::Scene::BattlerSprite < RPG::Sprite
# Set sprite's origin to bottom middle
def pbSetOrigin
return if !@_iconBitmap
self.ox = @_iconBitmap.width/2
self.ox = @_iconBitmap.width / 2
self.oy = @_iconBitmap.height
end
def pbSetPosition
return if !@_iconBitmap
pbSetOrigin
if (@index%2)==0
self.z = 50+5*@index/2
if (@index % 2) == 0
self.z = 50 + 5 * @index / 2
else
self.z = 50-5*(@index+1)/2
self.z = 50 - 5 * (@index + 1) / 2
end
# Set original position
p = Battle::Scene.pbBattlerPosition(@index,@sideSize)
p = Battle::Scene.pbBattlerPosition(@index, @sideSize)
@spriteX = p[0]
@spriteY = p[1]
# Apply metrics
@pkmn.species_data.apply_metrics_to_sprite(self, @index)
end
def setPokemonBitmap(pkmn,back = false)
def setPokemonBitmap(pkmn, back = false)
@pkmn = pkmn
@_iconBitmap.dispose if @_iconBitmap
@_iconBitmap = GameData::Species.sprite_bitmap_from_pokemon(@pkmn, back)
@@ -566,8 +566,8 @@ class Battle::Scene::BattlerSprite < RPG::Sprite
@pkmn.play_cry if @pkmn
end
QUARTER_ANIM_PERIOD = Graphics.frame_rate*3/20
SIXTH_ANIM_PERIOD = Graphics.frame_rate*2/20
QUARTER_ANIM_PERIOD = Graphics.frame_rate * 3 / 20
SIXTH_ANIM_PERIOD = Graphics.frame_rate * 2 / 20
def update(frameCounter = 0)
return if !@_iconBitmap
@@ -577,8 +577,8 @@ class Battle::Scene::BattlerSprite < RPG::Sprite
self.bitmap = @_iconBitmap.bitmap
# Pokémon sprite bobbing while Pokémon is selected
@spriteYExtra = 0
if @selected==1 # When choosing commands for this Pokémon
case (frameCounter/QUARTER_ANIM_PERIOD).floor
if @selected == 1 # When choosing commands for this Pokémon
case (frameCounter / QUARTER_ANIM_PERIOD).floor
when 1 then @spriteYExtra = 2
when 3 then @spriteYExtra = -2
end
@@ -587,8 +587,8 @@ class Battle::Scene::BattlerSprite < RPG::Sprite
self.y = self.y
self.visible = @spriteVisible
# Pokémon sprite blinking when targeted
if @selected==2 && @spriteVisible
case (frameCounter/SIXTH_ANIM_PERIOD).floor
if @selected == 2 && @spriteVisible
case (frameCounter / SIXTH_ANIM_PERIOD).floor
when 2, 5 then self.visible = false
else self.visible = true
end
@@ -607,7 +607,7 @@ class Battle::Scene::BattlerShadowSprite < RPG::Sprite
attr_accessor :index
attr_accessor :selected
def initialize(viewport,sideSize,index)
def initialize(viewport, sideSize, index)
super(viewport)
@pkmn = nil
@sideSize = sideSize
@@ -629,8 +629,8 @@ class Battle::Scene::BattlerShadowSprite < RPG::Sprite
# Set sprite's origin to centre
def pbSetOrigin
return if !@_iconBitmap
self.ox = @_iconBitmap.width/2
self.oy = @_iconBitmap.height/2
self.ox = @_iconBitmap.width / 2
self.oy = @_iconBitmap.height / 2
end
def pbSetPosition
@@ -638,7 +638,7 @@ class Battle::Scene::BattlerShadowSprite < RPG::Sprite
pbSetOrigin
self.z = 3
# Set original position
p = Battle::Scene.pbBattlerPosition(@index,@sideSize)
p = Battle::Scene.pbBattlerPosition(@index, @sideSize)
self.x = p[0]
self.y = p[1]
# Apply metrics

View File

@@ -1,5 +1,5 @@
class Battle::Scene::Animation
def initialize(sprites,viewport)
def initialize(sprites, viewport)
@sprites = sprites
@viewport = viewport
@pictureEx = [] # For all the PictureEx
@@ -14,10 +14,10 @@ class Battle::Scene::Animation
end
def createProcesses; end
def empty?; return @pictureEx.length==0; end
def empty?; return @pictureEx.length == 0; end
def animDone?; return @animDone; end
def addSprite(s,origin = PictureOrigin::TopLeft)
def addSprite(s, origin = PictureOrigin::TopLeft)
num = @pictureEx.length
picture = PictureEx.new(s.z)
picture.x = s.x
@@ -25,20 +25,20 @@ class Battle::Scene::Animation
picture.visible = s.visible
picture.color = s.color.clone
picture.tone = s.tone.clone
picture.setOrigin(0,origin)
picture.setOrigin(0, origin)
@pictureEx[num] = picture
@pictureSprites[num] = s
return picture
end
def addNewSprite(x,y,name,origin = PictureOrigin::TopLeft)
def addNewSprite(x, y, name, origin = PictureOrigin::TopLeft)
num = @pictureEx.length
picture = PictureEx.new(num)
picture.setXY(0,x,y)
picture.setName(0,name)
picture.setOrigin(0,origin)
picture.setXY(0, x, y)
picture.setName(0, name)
picture.setOrigin(0, origin)
@pictureEx[num] = picture
s = IconSprite.new(x,y,@viewport)
s = IconSprite.new(x, y, @viewport)
s.setBitmap(name)
@pictureSprites[num] = s
@tempSprites.push(s)
@@ -49,11 +49,11 @@ class Battle::Scene::Animation
return if @animDone
@tempSprites.each { |s| s.update if s }
finished = true
@pictureEx.each_with_index do |p,i|
@pictureEx.each_with_index do |p, i|
next if !p.running?
finished = false
p.update
setPictureIconSprite(@pictureSprites[i],p)
setPictureIconSprite(@pictureSprites[i], p)
end
@animDone = true if finished
end
@@ -96,110 +96,110 @@ module Battle::Scene::Animation::BallAnimationMixin
return ball
end
def ballTracksHand(ball,traSprite,safariThrow = false)
def ballTracksHand(ball, traSprite, safariThrow = false)
# Back sprite isn't animated, no hand-tracking needed
if traSprite.bitmap.width<traSprite.bitmap.height*2
ball.setVisible(7,true)
if traSprite.bitmap.width < traSprite.bitmap.height * 2
ball.setVisible(7, true)
ballStartX = traSprite.x
ballStartX -= ball.totalDuration*(Graphics.width/(2*16)) if !safariThrow
ballStartY = traSprite.y-traSprite.bitmap.height/2
ballStartX -= ball.totalDuration * (Graphics.width / (2 * 16)) if !safariThrow
ballStartY = traSprite.y - traSprite.bitmap.height / 2
return ballStartX, ballStartY
end
# Back sprite is animated, make the Poké Ball track the trainer's hand
coordSets = [[traSprite.x-44,traSprite.y-32],[-10,-36],[118,-4]]
coordSets = [[traSprite.x - 44, traSprite.y - 32], [-10, -36], [118, -4]]
case @trainer.trainer_type
when :POKEMONTRAINER_Leaf
coordSets = [[traSprite.x-30,traSprite.y-30],[-18,-36],[118,-6]]
coordSets = [[traSprite.x - 30, traSprite.y - 30], [-18, -36], [118, -6]]
when :POKEMONTRAINER_Brendan
coordSets = [[traSprite.x-46,traSprite.y-40],[-4,-30],[118,-2]]
coordSets = [[traSprite.x - 46, traSprite.y - 40], [-4, -30], [118, -2]]
when :POKEMONTRAINER_May
coordSets = [[traSprite.x-44,traSprite.y-38],[-8,-30],[122,0]]
coordSets = [[traSprite.x - 44, traSprite.y - 38], [-8, -30], [122, 0]]
end
# Arm stretched out behind player
ball.setVisible(0,true)
ball.setXY(0,coordSets[0][0],coordSets[0][1])
ball.moveDelta(0,5,-5*(Graphics.width/(2*16)),0) if !safariThrow
ball.setDelta(0,-12,0) if safariThrow
ball.setVisible(0, true)
ball.setXY(0, coordSets[0][0], coordSets[0][1])
ball.moveDelta(0, 5, -5 * (Graphics.width / (2 * 16)), 0) if !safariThrow
ball.setDelta(0, -12, 0) if safariThrow
# Arm mid throw
ball.setDelta(5,coordSets[1][0],coordSets[1][1])
ball.moveDelta(5,2,-2*(Graphics.width/(2*16)),0) if !safariThrow
ball.setDelta(5,34,0) if safariThrow
ball.setDelta(5, coordSets[1][0], coordSets[1][1])
ball.moveDelta(5, 2, -2 * (Graphics.width / (2 * 16)), 0) if !safariThrow
ball.setDelta(5, 34, 0) if safariThrow
# Start of throw
ball.setDelta(7,coordSets[2][0],coordSets[2][1])
ball.setDelta(7,-14,0) if safariThrow
ball.setDelta(7, coordSets[2][0], coordSets[2][1])
ball.setDelta(7, -14, 0) if safariThrow
# Update Poké Ball trajectory's start position
ballStartX = ballStartY = 0
coordSets.each do |c|
ballStartX += c[0]
ballStartY += c[1]
end
ballStartX -= ball.totalDuration*(Graphics.width/(2*16)) if !safariThrow
ballStartX -= ball.totalDuration * (Graphics.width / (2 * 16)) if !safariThrow
ballStartX += 8 if safariThrow # -12 + 34 - 14
return ballStartX, ballStartY
end
def trainerThrowingFrames(ball,trainer,traSprite)
ball.setZ(0,traSprite.z-1)
def trainerThrowingFrames(ball, trainer, traSprite)
ball.setZ(0, traSprite.z - 1)
# Change trainer's frames
size = traSprite.src_rect.width # Width per frame
trainer.setSrc(0,size,0)
trainer.setSrc(5,size*2,0)
trainer.setSrc(7,size*3,0)
trainer.setSrc(9,size*4,0)
trainer.setSrc(18,0,0)
trainer.setSrc(0, size, 0)
trainer.setSrc(5, size * 2, 0)
trainer.setSrc(7, size * 3, 0)
trainer.setSrc(9, size * 4, 0)
trainer.setSrc(18, 0, 0)
# Alter trainer's positioning
trainer.setDelta(0,-12,0)
trainer.setDelta(5,34,0)
trainer.setDelta(7,-14,0)
trainer.setDelta(9,28,0)
trainer.moveDelta(10,3,-6,6)
trainer.setDelta(18,-4,0)
trainer.setDelta(19,-26,-6)
trainer.setDelta(0, -12, 0)
trainer.setDelta(5, 34, 0)
trainer.setDelta(7, -14, 0)
trainer.setDelta(9, 28, 0)
trainer.moveDelta(10, 3, -6, 6)
trainer.setDelta(18, -4, 0)
trainer.setDelta(19, -26, -6)
# Make ball track the trainer's hand
ballStartX, ballStartY = ballTracksHand(ball,traSprite,true)
ballStartX, ballStartY = ballTracksHand(ball, traSprite, true)
return ballStartX, ballStartY
end
def createBallTrajectory(ball,delay,duration,startX,startY,midX,midY,endX,endY)
def createBallTrajectory(ball, delay, duration, startX, startY, midX, midY, endX, endY)
# NOTE: This trajectory is the same regardless of whether the player's
# sprite is being shown on-screen (and sliding off while animating a
# throw). Instead, that throw animation and initialDelay are designed
# to make sure the Ball's trajectory starts at the same position.
ball.setVisible(delay,true)
a = 2*startY - 4*midY + 2*endY
b = 4*midY - 3*startY - endY
ball.setVisible(delay, true)
a = 2 * startY - 4 * midY + 2 * endY
b = 4 * midY - 3 * startY - endY
c = startY
for i in 1..duration
t = i.to_f/duration # t ranges from 0 to 1
x = startX + (endX-startX)*t # Linear in t
y = a*t**2 + b*t + c # Quadratic in t
ball.moveXY(delay+i-1,1,x,y)
t = i.to_f / duration # t ranges from 0 to 1
x = startX + (endX - startX) * t # Linear in t
y = a * t**2 + b * t + c # Quadratic in t
ball.moveXY(delay + i - 1, 1, x, y)
end
createBallTumbling(ball,delay,duration)
createBallTumbling(ball, delay, duration)
end
def createBallTumbling(ball,delay,duration)
def createBallTumbling(ball, delay, duration)
# Animate ball frames
numTumbles = 1
numFrames = 1
if @ballSprite && @ballSprite.bitmap.width>=@ballSprite.bitmap.height
if @ballSprite && @ballSprite.bitmap.width >= @ballSprite.bitmap.height
# 2* because each frame is twice as tall as it is wide
numFrames = 2*@ballSprite.bitmap.width/@ballSprite.bitmap.height
numFrames = 2 * @ballSprite.bitmap.width / @ballSprite.bitmap.height
end
if numFrames>1
if numFrames > 1
curFrame = 0
for i in 1..duration
thisFrame = numFrames*numTumbles*i/duration
if thisFrame>curFrame
thisFrame = numFrames * numTumbles * i / duration
if thisFrame > curFrame
curFrame = thisFrame
ball.setSrc(delay+i-1,(curFrame%numFrames)*@ballSprite.bitmap.height/2,0)
ball.setSrc(delay + i - 1, (curFrame % numFrames) * @ballSprite.bitmap.height / 2, 0)
end
end
ball.setSrc(delay+duration,0,0)
ball.setSrc(delay + duration, 0, 0)
end
# Rotate ball
ball.moveAngle(delay,duration,360*3)
ball.setAngle(delay+duration,0)
ball.moveAngle(delay, duration, 360 * 3)
ball.setAngle(delay + duration, 0)
end
def ballSetOpen(ball, delay, poke_ball)
@@ -228,24 +228,24 @@ module Battle::Scene::Animation::BallAnimationMixin
ballSetOpen(ball, delay, poke_ball)
end
def battlerAppear(battler,delay,battlerX,battlerY,batSprite,color)
battler.setVisible(delay,true)
battler.setOpacity(delay,255)
battler.moveXY(delay,5,battlerX,battlerY)
battler.moveZoom(delay,5,100,[batSprite,:pbPlayIntroAnimation])
def battlerAppear(battler, delay, battlerX, battlerY, batSprite, color)
battler.setVisible(delay, true)
battler.setOpacity(delay, 255)
battler.moveXY(delay, 5, battlerX, battlerY)
battler.moveZoom(delay, 5, 100, [batSprite, :pbPlayIntroAnimation])
# NOTE: As soon as the battler sprite finishes zooming, and just as it
# starts changing its tone to normal, it plays its intro animation.
color.alpha = 0
battler.moveColor(delay+5,10,color)
battler.moveColor(delay + 5, 10, color)
end
def battlerAbsorb(battler,delay,battlerX,battlerY,color)
def battlerAbsorb(battler, delay, battlerX, battlerY, color)
color.alpha = 255
battler.moveColor(delay,10,color)
battler.moveColor(delay, 10, color)
delay = battler.totalDuration
battler.moveXY(delay,5,battlerX,battlerY)
battler.moveZoom(delay,5,0)
battler.setVisible(delay+5,false)
battler.moveXY(delay, 5, battlerX, battlerY)
battler.moveZoom(delay, 5, 0)
battler.setVisible(delay + 5, false)
end
# The regular Poké Ball burst animation.

View File

@@ -4,15 +4,15 @@
class Battle::DebugSceneNoLogging
def initialize
@battle = nil
@lastCmd = [0,0,0,0]
@lastMove = [0,0,0,0]
@lastCmd = [0, 0, 0, 0]
@lastMove = [0, 0, 0, 0]
end
# Called whenever the battle begins.
def pbStartBattle(battle)
@battle = battle
@lastCmd = [0,0,0,0]
@lastMove = [0,0,0,0]
@lastCmd = [0, 0, 0, 0]
@lastMove = [0, 0, 0, 0]
end
def pbBlitz(keys)
@@ -23,61 +23,61 @@ class Battle::DebugSceneNoLogging
def pbBeginCommandPhase; end
def pbBeginAttackPhase; end
def pbShowOpponent(idxTrainer); end
def pbDamageAnimation(battler,effectiveness = 0); end
def pbCommonAnimation(animName,user = nil,target = nil); end
def pbAnimation(moveID,user,targets,hitNum = 0); end
def pbDamageAnimation(battler, effectiveness = 0); end
def pbCommonAnimation(animName, user = nil, target = nil); end
def pbAnimation(moveID, user, targets, hitNum = 0); end
def pbEndBattle(result); end
def pbWildBattleSuccess; end
def pbTrainerBattleSuccess; end
def pbBattleArenaJudgment(b1,b2,r1,r2); end
def pbBattleArenaBattlers(b1,b2); end
def pbBattleArenaJudgment(b1, b2, r1, r2); end
def pbBattleArenaBattlers(b1, b2); end
def pbRefresh; end
def pbDisplayMessage(msg,brief = false); end
def pbDisplayMessage(msg, brief = false); end
def pbDisplayPausedMessage(msg); end
def pbDisplayConfirmMessage(msg); return true; end
def pbShowCommands(msg,commands,defaultValue); return 0; end
def pbShowCommands(msg, commands, defaultValue); return 0; end
def pbSendOutBattlers(sendOuts,startBattle = false); end
def pbSendOutBattlers(sendOuts, startBattle = false); end
def pbRecall(idxBattler); end
def pbItemMenu(idxBattler,firstAction); return -1; end
def pbItemMenu(idxBattler, firstAction); return -1; end
def pbResetMoveIndex(idxBattler); end
def pbHPChanged(battler,oldHP,showAnim = false); end
def pbHPChanged(battler, oldHP, showAnim = false); end
def pbFaintBattler(battler); end
def pbEXPBar(battler,startExp,endExp,tempExp1,tempExp2); end
def pbEXPBar(battler, startExp, endExp, tempExp1, tempExp2); end
def pbLevelUp(pkmn, battler, oldTotalHP, oldAttack, oldDefense,
oldSpAtk, oldSpDef, oldSpeed); end
def pbForgetMove(pkmn,moveToLearn); return 0; end # Always forget first move
def pbForgetMove(pkmn, moveToLearn); return 0; end # Always forget first move
def pbCommandMenu(idxBattler,firstAction)
return 1 if rand(15)==0 # Bag
return 4 if rand(10)==0 # Call
return 0 # Fight
def pbCommandMenu(idxBattler, firstAction)
return 1 if rand(15) == 0 # Bag
return 4 if rand(10) == 0 # Call
return 0 # Fight
end
def pbFightMenu(idxBattler,megaEvoPossible = false)
def pbFightMenu(idxBattler, megaEvoPossible = false)
battler = @battle.battlers[idxBattler]
50.times do
break if yield rand(battler.move.length)
end
end
def pbChooseTarget(idxBattler,target_data,visibleSprites = nil)
def pbChooseTarget(idxBattler, target_data, visibleSprites = nil)
targets = @battle.allOtherSideBattlers(idxBattler).map { |b| b.index }
return -1 if targets.length==0
return -1 if targets.length == 0
return targets.sample
end
def pbPartyScreen(idxBattler,canCancel = false)
def pbPartyScreen(idxBattler, canCancel = false)
replacements = []
@battle.eachInTeamFromBattlerIndex(idxBattler) do |_b,idxParty|
replacements.push(idxParty) if !@battle.pbFindBattler(idxParty,idxBattler)
@battle.eachInTeamFromBattlerIndex(idxBattler) do |_b, idxParty|
replacements.push(idxParty) if !@battle.pbFindBattler(idxParty, idxBattler)
end
return if replacements.length==0
return if replacements.length == 0
50.times do
break if yield replacements[rand(replacements.length)],self
break if yield replacements[rand(replacements.length)], self
end
end
end

View File

@@ -31,17 +31,17 @@ class Battle::AI
sum += c[1]
n += 1
end
return 0 if n<2
return 0 if n < 2
mean = sum.to_f / n
varianceTimesN = 0
choices.each do |c|
next if c[1]<=0
deviation = c[1].to_f-mean
varianceTimesN += deviation*deviation
next if c[1] <= 0
deviation = c[1].to_f - mean
varianceTimesN += deviation * deviation
end
# Using population standard deviation
# [(n-1) makes it a sample std dev, would be 0 with only 1 sample]
return Math.sqrt(varianceTimesN/n)
return Math.sqrt(varianceTimesN / n)
end
#=============================================================================

View File

@@ -12,7 +12,7 @@ class Battle::AI
idxTarget = @battle.battlers[idxTarget].pokemonIndex # Party Pokémon
end
# Register use of item
@battle.pbRegisterItem(idxBattler,item,idxTarget)
@battle.pbRegisterItem(idxBattler, item, idxTarget)
PBDebug.log("[AI] #{user.pbThis} (#{user.index}) will use item #{GameData::Item.get(item).name}")
return true
end
@@ -22,7 +22,7 @@ class Battle::AI
def pbEnemyItemToUse(idxBattler)
return nil if !@battle.internalBattle
items = @battle.pbGetOwnerItems(idxBattler)
return nil if !items || items.length==0
return nil if !items || items.length == 0
# Determine target of item (always the Pokémon choosing the action)
idxTarget = idxBattler # Battler using the item
battler = @battle.battlers[idxTarget]
@@ -40,7 +40,7 @@ class Battle::AI
:LEMONADE => (Settings::REBALANCED_HEALING_ITEM_AMOUNTS) ? 70 : 80,
:MOOMOOMILK => 100,
:ORANBERRY => 10,
:SITRUSBERRY => battler.totalhp/4,
:SITRUSBERRY => battler.totalhp / 4,
:ENERGYPOWDER => (Settings::REBALANCED_HEALING_ITEM_AMOUNTS) ? 60 : 50,
:ENERGYROOT => (Settings::REBALANCED_HEALING_ITEM_AMOUNTS) ? 120 : 200
}
@@ -103,9 +103,9 @@ class Battle::AI
usableXItems = []
items.each do |i|
next if !i
next if !@battle.pbCanUseItemOnPokemon?(i,pkmn,battler,@battle.scene,false)
next if !ItemHandlers.triggerCanUseInBattle(i,pkmn,battler,nil,
false,self,@battle.scene,false)
next if !@battle.pbCanUseItemOnPokemon?(i, pkmn, battler, @battle.scene, false)
next if !ItemHandlers.triggerCanUseInBattle(i, pkmn, battler, nil,
false, self, @battle.scene, false)
# Log HP healing items
if losthp > 0
power = hpItems[i]
@@ -140,28 +140,28 @@ class Battle::AI
end
end
# Prioritise using a HP restoration item
if usableHPItems.length>0 && (battler.hp<=battler.totalhp/4 ||
(battler.hp<=battler.totalhp/2 && pbAIRandom(100)<30))
usableHPItems.sort! { |a,b| (a[1]==b[1]) ? a[2]<=>b[2] : a[1]<=>b[1] }
if usableHPItems.length > 0 && (battler.hp <= battler.totalhp / 4 ||
(battler.hp <= battler.totalhp / 2 && pbAIRandom(100) < 30))
usableHPItems.sort! { |a, b| (a[1] == b[1]) ? a[2] <=> b[2] : a[1] <=> b[1] }
prevItem = nil
usableHPItems.each do |i|
return i[0], idxTarget if i[2]>=losthp
return i[0], idxTarget if i[2] >= losthp
prevItem = i
end
return prevItem[0], idxTarget
end
# Next prioritise using a status-curing item
if usableStatusItems.length>0 && pbAIRandom(100)<40
usableStatusItems.sort! { |a,b| a[1]<=>b[1] }
if usableStatusItems.length > 0 && pbAIRandom(100) < 40
usableStatusItems.sort! { |a, b| a[1] <=> b[1] }
return usableStatusItems[0][0], idxTarget
end
# Next try using an X item
if usableXItems.length>0 && pbAIRandom(100)<30
usableXItems.sort! { |a,b| (a[1]==b[1]) ? a[2]<=>b[2] : a[1]<=>b[1] }
if usableXItems.length > 0 && pbAIRandom(100) < 30
usableXItems.sort! { |a, b| (a[1] == b[1]) ? a[2] <=> b[2] : a[1] <=> b[1] }
prevItem = nil
usableXItems.each do |i|
break if prevItem && i[1]>prevItem[1]
return i[0], idxTarget if i[1]+i[2]>=6
break if prevItem && i[1] > prevItem[1]
return i[0], idxTarget if i[1] + i[2] >= 6
prevItem = i
end
return prevItem[0], idxTarget

View File

@@ -3,10 +3,10 @@ class Battle::AI
# Decide whether the opponent should switch Pokémon
#=============================================================================
def pbEnemyShouldWithdraw?(idxBattler)
return pbEnemyShouldWithdrawEx?(idxBattler,false)
return pbEnemyShouldWithdrawEx?(idxBattler, false)
end
def pbEnemyShouldWithdrawEx?(idxBattler,forceSwitch)
def pbEnemyShouldWithdrawEx?(idxBattler, forceSwitch)
return false if @battle.wildBattle?
shouldSwitch = forceSwitch
batonPass = -1
@@ -15,13 +15,13 @@ class Battle::AI
battler = @battle.battlers[idxBattler]
# If Pokémon is within 6 levels of the foe, and foe's last move was
# super-effective and powerful
if !shouldSwitch && battler.turnCount>0 && skill>=PBTrainerAI.highSkill
if !shouldSwitch && battler.turnCount > 0 && skill >= PBTrainerAI.highSkill
target = battler.pbDirectOpposing(true)
if !target.fainted? && target.lastMoveUsed &&
(target.level-battler.level).abs<=6
(target.level - battler.level).abs <= 6
moveData = GameData::Move.get(target.lastMoveUsed)
moveType = moveData.type
typeMod = pbCalcTypeMod(moveType,target,battler)
typeMod = pbCalcTypeMod(moveType, target, battler)
if Effectiveness.super_effective?(typeMod) && moveData.base_damage > 50
switchChance = (moveData.base_damage > 70) ? 30 : 20
shouldSwitch = (pbAIRandom(100) < switchChance)
@@ -30,14 +30,14 @@ class Battle::AI
end
# Pokémon can't do anything (must have been in battle for at least 5 rounds)
if !@battle.pbCanChooseAnyMove?(idxBattler) &&
battler.turnCount && battler.turnCount>=5
battler.turnCount && battler.turnCount >= 5
shouldSwitch = true
end
# Pokémon is Perish Songed and has Baton Pass
if skill>=PBTrainerAI.highSkill && battler.effects[PBEffects::PerishSong]==1
battler.eachMoveWithIndex do |m,i|
next if m.function!="SwitchOutUserPassOnEffects" # Baton Pass
next if !@battle.pbCanChooseMove?(idxBattler,i,false)
if skill >= PBTrainerAI.highSkill && battler.effects[PBEffects::PerishSong] == 1
battler.eachMoveWithIndex do |m, i|
next if m.function != "SwitchOutUserPassOnEffects" # Baton Pass
next if !@battle.pbCanChooseMove?(idxBattler, i, false)
batonPass = i
break
end
@@ -45,96 +45,96 @@ class Battle::AI
# Pokémon will faint because of bad poisoning at the end of this round, but
# would survive at least one more round if it were regular poisoning instead
if battler.status == :POISON && battler.statusCount > 0 &&
skill>=PBTrainerAI.highSkill
toxicHP = battler.totalhp/16
nextToxicHP = toxicHP*(battler.effects[PBEffects::Toxic]+1)
if battler.hp<=nextToxicHP && battler.hp>toxicHP*2
shouldSwitch = true if pbAIRandom(100)<80
skill >= PBTrainerAI.highSkill
toxicHP = battler.totalhp / 16
nextToxicHP = toxicHP * (battler.effects[PBEffects::Toxic] + 1)
if battler.hp <= nextToxicHP && battler.hp > toxicHP * 2
shouldSwitch = true if pbAIRandom(100) < 80
end
end
# Pokémon is Encored into an unfavourable move
if battler.effects[PBEffects::Encore]>0 && skill>=PBTrainerAI.mediumSkill
if battler.effects[PBEffects::Encore] > 0 && skill >= PBTrainerAI.mediumSkill
idxEncoredMove = battler.pbEncoredMoveIndex
if idxEncoredMove>=0
if idxEncoredMove >= 0
scoreSum = 0
scoreCount = 0
battler.allOpposing.each do |b|
scoreSum += pbGetMoveScore(battler.moves[idxEncoredMove],battler,b,skill)
scoreSum += pbGetMoveScore(battler.moves[idxEncoredMove], battler, b, skill)
scoreCount += 1
end
if scoreCount>0 && scoreSum/scoreCount<=20
shouldSwitch = true if pbAIRandom(100)<80
if scoreCount > 0 && scoreSum / scoreCount <= 20
shouldSwitch = true if pbAIRandom(100) < 80
end
end
end
# If there is a single foe and it is resting after Hyper Beam or is
# Truanting (i.e. free turn)
if @battle.pbSideSize(battler.index+1)==1 &&
!battler.pbDirectOpposing.fainted? && skill>=PBTrainerAI.highSkill
if @battle.pbSideSize(battler.index + 1) == 1 &&
!battler.pbDirectOpposing.fainted? && skill >= PBTrainerAI.highSkill
opp = battler.pbDirectOpposing
if opp.effects[PBEffects::HyperBeam]>0 ||
if opp.effects[PBEffects::HyperBeam] > 0 ||
(opp.hasActiveAbility?(:TRUANT) && opp.effects[PBEffects::Truant])
shouldSwitch = false if pbAIRandom(100)<80
shouldSwitch = false if pbAIRandom(100) < 80
end
end
# Sudden Death rule - I'm not sure what this means
if @battle.rules["suddendeath"] && battler.turnCount>0
if battler.hp<=battler.totalhp/4 && pbAIRandom(100)<30
if @battle.rules["suddendeath"] && battler.turnCount > 0
if battler.hp <= battler.totalhp / 4 && pbAIRandom(100) < 30
shouldSwitch = true
elsif battler.hp<=battler.totalhp/2 && pbAIRandom(100)<80
elsif battler.hp <= battler.totalhp / 2 && pbAIRandom(100) < 80
shouldSwitch = true
end
end
# Pokémon is about to faint because of Perish Song
if battler.effects[PBEffects::PerishSong]==1
if battler.effects[PBEffects::PerishSong] == 1
shouldSwitch = true
end
if shouldSwitch
list = []
idxPartyStart, idxPartyEnd = @battle.pbTeamIndexRangeFromBattlerIndex(idxBattler)
@battle.pbParty(idxBattler).each_with_index do |pkmn,i|
@battle.pbParty(idxBattler).each_with_index do |pkmn, i|
next if i == idxPartyEnd - 1 # Don't choose to switch in ace
next if !@battle.pbCanSwitch?(idxBattler,i)
next if !@battle.pbCanSwitch?(idxBattler, i)
# If perish count is 1, it may be worth it to switch
# even with Spikes, since Perish Song's effect will end
if battler.effects[PBEffects::PerishSong]!=1
if battler.effects[PBEffects::PerishSong] != 1
# Will contain effects that recommend against switching
spikes = battler.pbOwnSide.effects[PBEffects::Spikes]
# Don't switch to this if too little HP
if spikes>0
spikesDmg = [8,6,4][spikes-1]
if pkmn.hp<=pkmn.totalhp/spikesDmg
if spikes > 0
spikesDmg = [8, 6, 4][spikes - 1]
if pkmn.hp <= pkmn.totalhp / spikesDmg
next if !pkmn.hasType?(:FLYING) && !pkmn.hasActiveAbility?(:LEVITATE)
end
end
end
# moveType is the type of the target's last used move
if moveType && Effectiveness.ineffective?(pbCalcTypeMod(moveType,battler,battler))
if moveType && Effectiveness.ineffective?(pbCalcTypeMod(moveType, battler, battler))
weight = 65
typeMod = pbCalcTypeModPokemon(pkmn,battler.pbDirectOpposing(true))
typeMod = pbCalcTypeModPokemon(pkmn, battler.pbDirectOpposing(true))
if Effectiveness.super_effective?(typeMod)
# Greater weight if new Pokemon's type is effective against target
weight = 85
end
list.unshift(i) if pbAIRandom(100)<weight # Put this Pokemon first
elsif moveType && Effectiveness.resistant?(pbCalcTypeMod(moveType,battler,battler))
list.unshift(i) if pbAIRandom(100) < weight # Put this Pokemon first
elsif moveType && Effectiveness.resistant?(pbCalcTypeMod(moveType, battler, battler))
weight = 40
typeMod = pbCalcTypeModPokemon(pkmn,battler.pbDirectOpposing(true))
typeMod = pbCalcTypeModPokemon(pkmn, battler.pbDirectOpposing(true))
if Effectiveness.super_effective?(typeMod)
# Greater weight if new Pokemon's type is effective against target
weight = 60
end
list.unshift(i) if pbAIRandom(100)<weight # Put this Pokemon first
list.unshift(i) if pbAIRandom(100) < weight # Put this Pokemon first
else
list.push(i) # put this Pokemon last
end
end
if list.length>0
if batonPass>=0 && @battle.pbRegisterMove(idxBattler,batonPass,false)
if list.length > 0
if batonPass >= 0 && @battle.pbRegisterMove(idxBattler, batonPass, false)
PBDebug.log("[AI] #{battler.pbThis} (#{idxBattler}) will use Baton Pass to avoid Perish Song")
return true
end
if @battle.pbRegisterSwitch(idxBattler,list[0])
if @battle.pbRegisterSwitch(idxBattler, list[0])
PBDebug.log("[AI] #{battler.pbThis} (#{idxBattler}) will switch with " +
"#{@battle.pbParty(idxBattler)[list[0]].name}")
return true
@@ -147,19 +147,19 @@ class Battle::AI
#=============================================================================
# Choose a replacement Pokémon
#=============================================================================
def pbDefaultChooseNewEnemy(idxBattler,party)
def pbDefaultChooseNewEnemy(idxBattler, party)
enemies = []
idxPartyStart, idxPartyEnd = @battle.pbTeamIndexRangeFromBattlerIndex(idxBattler)
party.each_with_index do |_p,i|
party.each_with_index do |_p, i|
next if i == idxPartyEnd - 1 && enemies.length > 0 # Ignore ace if possible
enemies.push(i) if @battle.pbCanSwitchLax?(idxBattler,i)
enemies.push(i) if @battle.pbCanSwitchLax?(idxBattler, i)
end
return -1 if enemies.length==0
return pbChooseBestNewEnemy(idxBattler,party,enemies)
return -1 if enemies.length == 0
return pbChooseBestNewEnemy(idxBattler, party, enemies)
end
def pbChooseBestNewEnemy(idxBattler,party,enemies)
return -1 if !enemies || enemies.length==0
def pbChooseBestNewEnemy(idxBattler, party, enemies)
return -1 if !enemies || enemies.length == 0
best = -1
bestSum = 0
enemies.each do |i|
@@ -172,7 +172,7 @@ class Battle::AI
sum += Effectiveness.calculate(m.type, bTypes[0], bTypes[1], bTypes[2])
end
end
if best==-1 || sum>bestSum
if best == -1 || sum > bestSum
best = i
bestSum = sum
end

View File

@@ -14,12 +14,12 @@ class Battle::AI
# NOTE: A move is only added to the choices array if it has a non-zero
# score.
choices = []
user.eachMoveWithIndex do |_m,i|
next if !@battle.pbCanChooseMove?(idxBattler,i,false)
user.eachMoveWithIndex do |_m, i|
next if !@battle.pbCanChooseMove?(idxBattler, i, false)
if wildBattler
pbRegisterMoveWild(user,i,choices)
pbRegisterMoveWild(user, i, choices)
else
pbRegisterMoveTrainer(user,i,choices,skill)
pbRegisterMoveTrainer(user, i, choices, skill)
end
end
# Figure out useful information about the choices
@@ -27,54 +27,54 @@ class Battle::AI
maxScore = 0
choices.each do |c|
totalScore += c[1]
maxScore = c[1] if maxScore<c[1]
maxScore = c[1] if maxScore < c[1]
end
# Log the available choices
if $INTERNAL
logMsg = "[AI] Move choices for #{user.pbThis(true)} (#{user.index}): "
choices.each_with_index do |c,i|
choices.each_with_index do |c, i|
logMsg += "#{user.moves[c[0]].name}=#{c[1]}"
logMsg += " (target #{c[2]})" if c[2]>=0
logMsg += ", " if i<choices.length-1
logMsg += " (target #{c[2]})" if c[2] >= 0
logMsg += ", " if i < choices.length - 1
end
PBDebug.log(logMsg)
end
# Find any preferred moves and just choose from them
if !wildBattler && skill>=PBTrainerAI.highSkill && maxScore>100
if !wildBattler && skill >= PBTrainerAI.highSkill && maxScore > 100
stDev = pbStdDev(choices)
if stDev>=40 && pbAIRandom(100)<90
if stDev >= 40 && pbAIRandom(100) < 90
preferredMoves = []
choices.each do |c|
next if c[1]<200 && c[1]<maxScore*0.8
next if c[1] < 200 && c[1] < maxScore * 0.8
preferredMoves.push(c)
preferredMoves.push(c) if c[1]==maxScore # Doubly prefer the best move
preferredMoves.push(c) if c[1] == maxScore # Doubly prefer the best move
end
if preferredMoves.length>0
if preferredMoves.length > 0
m = preferredMoves[pbAIRandom(preferredMoves.length)]
PBDebug.log("[AI] #{user.pbThis} (#{user.index}) prefers #{user.moves[m[0]].name}")
@battle.pbRegisterMove(idxBattler,m[0],false)
@battle.pbRegisterTarget(idxBattler,m[2]) if m[2]>=0
@battle.pbRegisterMove(idxBattler, m[0], false)
@battle.pbRegisterTarget(idxBattler, m[2]) if m[2] >= 0
return
end
end
end
# Decide whether all choices are bad, and if so, try switching instead
if !wildBattler && skill>=PBTrainerAI.highSkill
if !wildBattler && skill >= PBTrainerAI.highSkill
badMoves = false
if (maxScore<=20 && user.turnCount>2) ||
(maxScore<=40 && user.turnCount>5)
badMoves = true if pbAIRandom(100)<80
if (maxScore <= 20 && user.turnCount > 2) ||
(maxScore <= 40 && user.turnCount > 5)
badMoves = true if pbAIRandom(100) < 80
end
if !badMoves && totalScore<100 && user.turnCount>1
if !badMoves && totalScore < 100 && user.turnCount > 1
badMoves = true
choices.each do |c|
next if !user.moves[c[0]].damagingMove?
badMoves = false
break
end
badMoves = false if badMoves && pbAIRandom(100)<10
badMoves = false if badMoves && pbAIRandom(100) < 10
end
if badMoves && pbEnemyShouldWithdrawEx?(idxBattler,true)
if badMoves && pbEnemyShouldWithdrawEx?(idxBattler, true)
if $INTERNAL
PBDebug.log("[AI] #{user.pbThis} (#{user.index}) will switch due to terrible moves")
end
@@ -82,13 +82,13 @@ class Battle::AI
end
end
# If there are no calculated choices, pick one at random
if choices.length==0
if choices.length == 0
PBDebug.log("[AI] #{user.pbThis} (#{user.index}) doesn't want to use any moves; picking one at random")
user.eachMoveWithIndex do |_m,i|
next if !@battle.pbCanChooseMove?(idxBattler,i,false)
choices.push([i,100,-1]) # Move index, score, target
user.eachMoveWithIndex do |_m, i|
next if !@battle.pbCanChooseMove?(idxBattler, i, false)
choices.push([i, 100, -1]) # Move index, score, target
end
if choices.length==0 # No moves are physically possible to use; use Struggle
if choices.length == 0 # No moves are physically possible to use; use Struggle
@battle.pbAutoChooseMove(user.index)
end
end
@@ -96,9 +96,9 @@ class Battle::AI
randNum = pbAIRandom(totalScore)
choices.each do |c|
randNum -= c[1]
next if randNum>=0
@battle.pbRegisterMove(idxBattler,c[0],false)
@battle.pbRegisterTarget(idxBattler,c[2]) if c[2]>=0
next if randNum >= 0
@battle.pbRegisterMove(idxBattler, c[0], false)
@battle.pbRegisterTarget(idxBattler, c[2]) if c[2] >= 0
break
end
# Log the result
@@ -111,40 +111,40 @@ class Battle::AI
# Get scores for the given move against each possible target
#=============================================================================
# Wild Pokémon choose their moves randomly.
def pbRegisterMoveWild(_user,idxMove,choices)
choices.push([idxMove,100,-1]) # Move index, score, target
def pbRegisterMoveWild(_user, idxMove, choices)
choices.push([idxMove, 100, -1]) # Move index, score, target
end
# Trainer Pokémon calculate how much they want to use each of their moves.
def pbRegisterMoveTrainer(user,idxMove,choices,skill)
def pbRegisterMoveTrainer(user, idxMove, choices, skill)
move = user.moves[idxMove]
target_data = move.pbTarget(user)
if target_data.num_targets > 1
# If move affects multiple battlers and you don't choose a particular one
totalScore = 0
@battle.allBattlers.each do |b|
next if !@battle.pbMoveCanTarget?(user.index,b.index,target_data)
score = pbGetMoveScore(move,user,b,skill)
next if !@battle.pbMoveCanTarget?(user.index, b.index, target_data)
score = pbGetMoveScore(move, user, b, skill)
totalScore += ((user.opposes?(b)) ? score : -score)
end
choices.push([idxMove,totalScore,-1]) if totalScore>0
choices.push([idxMove, totalScore, -1]) if totalScore > 0
elsif target_data.num_targets == 0
# If move has no targets, affects the user, a side or the whole field
score = pbGetMoveScore(move,user,user,skill)
choices.push([idxMove,score,-1]) if score>0
score = pbGetMoveScore(move, user, user, skill)
choices.push([idxMove, score, -1]) if score > 0
else
# If move affects one battler and you have to choose which one
scoresAndTargets = []
@battle.allBattlers.each do |b|
next if !@battle.pbMoveCanTarget?(user.index,b.index,target_data)
next if !@battle.pbMoveCanTarget?(user.index, b.index, target_data)
next if target_data.targets_foe && !user.opposes?(b)
score = pbGetMoveScore(move,user,b,skill)
scoresAndTargets.push([score,b.index]) if score>0
score = pbGetMoveScore(move, user, b, skill)
scoresAndTargets.push([score, b.index]) if score > 0
end
if scoresAndTargets.length>0
if scoresAndTargets.length > 0
# Get the one best target for the move
scoresAndTargets.sort! { |a,b| b[0]<=>a[0] }
choices.push([idxMove,scoresAndTargets[0][0],scoresAndTargets[0][1]])
scoresAndTargets.sort! { |a, b| b[0] <=> a[0] }
choices.push([idxMove, scoresAndTargets[0][0], scoresAndTargets[0][1]])
end
end
end
@@ -152,31 +152,31 @@ class Battle::AI
#=============================================================================
# Get a score for the given move being used against the given target
#=============================================================================
def pbGetMoveScore(move,user,target,skill = 100)
skill = PBTrainerAI.minimumSkill if skill<PBTrainerAI.minimumSkill
def pbGetMoveScore(move, user, target, skill = 100)
skill = PBTrainerAI.minimumSkill if skill < PBTrainerAI.minimumSkill
score = 100
score = pbGetMoveScoreFunctionCode(score,move,user,target,skill)
score = pbGetMoveScoreFunctionCode(score, move, user, target, skill)
# A score of 0 here means it absolutely should not be used
return 0 if score<=0
if skill>=PBTrainerAI.mediumSkill
return 0 if score <= 0
if skill >= PBTrainerAI.mediumSkill
# Prefer damaging moves if AI has no more Pokémon or AI is less clever
if @battle.pbAbleNonActiveCount(user.idxOwnSide)==0
if !(skill>=PBTrainerAI.highSkill && @battle.pbAbleNonActiveCount(target.idxOwnSide)>0)
if @battle.pbAbleNonActiveCount(user.idxOwnSide) == 0
if !(skill >= PBTrainerAI.highSkill && @battle.pbAbleNonActiveCount(target.idxOwnSide) > 0)
if move.statusMove?
score /= 1.5
elsif target.hp<=target.totalhp/2
elsif target.hp <= target.totalhp / 2
score *= 1.5
end
end
end
# Don't prefer attacking the target if they'd be semi-invulnerable
if skill>=PBTrainerAI.highSkill && move.accuracy>0 &&
(target.semiInvulnerable? || target.effects[PBEffects::SkyDrop]>=0)
if skill >= PBTrainerAI.highSkill && move.accuracy > 0 &&
(target.semiInvulnerable? || target.effects[PBEffects::SkyDrop] >= 0)
miss = true
miss = false if user.hasActiveAbility?(:NOGUARD) || target.hasActiveAbility?(:NOGUARD)
if miss && pbRoughStat(user,:SPEED,skill)>pbRoughStat(target,:SPEED,skill)
if miss && pbRoughStat(user, :SPEED, skill) > pbRoughStat(target, :SPEED, skill)
# Knows what can get past semi-invulnerability
if target.effects[PBEffects::SkyDrop]>=0
if target.effects[PBEffects::SkyDrop] >= 0
miss = false if move.hitsFlyingTargets?
else
if target.inTwoTurnAttack?("TwoTurnAttackInvulnerableInSky",
@@ -193,13 +193,13 @@ class Battle::AI
score -= 80 if miss
end
# Pick a good move for the Choice items
if user.hasActiveItem?([:CHOICEBAND,:CHOICESPECS,:CHOICESCARF]) ||
if user.hasActiveItem?([:CHOICEBAND, :CHOICESPECS, :CHOICESCARF]) ||
user.hasActiveAbility?(:GORILLATACTICS)
if move.baseDamage>=60
if move.baseDamage >= 60
score += 60
elsif move.damagingMove?
score += 30
elsif move.function=="UserTargetSwapItems"
elsif move.function == "UserTargetSwapItems"
score += 70 # Trick
else
score -= 60
@@ -236,17 +236,17 @@ class Battle::AI
end
# Adjust score based on how much damage it can deal
if move.damagingMove?
score = pbGetMoveScoreDamage(score,move,user,target,skill)
score = pbGetMoveScoreDamage(score, move, user, target, skill)
else # Status moves
# Don't prefer attacks which don't deal damage
score -= 10
# Account for accuracy of move
accuracy = pbRoughAccuracy(move,user,target,skill)
score *= accuracy/100.0
score = 0 if score<=10 && skill>=PBTrainerAI.highSkill
accuracy = pbRoughAccuracy(move, user, target, skill)
score *= accuracy / 100.0
score = 0 if score <= 10 && skill >= PBTrainerAI.highSkill
end
score = score.to_i
score = 0 if score<0
score = 0 if score < 0
return score
end
@@ -254,25 +254,25 @@ class Battle::AI
# Add to a move's score based on how much damage it will deal (as a percentage
# of the target's current HP)
#=============================================================================
def pbGetMoveScoreDamage(score,move,user,target,skill)
def pbGetMoveScoreDamage(score, move, user, target, skill)
# Don't prefer moves that are ineffective because of abilities or effects
return 0 if score<=0 || pbCheckMoveImmunity(score,move,user,target,skill)
return 0 if score <= 0 || pbCheckMoveImmunity(score, move, user, target, skill)
# Calculate how much damage the move will do (roughly)
baseDmg = pbMoveBaseDamage(move,user,target,skill)
realDamage = pbRoughDamage(move,user,target,skill,baseDmg)
baseDmg = pbMoveBaseDamage(move, user, target, skill)
realDamage = pbRoughDamage(move, user, target, skill, baseDmg)
# Account for accuracy of move
accuracy = pbRoughAccuracy(move,user,target,skill)
realDamage *= accuracy/100.0
accuracy = pbRoughAccuracy(move, user, target, skill)
realDamage *= accuracy / 100.0
# Two-turn attacks waste 2 turns to deal one lot of damage
if move.chargingTurnMove? || move.function=="AttackAndSkipNextTurn" # Hyper Beam
realDamage *= 2/3 # Not halved because semi-invulnerable during use or hits first turn
if move.chargingTurnMove? || move.function == "AttackAndSkipNextTurn" # Hyper Beam
realDamage *= 2 / 3 # Not halved because semi-invulnerable during use or hits first turn
end
# Prefer flinching external effects (note that move effects which cause
# flinching are dealt with in the function code part of score calculation)
if skill>=PBTrainerAI.mediumSkill && !move.flinchingMove?
if skill >= PBTrainerAI.mediumSkill && !move.flinchingMove?
if !target.hasActiveAbility?(:INNERFOCUS) &&
!target.hasActiveAbility?(:SHIELDDUST) &&
target.effects[PBEffects::Substitute]==0
target.effects[PBEffects::Substitute] == 0
canFlinch = false
if user.hasActiveItem?([:KINGSROCK, :RAZORFANG])
canFlinch = true
@@ -283,14 +283,14 @@ class Battle::AI
end
end
# Convert damage to percentage of target's remaining HP
damagePercentage = realDamage*100.0/target.hp
damagePercentage = realDamage * 100.0 / target.hp
# Don't prefer weak attacks
# damagePercentage /= 2 if damagePercentage<20
# Prefer damaging attack if level difference is significantly high
damagePercentage *= 1.2 if user.level-10>target.level
damagePercentage *= 1.2 if user.level - 10 > target.level
# Adjust score
damagePercentage = 120 if damagePercentage>120 # Treat all lethal moves the same
damagePercentage += 40 if damagePercentage>100 # Prefer moves likely to be lethal
damagePercentage = 120 if damagePercentage > 120 # Treat all lethal moves the same
damagePercentage += 40 if damagePercentage > 100 # Prefer moves likely to be lethal
score += damagePercentage.to_i
return score
end

Some files were not shown because too many files have changed in this diff Show More