Changed: PokemonEvolution --- Left +++ Right @@ -493,5 +493,7 @@ return poke if pokemon.level>=level when 5, 6 # Evolves if traded + return -1 when 7 # Evolves with item + return -1 when 8 return poke if pokemon.level>=level && pokemon.attack>pokemon.defense @@ -507,5 +509,7 @@ return poke if pokemon.level>=level when 14 # Shedinja + return -1 when 15 # Feebas, TODO + return -1 when 18 # Evolves during the day if holding item time=Time.now Changed: Audio --- Left +++ Right @@ -134,5 +134,5 @@ def Audio_bgm_play(name, volume, pitch, position = 0) - volume=0 if !getPlayMusic() +# volume=0 if !getPlayMusic() begin filename = canonicalize(RTP.getPath(name,[".mid",".mp3",".wma",".ogg",".wav",""])) @@ -152,7 +152,7 @@ def Audio_me_play(name, volume, pitch, position = 0) - volume=0 if !getPlayMusic() +# volume=0 if !getPlayMusic() begin - filename = canonicalize(rtpGetPath(name,[".mid",".mp3",".wma",".ogg",".wav",""])) + filename = canonicalize(RTP.getPath(name,[".mid",".mp3",".wma",".ogg",".wav",""])) if AudioState.bgmActive? bgmPosition=Kernel.Audio_bgm_get_position @@ -240,7 +240,7 @@ def Audio_bgs_play(name, volume, pitch, position = 0) - volume=0 if !getPlaySound() +# volume=0 if !getPlaySound() begin - filename = canonicalize(rtpGetPath(name,[".mid",".mp3",".wma",".ogg",".wav",""])) + filename = canonicalize(RTP.getPath(name,[".mid",".mp3",".wma",".ogg",".wav",""])) AudioState::AudioContextPlay.call(AudioState.bgsContext,filename,volume,pitch,position,0) rescue @@ -259,7 +259,7 @@ def Audio_se_play(name, volume, pitch, position = 0) - volume=0 if !getPlaySound() +# volume=0 if !getPlaySound() begin - filename = canonicalize(rtpGetPath(name,[".mid",".mp3",".wma",".ogg",".wav",""])) + filename = canonicalize(RTP.getPath(name,[".mid",".mp3",".wma",".ogg",".wav",""])) AudioState::AudioContextSEPlay.call(AudioState.seContext,filename,volume,pitch,position) rescue Changed: Game_Player_ --- Left +++ Right @@ -7,18 +7,4 @@ #============================================================================== -def pbAddDependency(event) - $PokemonTemp.dependentEvents.addEvent(event) -end -def pbRemoveDependency(event) - $PokemonTemp.dependentEvents.removeEvent(event) -end - -def pbAddDependency2(eventID, eventName, commonEvent) - $PokemonTemp.dependentEvents.addEvent($game_map.events[eventID],eventName,commonEvent) -end -def pbRemoveDependency2(eventName) - $PokemonTemp.dependentEvents.removeEventByName(eventName) -end - class Game_Player < Game_Character def map Changed: PokemonMessages --- Left +++ Right @@ -91,12 +91,12 @@ end # Update windows - @help_window.update - @party_command_window.update - @actor_command_window.update - @status_window.update + @help_window.update if @help_window + @party_command_window.update if @party_command_window + @actor_command_window.update if @actor_command_window + @status_window.update if @status_window $game_temp.message_window_showing=oldmws - @message_window.update + @message_window.update if @message_window # Update sprite set - @spriteset.update + @spriteset.update if @spriteset end end @@ -233,10 +233,10 @@ module InterpreterMixin - def pbGlobalLock + def pbGlobalLock # Freezes all events on the map (for use at the beginning of common events) for event in $game_map.events.values event.minilock end end - def pbGlobalUnlock + def pbGlobalUnlock # Unfreezes all events on the map (for use at the end of common events) for event in $game_map.events.values event.unlock @@ -298,6 +298,4 @@ when 113 # Break Loop i=pbBreakLoop(i) - when 115 # Exit Event Processing - i=-1 when 119 # Jump to Label i=pbJumpToLabel(i,@list[i].parameters[0]) @@ -409,8 +407,14 @@ class Game_Interpreter include InterpreterMixin + @@immediateDisplayAfterWait=false + @buttonInput=false def command_105 + return false if @buttonInput + @buttonInput=true pbButtonInputProcessing(@list[@index].parameters[0]) + @buttonInput=false @index+=1 + return true end def command_101 @@ -506,8 +510,14 @@ class Interpreter include InterpreterMixin + @@immediateDisplayAfterWait=false + @buttonInput=false def command_105 + return false if @buttonInput + @buttonInput=true pbButtonInputProcessing(@list[@index].parameters[0]) + @buttonInput=false @index+=1 + return true end def command_101 @@ -1139,6 +1149,8 @@ # internal function -def pbDisplayGoldWindow(msgwindow) - moneyString="" + + +def pbGetGoldString +moneyString="" if $Trainer moneyString=_INTL("${1}",$Trainer.money) @@ -1150,4 +1162,9 @@ end end + return moneyString +end + +def pbDisplayGoldWindow(msgwindow) + moneyString=pbGetGoldString() goldwindow=Window_UnformattedTextPokemon.newWithSize( _INTL("MONEY:\n{1}",moneyString),0,0,32,32,msgwindow.viewport) @@ -1177,5 +1194,5 @@ $game_system.bgm_play(param) else - Audio.se_play("Audio/BGM/"+param.name,param.volume,param.pitch) + Audio.bgm_play(canonicalize("Audio/BGM/"+param.name),param.volume,param.pitch) end end @@ -1196,5 +1213,5 @@ $game_system.me_play(param) else - Audio.se_play("Audio/ME/"+param.name,param.volume,param.pitch) + Audio.me_play(canonicalize("Audio/ME/"+param.name),param.volume,param.pitch) end end @@ -1215,5 +1232,5 @@ $game_system.se_play(param) else - Audio.se_play("Audio/SE/"+param.name,param.volume,param.pitch) + Audio.se_play(canonicalize("Audio/SE/"+param.name),param.volume,param.pitch) end end @@ -1240,5 +1257,5 @@ cmdvariable=0 cmdIfCancel=0 - waitcount=0 + msgwindow.waitcount=0 autoresume=false text=message.clone @@ -1253,4 +1270,7 @@ } end + text.gsub!(/\\[Ss][Ii][Gg][Nn]\[([^\]]*)\]/){ + next "\\op\\cl\\ts[]\\w["+$1+"]" + } text.gsub!(/\\[Pp][Nn]/,$Trainer.name) if $Trainer text.gsub!(/\\[Pp][Mm]/,_INTL("${1}",$Trainer.money)) if $Trainer @@ -1288,5 +1308,5 @@ textchunks=[] controls=[] - while text[/(?:\\([WwFf]|[Ff][Ff]|[Mm][Ee]|[Ss][Ee]|[Ww][Tt]|[Ww][Tt][Nn][Pp]|[Cc][Hh])\[([^\]]*)\]|\\([Gg]|[Ww][Dd]|[Ww][Mm]|[Ww][Uu]|[\.]|[\|]|[\!]|[\x5E])())/i] + while text[/(?:\\([WwFf]|[Ff][Ff]|[Tt][Ss]|[Cc][Ll]|[Mm][Ee]|[Ss][Ee]|[Ww][Tt]|[Ww][Tt][Nn][Pp]|[Cc][Hh])\[([^\]]*)\]|\\([Gg]|[Ww][Dd]|[Ww][Mm]|[Oo][Pp]|[Cc][Ll]|[Ww][Uu]|[\.]|[\|]|[\!]|[\x5E])())/i] textchunks.push($~.pre_match) if $~[1] @@ -1314,4 +1334,7 @@ text=textchunks.join("") unformattedText=toUnformattedText(text) + signWaitCount=0 + haveSpecialClose=false + specialCloseSE="" for i in 0...controls.length control=controls[i][0] @@ -1320,4 +1343,10 @@ facewindow.dispose if facewindow facewindow=PictureWindow.new("Graphics/Pictures/#{param}") + elsif control=="op" + signWaitCount=21 + elsif control=="cl" + text=text.sub(/\001$/,"") + haveSpecialClose=true + specialCloseSE=param elsif control=="se" && controls[i][2]==0 startSE=param @@ -1340,5 +1369,5 @@ if startSE!=nil pbSECommand(pbStringToAudioFile(startSE)) - elsif sound + elsif sound && signWaitCount==0 pbPlayDecisionSE() end @@ -1356,4 +1385,5 @@ facewindow.z=msgwindow.z end + atTop=(msgwindow.y==0) ########## Show text ############################# msgwindow.text=text @@ -1363,6 +1393,14 @@ count+=1 end + if signWaitCount>0 + signWaitCount-=1 + if atTop + msgwindow.y=-(msgwindow.height*(signWaitCount)/20) + else + msgwindow.y=Graphics.height-(msgwindow.height*(20-signWaitCount)/20) + end + end for i in 0...controls.length - if controls[i] && controls[i][2]<=msgwindow.position && waitcount==0 + if controls[i] && controls[i][2]<=msgwindow.position && msgwindow.waitcount==0 control=controls[i][0] param=controls[i][1] @@ -1373,4 +1411,10 @@ facewindow.viewport=msgwindow.viewport facewindow.z=msgwindow.z + elsif control=="ts" + if param=="" + msgwindow.textspeed=-999 + else + msgwindow.textspeed=param.to_i + end elsif control=="ff" facewindow.dispose if facewindow @@ -1384,21 +1428,26 @@ elsif control=="wu" msgwindow.y=0 + atTop=true msgback.y=msgwindow.y if msgback pbPositionNearMsgWindow(facewindow,msgwindow,:left) + msgwindow.y=-(msgwindow.height*(signWaitCount)/20) elsif control=="wm" + atTop=false msgwindow.y=(Graphics.height/2)-(msgwindow.height/2) msgback.y=msgwindow.y if msgback pbPositionNearMsgWindow(facewindow,msgwindow,:left) elsif control=="wd" + atTop=false msgwindow.y=(Graphics.height)-(msgwindow.height) msgback.y=msgwindow.y if msgback pbPositionNearMsgWindow(facewindow,msgwindow,:left) + msgwindow.y=Graphics.height-(msgwindow.height*(20-signWaitCount)/20) elsif control=="." - waitcount+=Graphics.frame_rate/4 + msgwindow.waitcount+=Graphics.frame_rate/4 elsif control=="|" - waitcount+=Graphics.frame_rate + msgwindow.waitcount+=Graphics.frame_rate elsif control=="wt" # Wait param=param.sub(/^\s+/,"").sub(/\s+$/,"") - waitcount+=param.to_i*2 + msgwindow.waitcount+=param.to_i*2 elsif control=="w" # Windowskin if param=="" @@ -1411,5 +1460,5 @@ elsif control=="wtnp" # Wait, no pause param=param.sub(/^\s+/,"").sub(/\s+$/,"") - waitcount=param.to_i*2 + msgwindow.waitcount=param.to_i*2 autoresume=true elsif control=="se" # Play SE @@ -1435,5 +1484,5 @@ break end - if autoresume && waitcount==0 + if autoresume && msgwindow.waitcount==0 msgwindow.resume if msgwindow.busy? break if !msgwindow.busy? @@ -1444,13 +1493,9 @@ msgwindow.resume else - break + break if signWaitCount==0 end end pbUpdateSceneMap - if waitcount>0 - waitcount-=1 - else - msgwindow.update - end + msgwindow.update end until delay==count && !msgwindow.busy? Input.update # Must call Input.update again to avoid extra triggers @@ -1467,4 +1512,19 @@ goldwindow.dispose if goldwindow facewindow.dispose if facewindow + if haveSpecialClose + pbSECommand(pbStringToAudioFile(specialCloseSE)) + atTop=(msgwindow.y==0) + for i in 0..20 + if atTop + msgwindow.y=-(msgwindow.height*(i)/20) + else + msgwindow.y=Graphics.height-(msgwindow.height*(20-i)/20) + end + Graphics.update + Input.update + pbUpdateSceneMap + msgwindow.update + end + end return ret end Changed: SpriteWindow --- Left +++ Right @@ -2701,5 +2701,5 @@ refresh end - def initialize(text) + def initialize(text="") super(0,0,33,33) self.contents=Bitmap.new(1,1) @@ -2728,4 +2728,8 @@ return dims end + def setTextToFit(text,maxwidth=-1) + resizeToFit(text,maxwidth) + self.text=text + end def resizeToFit(text,maxwidth=-1) # maxwidth is maximum acceptable window width dims=resizeToFitInternal(text,maxwidth) @@ -2763,5 +2767,12 @@ @frameskipChanged=true end + def waitcount + @waitcount + end + def waitcount=(value) + @waitcount=(value<=0) ? 0 : value + end def setText(value) + @waitcount=0 @curchar=0 @drawncurchar=-1 @@ -2893,5 +2904,5 @@ end end - def initialize(text) + def initialize(text="") @cursorMode=CURSORMODE @endOfText=nil @@ -2962,4 +2973,8 @@ redrawText end + def setTextToFit(text,maxwidth=-1) + resizeToFit(text,maxwidth) + self.text=text + end def resizeToFit(text,maxwidth=-1) dims=resizeToFitInternal(text,maxwidth) @@ -3112,8 +3127,13 @@ @pausesprite.update end + if @waitcount>0 + @waitcount-=1 + return + end if busy? refresh if !@frameskipChanged updateInternal - refresh if @frameskipChanged # needed to allow "textspeed=-999" to work seamlessly + # following line needed to allow "textspeed=-999" to work seamlessly + refresh if @frameskipChanged end @frameskipChanged=false Changed: DrawText --- Left +++ Right @@ -102,4 +102,5 @@ def RgbToColor(param) + return Font.default_color if !param baseint=param.to_i(16) if param.length==8 # 32-bit hex @@ -233,5 +234,11 @@ - Displays the icon X (in Graphics/Icons/). Added 2009-9-12 - - Displays the text in the given opacity (0-255) + - Displays the text in the given opacity (0-255) +Added 2009-10-19 + - Displays the text in outline format. +Added 2009-10-20 + ... - Color specification where B is the base color and + S is the shadow color. B and/or S can be omitted. A total of four formats are supported: + RRGGBBAA, RRGGBB, 16-bit RGB, and Window_Base color numbers. In addition, the syntax supports the following: ' - Converted to "'". @@ -247,8 +254,8 @@ def isWaitChar(x) - return (x=="\1" || x=="\2") + return (x=="\001" || x=="\002") end -FORMATREGEXP=/<(\/?)([Cc]|[Cc][2]|[Oo]|[Ff][Nn]|[Bb][Rr]|[Ff][Ss]|[Ii]|[Bb]|[Uu]|[Ss]|[Ii][Cc][Oo][Nn]|[Ii][Mm][Gg]|[Aa][Cc]|[Aa][Rr]|[Aa][Ll]|[Rr])(\s*\=\s*([^>]*))?>/ +FORMATREGEXP=/<(\/?)([Cc]|[Cc][2]|[Cc][33]|[Oo]|[Ff][Nn]|[Bb][Rr]|[Ff][Ss]|[Ii]|[Bb]|[Uu]|[Ss]|[Ii][Cc][Oo][Nn]|[Ii][Mm][Gg]|[Aa][Cc]|[Aa][Rr]|[Aa][Ll]|[Rr]|[Oo][Uu][Tt][Ll][Nn])(\s*\=\s*([^>]*))?>/ def toUnformattedText(text) @@ -310,5 +317,5 @@ havenl=true characters.push(["\n",x,y*lineheight+yDst,0,lineheight, - false,false,false,colorclone,nil,false,false,"",8,position]) + false,false,false,colorclone,nil,false,false,"",8,position,nil,0]) y+=1 x=0 @@ -345,5 +352,5 @@ colorclone,nil, false,false, - bitmap.font.name,bitmap.font.size,position]) + bitmap.font.name,bitmap.font.size,position,nil,0]) end x+=width @@ -446,4 +453,17 @@ end +def getLastColors(colorstack,opacitystack,defaultcolors) + colors=getLastParam(colorstack,defaultcolors) + opacity=getLastParam(opacitystack,255) + if opacity!=255 + colors=[ + Color.new(colors[0].red,colors[0].green,colors[0].blue, + colors[0].alpha*opacity/255), + colors[1] ? Color.new(colors[1].red,colors[1].green,colors[1].blue, + colors[1].alpha*opacity/255) : nil] + end + return colors +end + def getFormattedText( bitmap,xDst,yDst,widthDst,heightDst, @@ -509,4 +529,5 @@ boldcount=0 italiccount=0 + outlinecount=0 underlinecount=0 strikecount=0 @@ -559,4 +580,15 @@ colorstack.push([base,shadow]) end + elsif control=="c3" + if endtag + colorstack.pop + else + param=param.split(",") + # get pure colors unaffected by opacity + oldColors=getLastParam(colorstack,defaultcolors) + base=(param[0] && param[0]!="") ? RgbToColor(param[0]) : oldColors[0] + shadow=(param[1] && param[1]!="") ? RgbToColor(param[1]) : oldColors[1] + colorstack.push([base,shadow]) + end elsif control=="o" opacitystack.pop if endtag @@ -565,4 +597,7 @@ boldcount-=1 if endtag boldcount+=1 if !endtag + elsif control=="outln" + outlinecount-=1 if endtag + outlinecount+=1 if !endtag elsif control=="i" italiccount-=1 if endtag @@ -674,5 +709,5 @@ havenl=true characters.push(["\n",x,y*lineheight+yDst,0,lineheight, - false,false,false,defaultcolors[0],defaultcolors[1],false,false,"",8,position,nil]) + false,false,false,defaultcolors[0],defaultcolors[1],false,false,"",8,position,nil,0]) charactersInternal.push([alignment,y,0]) y+=1; @@ -688,5 +723,5 @@ havenl=true characters.push(["\n",x,y*lineheight+yDst,0,lineheight, - false,false,false,defaultcolors[0],defaultcolors[1],false,false,"",8,position,nil]) + false,false,false,defaultcolors[0],defaultcolors[1],false,false,"",8,position,nil,0]) charactersInternal.push([alignment,y,0]) y+=1 @@ -717,13 +752,5 @@ textx=x+xStart texty=(lineheight*y)+yDst+yStart - colors=getLastParam(colorstack,defaultcolors) - opacity=getLastParam(opacitystack,255) - if opacity!=255 - colors=[ - Color.new(colors[0].red,colors[0].green,colors[0].blue, - colors[0].alpha*opacity/255), - colors[1] ? Color.new(colors[1].red,colors[1].green,colors[1].blue, - colors[1].alpha*opacity/255) : nil] - end + colors=getLastColors(colorstack,opacitystack,defaultcolors) oldx=x # Push character, textx will be calculated later @@ -736,5 +763,7 @@ graphic ? true : false, (boldcount>0),(italiccount>0),colors[0],colors[1], - (underlinecount>0),(strikecount>0),fontname,fontsize,position,graphicRect]) + (underlinecount>0),(strikecount>0),fontname,fontsize,position,graphicRect, + (outlinecount>0) ? 1 : 0 + ]) charactersInternal.push([alignment,y,xStart,textchars[position],extraspace]) end @@ -921,19 +950,31 @@ bitmap.font.name=ch[12] end + offset=0 if ch[9] # shadow bitmap.font.color=ch[9] - bitmap.draw_text(ch[1]+2,ch[2],ch[3]+2,ch[4],ch[0]) - bitmap.draw_text(ch[1],ch[2]+2,ch[3]+2,ch[4],ch[0]) - bitmap.draw_text(ch[1]+2,ch[2]+2,ch[3]+2,ch[4],ch[0]) + if (ch[16]&1)==0 # shadow + bitmap.draw_text(ch[1]+2,ch[2],ch[3]+2,ch[4],ch[0]) + bitmap.draw_text(ch[1],ch[2]+2,ch[3]+2,ch[4],ch[0]) + bitmap.draw_text(ch[1]+2,ch[2]+2,ch[3]+2,ch[4],ch[0]) + else # outline + offset=1 + bitmap.draw_text(ch[1],ch[2],ch[3]+2,ch[4],ch[0]) + bitmap.draw_text(ch[1],ch[2]+1,ch[3]+2,ch[4],ch[0]) + bitmap.draw_text(ch[1],ch[2]+2,ch[3]+2,ch[4],ch[0]) + bitmap.draw_text(ch[1]+1,ch[2],ch[3]+2,ch[4],ch[0]) + bitmap.draw_text(ch[1]+1,ch[2]+2,ch[3]+2,ch[4],ch[0]) + bitmap.draw_text(ch[1]+2,ch[2],ch[3]+2,ch[4],ch[0]) + bitmap.draw_text(ch[1]+2,ch[2]+1,ch[3]+2,ch[4],ch[0]) + bitmap.draw_text(ch[1]+2,ch[2]+2,ch[3]+2,ch[4],ch[0]) + end end if bitmap.font.color!=ch[8] bitmap.font.color=ch[8] end - bitmap.draw_text(ch[1],ch[2],ch[3],ch[4],ch[0]) + bitmap.draw_text(ch[1]+offset,ch[2]+offset,ch[3],ch[4],ch[0]) else if bitmap.font.color!=ch[8] bitmap.font.color=ch[8] end - bitmap.draw_text(ch[1],ch[2],ch[3],ch[4],ch[0]) end if ch[10] # underline Changed: PokemonUtilities --- Left +++ Right @@ -83,15 +83,23 @@ Thread.stop # Geocode the current user via the internet (requires script "Sockets") - data="" + +data="" +lat=200;lon=200 if Kernel.respond_to?("pbDownloadToString") - data=pbDownloadToString("http://api.hostip.info/rough.php?position=true") + data=pbDownloadToString("http://www.maxmind.com/app/locate_my_ip") + if data[/Latitude\/Longi[\s\S]+?\">\s*([\-0-9\.]+)\/([\-0-9\.]+)/] + lat=-($1.to_f)*Math::PI/180 + lon=($2.to_f)*Math::PI/180 + end + if lat==200 || lon==200 + data=pbDownloadToString("http://api.hostip.info/rough.php?position=true") + if data[/Latitude\:\s+(-?\d+(?:\.\d+)?)/] + lat=-($1.to_f)*Math::PI/180 + end + if data[/Longitude\:\s+(-?\d+(?:\.\d+)?)/] + lon=($1.to_f)*Math::PI/180 + end + end end - lat=200;lon=200 - if data[/Latitude\:\s+(-?\d+(?:\.\d+)?)/] - lat=-($1.to_f)*Math::PI/180 - end - if data[/Longitude\:\s+(-?\d+(?:\.\d+)?)/] - lon=($1.to_f)*Math::PI/180 - end if lat!=200 && lon!=200 Thread.critical=true; begin @@ -118,4 +126,5 @@ return ret end +# Internal function def modulus(x,y) return x-(x/y).floor*y @@ -123,5 +132,5 @@ # Internal function -def getSunCoords(time) +def getSunCoords(time) # 'time' represents a Unix time (in local time) d=(2440586.5+time.to_i/86400.0)-2447891.5 twopi=Math::PI*2 @@ -146,6 +155,6 @@ lon=(lon-(Math::PI/12)*t) return [ - modulus(lat,twopi), # latitude of sun in radians - modulus(lon,twopi) # longitude of sun in radians + modulus(lat,twopi), # latitude of sun in radians (negative means north) + modulus(lon,twopi) # longitude of sun in radians (negative means west) ] end @@ -169,4 +178,7 @@ end +$testhour=0 +$testmsg=nil + def pbSetDayNightTone(toneToSet) # Calculates the tone for the current frame, used @@ -206,14 +218,14 @@ -#Modified by Wichu, adapted by Peter O. + def getRandomNameEx(type,variable,upper,*formats) if formats.length==0 case type - when 0 - formats=%w( 1423 2341 23441 14235 1415 14141 142314 41423 4141 42341 ) - when 1 - formats=%w( 1416 14416 141416 23416 41416 423416 414236 14236 1414236 14146 ) - when 2 - formats=%w( cvcvvc cvvcvc cvcvcv vcvvc cvcv cvvc cvcv cvve bvc bve cve bvvc bvcv bvcvc) + when 0 # Names for males + formats=%w( WE WE5 WEVE BVE BVE5 BVEVE ) + when 1 # Names for females + formats=%w( vE6 vEVE6 BVE6 B4 ) + when 2 # Neutral gender names + formats=%w( WE WEU WEVE BVE BVEU BVEVE ) end end @@ -222,21 +234,34 @@ format.scan(/./) {|c| case c - when "c" - set=%w( b c d f g h j k l l m n n p r r s s t t v w x z ) + when "c" # consonant + set=%w( b c d f g h j k l m n p r s t v w x z ) name+=set[rand(set.length)] - when "v" - set=%w( a a a e e e i i i o o o u u u y ) + when "v" # vowel + set=%w( a a a e e e i i i o o o u u u ) name+=set[rand(set.length)] - when "b" # two-letter "blends" - set=%w( br bl ch cl cr dr fr fl gh gl gr ph pl pr sc sh sk sl - sm sn sp st sw th tr tw wh wr ) + when "V" # vowel or vowel group + set=%w( a a a e e e i i i o o o u u u ai ai au au ay ay + ie ie ee ee uu uu oa oa oi oi oo oo ou ou ) name+=set[rand(set.length)] - when "e" # two-letter "blends" at end - set=%w( ck ch dd ff bb gg gh ld ll mm nd nt ng ph pt ps sk sh sp ss st rd - rn rp rm rk ns bs ft ) + when "W" # beginning vowel + set=%w( a a a e e e i i i o o o u u u au au ay ay + ea ea ee ee oo oo ou ou ) name+=set[rand(set.length)] - when "1" - set=%w( b c d f g h j k l m n p q r s t v w x z ) + when "U" # ending vowel + set=%w( a a a a e e i i o o o o u ay ay ie ie ee ue oo ) name+=set[rand(set.length)] + when "B" # beginning consonant + set1=%w( b c d f g h j k l l m n n p r r s s t t v w y z ) + set2=%w( + bl br ch cl cr dr fr fl gh gl gr kh kl kr ph pl pr sc sk sl + sm sn sp st sw th tr tw vl zh ) + name+=rand(2)==0 ? set1[rand(set1.length)] : set2[rand(set2.length)] + when "E" # ending consonant + set1=%w( b c d f g h j k k l l m n n p r r s s t t v x z ) + set2=%w( bb bs ch cs ds fs ft gs gh ld ls + nd nt ng nk rn kt ks + ms ns ph pt ps sk sh sp ss st rd + rn rp rm rt rk ns th zh) + name+=rand(2)==0 ? set1[rand(set1.length)] : set2[rand(set2.length)] when "2" set=%w( c f g k l p r s t ) @@ -246,11 +271,11 @@ name+=set[rand(set.length)] when "4" - set=%w( a e i o u ) + set=%w( una ona ina ita ila ala ana ia ) name+=set[rand(set.length)] when "5" - set=%w( e e o o o u u ) + set=%w( e e o o o o u u ito io ) name+=set[rand(set.length)] when "6" - set=%w( a a a i i i e ) + set=%w( a a a ili ine ite ina ita ila ala ana ) name+=set[rand(set.length)] end @@ -262,8 +287,12 @@ name[0,1]=name[0,1].upcase end -$game_variables[variable]=name if variable +if $game_variables + $game_variables[variable]=name if variable +end return name end + + def getRandomName(*formats) return getRandomNameEx(2,nil,nil,formats) @@ -467,6 +496,5 @@ end -# Runs a common event and returns -# only after the common event is finished. +# Runs a common event and waits# until the common event is finished. # Requires the script "PokemonMessages" def pbCommonEvent(id) @@ -652,4 +680,6 @@ pokemon.id=$Trainer.getForeignID pokemon.ot=ownerName + $Trainer.seen[pokemon.species]=true + $Trainer.owned[pokemon.species]=true # Set nickname if nickname @@ -668,5 +698,5 @@ end speciesname=PBSpecies.getName(species) - Kernel.pbMessage(_INTL("{1} obtained {2}!\1",$Trainer.name,speciesname)) + Kernel.pbMessage(_INTL("{1} obtained {2}!\\me[itemlevel]\1",$Trainer.name,speciesname)) pokemon=PokeBattle_Pokemon.new(species,level,$Trainer) pbNicknameAndStore(pokemon) @@ -674,4 +704,17 @@ end +def pbAddPokemon2(pokemon) + return if !pokemon + if pbBoxesFull? + Kernel.pbMessage(_INTL("There's no more room for Pokémon!\1")) + Kernel.pbMessage(_INTL("The Pokémon Boxes are full and can't accept any more!")) + return false + end + speciesname=PBSpecies.getName(pokemon.species) + Kernel.pbMessage(_INTL("{1} obtained {2}!\\me[itemlevel]\1",$Trainer.name,speciesname)) + pbNicknameAndStore(pokemon) + return true +end + def pbAddPokemon(species,level) if pbBoxesFull? @@ -681,5 +724,5 @@ end speciesname=PBSpecies.getName(species) - Kernel.pbMessage(_INTL("{1} obtained {2}!\1",$Trainer.name,speciesname)) + Kernel.pbMessage(_INTL("{1} obtained {2}!\\me[itemlevel]\1",$Trainer.name,speciesname)) pokemon=PokeBattle_Pokemon.new(species,level,$Trainer) pbNicknameAndStore(pokemon) @@ -698,5 +741,5 @@ # Checks whether the party has a Pokemon with a certain move and returns # the index of that Pokemon, or nil if no Pokemon has that move -def Kernel.pbCheckMove(move) +def pbCheckMove(move) for i in $Trainer.party for j in i.moves @@ -707,4 +750,12 @@ end +# Heals all Pokemon in the party +def pbHealAll + return if !$Trainer + for i in $Trainer.party + i.heal + end +end + def pbCheckAble(pokemonIndex) for i in 0...$Trainer.party.length @@ -716,4 +767,12 @@ end +# Returns true if all Pokemon other than eggs have fainted +def pbAllFainted + for i in $Trainer.party + return false if !i.egg? && i.hp>0 + end + return true +end + # Returns the first unfainted, non-egg Pokemon # in the player's party @@ -1044,5 +1103,5 @@ def pbGetTrainerTypeGender(trainertype) - ret=2 + ret=2 # 2 = gender unknown pbRgssOpen("Data/trainernames.dat","rb"){|f| trainernames=Marshal.load(f) Changed: Sockets --- Left +++ Right @@ -592,4 +592,5 @@ def pbPostData(url, postdata, filename=nil, depth=0) + userAgent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.14) Gecko/2009082707 Firefox/3.0.14" if url[/^http:\/\/([^\/]+)(.*)$/] host=$1 @@ -602,5 +603,5 @@ next "#{keyString}=#{valueString}" }.join('&') - request="POST #{path} HTTP/1.1\nUser-Agent: Ruby Agent\nPragma: no-cache\nHost: #{host}\nProxy-Connection: Close\n" + request="POST #{path} HTTP/1.1\nUser-Agent: #{userAgent}\nPragma: no-cache\nHost: #{host}\nProxy-Connection: Close\n" request+="Content-Type: application/x-www-form-urlencoded\n" request+="Content-Length: #{body.length}\n" @@ -613,4 +614,5 @@ def pbDownloadData(url, filename=nil, depth=0) + userAgent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.14) Gecko/2009082707 Firefox/3.0.14" if depth>10 raise "Redirection level too deep" @@ -619,5 +621,5 @@ host=$1 path=$2 - request="GET #{path} HTTP/1.1\nUser-Agent: Ruby Agent\nPragma: no-cache\nHost: #{host}\nProxy-Connection: Close\n\n" + request="GET #{path} HTTP/1.1\nUser-Agent: #{userAgent}\nPragma: no-cache\nHost: #{host}\nProxy-Connection: Close\n\n" return pbHttpRequest(host, request, filename, depth) end Changed: Main --- Left +++ Right Changed: PokeBattle_AI --- Left +++ Right @@ -500,6 +500,6 @@ score+=20 if pbWeather==PBWeather::RAINDANCE && move.type==PBTypes::WATER score-=10 if pbWeather==PBWeather::RAINDANCE && move.type==PBTypes::FIRE + score+=(move.basedamage/5)-10 end - score+=(move.basedamage/5)-10 else score-=10 Changed: Compiler --- Left +++ Right @@ -854,5 +854,5 @@ clonitem.sub!(/\s*$/){} return pbGetConst(PBItems,clonitem, - _INTL("Undefined item conzstant name: %s\r\nName must consist only of letters, numbers, and\r\nunderscores and can't begin with a number.\r\n{1}", + _INTL("Undefined item constant name: %s\r\nName must consist only of letters, numbers, and\r\nunderscores and can't begin with a number.\r\n{1}", FileLineData.linereport)) end @@ -3104,8 +3104,62 @@ changed=true end - elsif list[i].code==101 && list[i].parameters[0][0,1]=="\\" - list[i].parameters[0].gsub!(/^\\[Bb]\s+/,"\\b") - list[i].parameters[0].gsub!(/^\\[Rr]\s+/,"\\r") - list[i].parameters[0].gsub!(/^\\[Gg]\s+/,"\\G") + elsif list[i].code==101 + if list[i].parameters[0][0,1]=="\\" + newx=list[i].parameters[0].clone + newx.sub!(/^\\[Bb]\s+/,"\\b") + newx.sub!(/^\\[Rr]\s+/,"\\r") + newx.sub!(/^\\[Gg]\s+/,"\\G") + if list[i].parameters[0]!=newx + list[i].parameters[0]=newx + changed=true + end + end + lines=1 + j=i+1; while j=3 && list[i+lines] && list[i+lines].code==101 + # Check whether a sentence is being broken midway + # between two Text commands + lastLine=list[i+lines-1].parameters[0].sub(/\s+$/,"") + if lastLine.length>0 && !lastLine[/[\\<]/] && lastLine[/[^\.,\!\?\;\-\"]$/] + message=list[i].parameters[0] + j=i+1; while j=0 + list.insert(i,RPG::EventCommand.new( + j==0 ? 101 : 401,indent,[nextMessage[j]])) + j-=1;end + j=newMessage.length-1;while j>=0 + list.insert(i,RPG::EventCommand.new( + j==0 ? 101 : 401,indent,[newMessage[j]])) + j-=1;end + changed=true + i+=1 + next + end + end + end elsif list[i].code==111 && list[i].parameters[0]==12 script=list[i].parameters[1] @@ -3237,4 +3291,8 @@ j+=1 end + while j0 && - event.pages[1].list[0].code==101 - text=event.pages[1].list[0].parameters[0] - j=1;while j0 && + page1list[0].code==101 + text=page1list[0].parameters[0] + j=1 + while j990 - for i in @@tempid...1000 - filename=sprintf(ENV["TEMP"]+"\\%s%d.tmp",prefix,i) - begin - fn=File.open(filename,mode) - @@tempid+=1 - return fn - rescue Errno::EINVAL, Errno::EACCES, Errno::ENOENT - end - end - return nil - end def self._load(string) data=Marshal.load(string) @@ -124,23 +210,10 @@ end def play - return if @samples.length==0 - data=[ - 0x46464952,@samples.length+0x2C, - 0x45564157,0x20746d66,0x10, - 0x01,0x01, # PCM,mono - @freq,@freq, - 1,8, # 8-bit - 0x61746164,@samples.length - ].pack("VVVVVvvVVvvVV") - f=WaveData.openTemp("wav","wb") - if f - path=f.path - f.write(data) - f.write(@samples) - f.close - Audio.se_play(path) - pbDelayedDelete(path) - end + # Play sound data asynchronously + pbPlaySoundData(@samples,100,true,@freq) end + def save(filename) + pbSaveSoundData(@samples,@freq,filename) + end end @@ -152,4 +225,17 @@ set(env) if env end + def self.fromToneFile(file) + envelope=self.new + File.open(file,"rb"){|f| + f.gets if !f.eof? + while !f.eof? + ln=f.gets + if ln[ /^(\d+)\s+(\d+)/ ] + envelope.addValueChange($1.to_i,$2.to_i) + end + end + } + return envelope + end def length; @e.length; end def [](x); @e[x]; end @@ -157,5 +243,5 @@ def clear; @e.clear; end def changeAbsolute(pos,volume) - return if pos<0 + return self if pos<0 velength=@e.length if velength>0 @@ -165,5 +251,9 @@ @e.push([pos,volume]) end + return self end + def self.initial(value) + return self.new.change(0,value) + end def self.smoothVolume(duration,volume) env=self.new @@ -204,6 +294,10 @@ return env end + def self.blink(value,onDuration,offDuration,totalDuration) + return self.new.addValueChanges( + value,onDuration,0,offDuration).repeat(totalDuration) + end def change(delta,volume) - return if delta<0 + return self if delta<0 velength=@e.length if velength>0 @@ -212,18 +306,84 @@ @e.push([delta,volume]) end + return self end + def duration + return @e.length==0 ? 0 : @e[@e.length-1][0] + end + def value + return @e.length==0 ? 0 : @e[@e.length-1][1] + end + def addValueChange(value,duration) + changeDiscrete(0,value) + changeDiscrete(duration,value) + return self + end + def sweep(duration,currentValue=nil) + currentValue=self.value if !currentValue + fallingValue=currentValue-40 + fallingValue=0 if fallingValue<0 + changeDiscrete(0,currentValue) + i=duration;while i>100 + change(20,fallingValue) + change(20,currentValue) + change(40,currentValue) + i-=100;end + change(i,currentValue) + return self + end + def addValueChanges(*arg) + i=0;while i=oldLength + i=0; currentDuration+=oldDuration + end + end + return self + end # Changes the volume, frequency, etc. abruptly without # blending. def changeDiscrete(delta,volume) - return if delta<0 + return self if delta<0 velength=@e.length if velength>0 oldValue=@e[velength-1][1] - @e.push([@e[velength-1][0]+delta,oldValue]) - @e.push([delta,volume]) + oldDelta=@e[velength-1][0] + newDelta=oldDelta+delta + newValue=oldValue + if newDelta!=oldDelta || newValue!=oldValue + @e.push([newDelta,newValue]) + oldDelta=newDelta + oldValue=newValue + end + newValue=volume + if newDelta!=oldDelta || newValue!=oldValue + @e.push([newDelta,newValue]) + end else @e.push([delta,volume]) end + return self end + def set(value) + if value.is_a?(SoundEnvelope) || value.is_a?(Array) + @e.clear + for v in value; @e.push(v); end + end + end private def stableSort @@ -236,4 +396,35 @@ end +# internal class +class SoundEnvelopeIterator + def initialize(env) + @env=env + @envIndex=0 + end + def getValue(frame) + value=0 + if @envIndex==@env.length + value=@env[@envIndex-1][1] + elsif @envIndex==0 + value=@env[@envIndex][1] + else + lastPos=@env[@envIndex-1][0] + thisPos=@env[@envIndex][0] + if thisPos!=lastPos + lastVolume=@env[@envIndex-1][1] + thisVolume=@env[@envIndex][1] + value=(thisVolume-lastVolume)*(frame-lastPos)/(thisPos-lastPos)+lastVolume + else + value=@env[@envIndex][1] + end + end + while @envIndex+1<@env.length && @env[@envIndex][0]==frame.to_i + @envIndex+=1 + end + return value + end +end + +# internal class class WaveForm SAMPLEFREQ=11025 @@ -256,73 +447,69 @@ end def setFrequencyEnvelope(env) - @freqEnvelope.set(env) + if env.is_a?(Numeric) + @freqEnvelope.clear + @freqEnvelope.addValueChange(env,@duration) + else + @freqEnvelope.set(env) + end end def setVolumeEnvelope(env) - @volumeEnvelope.set(env) + if env.is_a?(Numeric) + @volumeEnvelope.clear + @volumeEnvelope.addValueChange(env,@duration) + else + @volumeEnvelope.set(env) + end end - def getVolume(env,envIndex,frame) - return env[envIndex-1][1] if envIndex==env.length - return env[envIndex][1] if envIndex==0 - lastPos=env[envIndex-1][0] - thisPos=env[envIndex][0] - return env[envIndex][1] if thisPos==lastPos - lastVolume=env[envIndex-1][1] - thisVolume=env[envIndex][1] - return (thisVolume-lastVolume)* - (frame-lastPos)/(thisPos-lastPos)+lastVolume + def lcm(x,y) + return y if x=0; return x if y==0 + return x if x==y + if x>y; incr=x + while x%y!=0; x+=incr; end + return x + else; incr=y + while y%x!=0; y+=incr; end + return y + end end def start @i=0 - @vEnvIndex=0 - @fEnvIndex=0 - @tEnvIndex=0 - @counter=0 - @buffer=[] + @volumeIterator=SoundEnvelopeIterator.new(@volumeEnvelope) + @freqIterator=SoundEnvelopeIterator.new(@freqEnvelope) + @timbreIterator=SoundEnvelopeIterator.new(@timbreEnvelope) @sampleCount=@duration*SAMPLEFREQ/1000 @samples=" "*@sampleCount - @samplesPerTick=@freq==0 ? @sampleCount : [SAMPLEFREQ/@freq,1].max - @proc.call(@buffer,@samplesPerTick,@timbre) if @proc + @exactSamplesPerPass=@freq==0 ? 1.0 : [SAMPLEFREQ.to_f/@freq,1].max + @step=1.0/@exactSamplesPerPass + @exactCounter=0 end + def self.frac(x) + return x-x.floor + end def nextSample vol=100 + fframe=@i*1000.0/SAMPLEFREQ if @volumeEnvelope.length>0 # Update volume - fframe=@i*1000.0/SAMPLEFREQ # convert to float - frame=@i*1000/SAMPLEFREQ - vol=getVolume(@volumeEnvelope,@vEnvIndex,fframe) - while @vEnvIndex+1<@volumeEnvelope.length && - @volumeEnvelope[@vEnvIndex][0]==frame - @vEnvIndex+=1 - end + vol=@volumeIterator.getValue(fframe) end if @proc updateBuffer=false if @freqEnvelope.length>0 # Update frequency - frame=@i*1000/SAMPLEFREQ - freq=getVolume(@freqEnvelope,@fEnvIndex,frame).to_i - while @fEnvIndex<@freqEnvelope.length && - @freqEnvelope[@fEnvIndex][0]==frame && - @fEnvIndex+=1 - end + freq=@freqIterator.getValue(fframe) if freq!=@freq # update sample buffer @freq=freq - @samplesPerTick=@freq==0 ? @sampleCount : [SAMPLEFREQ/@freq,1].max - @counter=@samplesPerTick-1 if @counter>=@samplesPerTick - updateBuffer=true + @exactSamplesPerPass=@freq==0 ? 1.0 : [SAMPLEFREQ.to_f/@freq,1].max + @step=1.0/@exactSamplesPerPass end end if @timbreEnvelope.length>0 # Update timbre - frame=@i*1000/SAMPLEFREQ - timbre=getVolume(@timbreEnvelope,@tEnvIndex,frame) - while @tEnvIndex<@timbreEnvelope.length && - @timbreEnvelope[@tEnvIndex][0]==frame - @tEnvIndex+=1 - end - if timbre!=@timbre # update sample buffer - @timbre=timbre - updateBuffer=true - end + @timbre=@timbreIterator.getValue(fframe) end - @proc.call(@buffer,@samplesPerTick,@timbre) if updateBuffer - @samples[@i]=0x80+(vol*@buffer[@counter]).to_i + if @freq==0 || vol==0 + @samples[@i]=0x80 + else + sample=@proc.call(@exactCounter,@timbre) + @samples[@i]=0x80+(vol*sample).round + end else # noise v=vol.abs.to_i*2 @@ -330,13 +517,16 @@ end @i+=1 - @counter+=1 - @counter=0 if @counter==@samplesPerTick + @exactCounter+=@step + while @exactCounter>1.0; @exactCounter-=1.0; end end - def play(path, volume, async, delete=true) - return if !path - Audio.se_play(path,volume) - sleep(@duration/1000.0) if !async - pbDelayedDelete(path) if delete + def mixSamples(other) + for i in 0...other.sampleCount + newSamp=((@samples[i]-0x80)+(other.samples[i]-0x80))/2+0x80 + @samples[i]=newSamp + end end + def play(volume=100, async=false) + pbPlaySoundData(@samples,volume,async,SAMPLEFREQ) + end def generateSound start @@ -348,23 +538,8 @@ return WaveData.new(SAMPLEFREQ,@samples) end - def writeSound - data=[ - 0x46464952,@samples.length+0x2C, - 0x45564157,0x20746d66,0x10, - 0x01,0x01, # PCM,mono - SAMPLEFREQ,SAMPLEFREQ, - 1,8, # 8-bit - 0x61746164,@samples.length - ].pack("VVVVVvvVVvvVV") - f=Audio.openTemp("wav","wb") - if f - path=f.path - f.write(data) - f.write(@samples) - f.close - return path - end - return nil + def save(filename) + pbSaveSoundData(@samples,SAMPLEFREQ,filename) end + attr_accessor :samples,:sampleCount end @@ -393,19 +568,4 @@ SIXTEENTH = EIGHTH/2 end - @@tempid=0 - def self.openTemp(prefix,mode) - @@tempid=0 if @@tempid>990 - for i in @@tempid...1000 - filename=sprintf(ENV["TEMP"]+"\\%s%d.tmp",prefix,i) - begin - fn=File.open(filename,mode) - @@tempid+=1 - return fn - rescue Errno::EINVAL, Errno::EACCES, Errno::ENOENT - end - end - return nil - end - def self.noise(durationInMs=200, volume=100, async=false) return if durationInMs<=0 @@ -416,9 +576,49 @@ end waveForm.generateSound - path=waveForm.writeSound - waveForm.play(path,volume,async) + waveForm.play(volume,async) end + # internal method + def self.envelopeDuration(env) + return 0 if !env + if env.is_a?(SoundEnvelope) || env.is_a?(Array) + return SoundEnvelope.new(env).duration + end + return 0 + end + def self.oscillateDouble(durationInMs, + freq1, freq2, volume1, volume2, + timbre1, timbre2, + proc1, proc2, async=false) + return if durationInMs<0 + freq1Zero=(freq1.is_a?(Numeric) && freq1<=0) || + (freq1.is_a?(Array) && freq1.length==0) + freq2Zero=(freq2.is_a?(Numeric) && freq2<=0) || + (freq2.is_a?(Array) && freq2.length==0) + if freq1Zero && freq2Zero + Thread.sleep(durationInMs/1000.0) if !async + return + end + if durationInMs==0 || durationInMs==nil + durationInMs=[ + envelopeDuration(freq1), + envelopeDuration(freq2), + envelopeDuration(volume1), + envelopeDuration(volume2), + envelopeDuration(timbre1), + envelopeDuration(timbre2) + ].max + return if durationInMs<=0 + end + waveForm1=WaveForm.new(proc1,freq1,durationInMs,timbre1) + waveForm2=WaveForm.new(proc2,freq2,durationInMs,timbre2) + waveForm1.setVolumeEnvelope(volume1) + waveForm2.setVolumeEnvelope(volume2) + waveForm1.generateSound + waveForm2.generateSound + waveForm1.mixSamples(waveForm2) + waveForm1.play(100,async) + end def self.oscillate(durationInMs=200, freq=800, volume=100, timbre=0.5, async=false, &block) - return if durationInMs<=0 + return if durationInMs<0 if (freq.is_a?(Numeric) && freq<=0) || (freq.is_a?(Array) && freq.length==0) @@ -426,4 +626,11 @@ return end + if durationInMs==0 || durationInMs==nil + durationInMs=[ + envelopeDuration(freq), + envelopeDuration(volume), + envelopeDuration(timbre)].max + return if durationInMs<=0 + end waveForm=WaveForm.new(block,freq,durationInMs,timbre) if volume.is_a?(Array) || volume.is_a?(SoundEnvelope) @@ -432,42 +639,40 @@ end waveForm.generateSound - path=waveForm.writeSound - waveForm.play(path,volume,async) + waveForm.play(volume,async) end - def self.oscillate2(durationInMs=200, volume=100, async=false, &block) - return if durationInMs<=0 - waveForm=WaveForm.new(block,0,durationInMs,0.5) - if volume.is_a?(Array) || volume.is_a?(SoundEnvelope) - waveForm.setVolumeEnvelope(volume) - volume=100 - end - waveForm.generateSound - path=waveForm.writeSound - waveForm.play(path,volume,async) + def self.frac(x) + return x-x.floor end + TWOPI=Math::PI*2 + @@sineProc2=proc {|z,timbre| + x=z1 + for i in 0...tone.length + dtmf(tone[i,1],durationInMs,volume,false) + end + end t1=0 t1=1209 if "14ghi7pqrs*".include?(tone) @@ -483,27 +688,21 @@ f1=Math::PI*2.0*t1/WaveForm::SAMPLEFREQ f2=Math::PI*2.0*t2/WaveForm::SAMPLEFREQ - oscillate2(durationInMs,volume,async){|buffer,samplesPerTick,timbre| - for i in 0...samplesPerTick - buffer[i]=0.5*(Math.sin(i*f1)+Math.sin(i*f2)); - end - } + doubleSine(durationInMs,t1,t2,volume,volume,0.5,0.5,async) end - def self.beep(durationInMs=200, freq=800, volume=100, timbre=0.5, async=false) square(durationInMs,freq,volume,timbre,async) end + @@triangleProc2=proc {|z,timbre| + z>4 @@ -658,4 +986,10 @@ def getWaveData(filename) time=-1 + fgetdw=proc{|file| + (file.eof? ? 0 : (file.read(4).unpack("V")[0] || 0)) + } + fgetw=proc{|file| + (file.eof? ? 0 : (file.read(2).unpack("v")[0] || 0)) + } if !FileTest.exist?(filename) return 1 # Not found @@ -663,39 +997,39 @@ File.open(filename,"rb"){|file| file.pos=0 - fdw=file.fgetdw + fdw=fgetdw.call(file) if fdw==0x46464952 # "RIFF" - filesize=file.fgetdw - wave=file.fgetdw + filesize=fgetdw.call(file) + wave=fgetdw.call(file) if wave!=0x45564157 # "WAVE" return 2 end - fmt=file.fgetdw + fmt=fgetdw.call(file) if fmt!=0x20746d66 # "fmt " return 2 end - fmtsize=file.fgetdw - format=file.fgetw + fmtsize=fgetdw.call(file) + format=fgetw.call(file) if format!=1 return 3 # unsupported end - channels=file.fgetw # channels (1 or 2) + channels=fgetw.call(file) # channels (1 or 2) if channels!=1 return 3 # unsupported end - rate=file.fgetdw # samples per second - bytessec=file.fgetdw # avg bytes per second + rate=fgetdw.call(file) # samples per second + bytessec=fgetdw.call(file) # avg bytes per second if bytessec==0 return 2 end - bytessample=file.fgetw # bytes per sample - bitssample=file.fgetw # bits per sample (8, 16, etc.) + bytessample=fgetw.call(file) # bytes per sample + bitssample=fgetw.call(file) # bits per sample (8, 16, etc.) if bitssample!=8 && bitssample!=16 return 3 # unsupported end - data=file.fgetdw + data=fgetdw.call(file) if data!=0x61746164 # "data" return 2 end - datasize=file.fgetdw + datasize=fgetdw.call(file) data=file.read(datasize) samples=nil @@ -819,3 +1153,2 @@ MciSendString.call("close RECORDER",0,0,0) end - Changed: Game_CommonEvent --- Left +++ Right @@ -43,7 +43,16 @@ # * Refresh #-------------------------------------------------------------------------- + def switchIsOn?(id) + switchname=$data_system.switches[id] + return false if !switchname + if switchname[/^s\:/] + return eval($~.post_match) + else + return $game_switches[id] + end + end def refresh # Create an interpreter for parallel process if necessary - if self.trigger == 2 and $game_switches[self.switch_id] == true + if self.trigger == 2 and switchIsOn?(self.switch_id) if @interpreter == nil @interpreter = Interpreter.new Changed: PokemonField --- Left +++ Right @@ -315,4 +315,5 @@ def pbBattleAnimation(bgm=nil) + handled=false if bgm $game_system.bgm_play(bgm) @@ -342,5 +343,19 @@ end $game_temp.background_bitmap=Graphics.snap_to_bitmap - if Sprite.method_defined?(:wave_amp) && rand(15)==0 +# +# Animate the screen ($game_temp.background_bitmap contains +# the current game screen). +# +# The following example runs a common event that does +# a custom animation if some condition is true. The screen +# should fade to black when the common event is finished: +# +#if $game_map && $game_map.map_id==20 # If on map 20 +# pbCommonEvent(20) +# handled=true # Note that the battle animation is done +#end +# + if !handled + if Sprite.method_defined?(:wave_amp) && rand(15)==0 viewport.color=Color.new(0,0,0,255) sprite = Sprite.new @@ -362,5 +377,5 @@ bm.dispose sprite.dispose - elsif Bitmap.method_defined?(:radial_blur) && rand(15)==0 + elsif Bitmap.method_defined?(:radial_blur) && rand(15)==0 viewport.color=Color.new(0,0,0,255) sprite = Sprite.new @@ -379,15 +394,15 @@ bm.dispose sprite.dispose - elsif rand(15)==0 + elsif rand(15)==0 scroll=["ScrollDown","ScrollLeft","ScrollRight","ScrollUp"] Graphics.freeze viewport.color=Color.new(0,0,0,255) Graphics.transition(50,sprintf("Graphics/Transitions/%s",scroll[rand(4)])) - elsif rand(15)==0 + elsif rand(15)==0 scroll=["ScrollDownRight","ScrollDownLeft","ScrollUpRight","ScrollUpLeft"] Graphics.freeze viewport.color=Color.new(0,0,0,255) Graphics.transition(50,sprintf("Graphics/Transitions/%s",scroll[rand(4)])) - else + else transitions=["Splash","Image1","Image2", "Image3","Image4","Random_stripe_h", @@ -410,4 +425,5 @@ Graphics.transition(40, sprintf("Graphics/Transitions/%s",transitions[rnd])) + end end 5.times do @@ -1492,11 +1508,6 @@ -def pbAllFainted - for i in $Trainer.party - return false if !i.egg? && i.hp>0 - end - return true -end + def Kernel.pbSetPokemonCenter $PokemonGlobal.pokecenterMapId=$game_map.map_id @@ -1617,10 +1628,6 @@ end -def Kernel.pbHealAll - for i in $Trainer.party - i.heal - end -end + def Kernel.pbPokerus? return false if $game_switches[POKeRUS_SWITCH] @@ -2059,4 +2066,36 @@ module InterpreterFieldMixin + # Used in boulder events. Allows an event to be pushed. To be used in + # a script event command. + def pbPushThisEvent + event=get_character(0) + oldx=event.x + oldy=event.y + # Apply strict version of passable, which makes impassable + # tiles that are passable only from certain directions + if !event.passableStrict?(event.x,event.y,$game_player.direction) + return + end + case $game_player.direction + when 2 # down + event.move_down + when 4 # left + event.move_left + when 6 # right + event.move_right + when 8 # up + event.move_up + end + $PokemonMap.addMovedEvent(@event_id) if $PokemonMap + if oldx!=event.x || oldy!=event.y + $game_player.lock + begin + Graphics.update + Input.update + pbUpdateSceneMap + end until !event.moving? + $game_player.unlock + end + end def pbPushThisBoulder if $PokemonMap.strengthUsed Changed: Interpreter --- Left +++ Right @@ -239,7 +239,11 @@ return result rescue Exception - e=$! - event=get_character(0) + + e=$! + + raise if e.is_a?(Hangup) || e.is_a?(SystemExit) || "#{e.class}"=="Reset" + event=get_character(0) s="" + message=pbGetExceptionMessage(e) if e.is_a?(SyntaxError) Changed: DependentEvents --- Left +++ Right @@ -8,4 +8,18 @@ end +def pbAddDependency(event) + $PokemonTemp.dependentEvents.addEvent(event) +end +def pbRemoveDependency(event) + $PokemonTemp.dependentEvents.removeEvent(event) +end + +def pbAddDependency2(eventID, eventName, commonEvent) + $PokemonTemp.dependentEvents.addEvent($game_map.events[eventID],eventName,commonEvent) +end +def pbRemoveDependency2(eventName) + $PokemonTemp.dependentEvents.removeEventByName(eventName) +end + class PokemonGlobalMetadata attr_accessor :dependentEvents