Changed: PokemonMap @@ -15,1 +15,0 @@ - attr_accessor :partner @@ -26,1 +25,0 @@ - @partner=nil @@ -177,0 +175,1 @@ + attr_accessor :partner @@ -675,1 +674,2 @@ - return false unless ($DEBUG && Input.press?(Input::CTRL)) || newmap[0].passable?(newmap[1],newmap[2],0,$game_player) + return false unless ($DEBUG && Input.press?(Input::CTRL)) || + newmap[0].passable?(newmap[1],newmap[2],0,$game_player) @@ -764,2 +764,0 @@ - # Determines whether a map with id has connections - # with other maps. Changed: PokeBattle_Pokemon @@ -263,1 +263,1 @@ - if value<1 || value>100 + if value<1 || value>PBExperience::MAXLEVEL Changed: PBExperience @@ -1,2 +1,1 @@ -#35363792 -begin + @@ -68,0 +67,46 @@ +MAXLEVEL=100 +=begin + Erratic (600000): + For levels 0-50: n**3([100-n]/50) + For levels 51-68: n**3([150-n]/100) + For levels 69-98: n**3(1.274-[1/50][n/3]-p(n mod 3)) + where p(x) = array(0.000,0.008,0.014)[x] + For levels 99-100: n**3([160-n]/100) + Fluctuating (1640000): + For levels 0-15: n**3([24+{(n+1)/3}]/50) + For levels 16-35: n**3([14+n]/50) + For levels 36-100: n**3([32+{n/2}]/50) +=end +def self.pbGetExpInternal(level,growth) + if level>100 + # Use formulas for levels greater than 100 + case growth + when 0 # 1000000 medium + return level**3 + when 1 # 600000 erratic + # Different formula that causes 600000 EXP at level 100 + return ( (level**3)*( (level * 6 / 10) / (100*1.0) ) ).floor + when 2 # 1640000 fluctuating + # Different formula that causes 1640000 EXP at level 100 + rate=82 + if level>100 + # Slow rate with increasing level + rate-=(level-100)/2 + rate=40 if rate<40 + end + return ( (level**3)*( (level * rate / 100) / 50.0 ) ).floor + when 3 # 1059860 parabolic + return (6*(level**3)/5) - 15*(level**2) + 100*level - 140 + when 4 # 800000 fast + return ( 4*(level**3)/5 ).floor + when 5 # 1250000 slow + return ( 5*(level**3)/4 ).floor + else + return 0 + end + else + # Refer to experience table for levels 100 and less + return @PBExpTable[growth*101+level] + end +end + @@ -72,1 +117,1 @@ - return @PBExpTable[growth*101+100] + return pbGetExpInternal(MAXLEVEL,growth) @@ -79,2 +124,5 @@ - level=100 if level>100 - return @PBExpTable[growth*101+level] + if level<0 + return ArgumentError.new("The level is invalid.") + end + level=MAXLEVEL if level>MAXLEVEL + return pbGetExpInternal(level,growth) @@ -88,2 +136,1 @@ - index=growth*101 - maxexp=@PBExpTable[index+100] + maxexp=pbGetExpInternal(MAXLEVEL,growth) @@ -98,2 +145,1 @@ - index=growth*101 - maxexp=@PBExpTable[index+100] + maxexp=pbGetExpInternal(MAXLEVEL,growth) @@ -102,3 +148,4 @@ - for j in 0..100 - return i if exp==@PBExpTable[index+i] - return i-1 if exp<@PBExpTable[index+i] + for j in 0..MAXLEVEL + currentExp=pbGetExpInternal(i,growth) + return i if exp==currentExp + return i-1 if expmaxlevel + raise _INTL("Invalid level number: {1}\r\n{2}",splitarr[1],FileLineData.linereport) + end + if splitarr[2]<=0 || splitarr[2]>maxlevel + raise _INTL("Invalid level number: {1}\r\n{2}",splitarr[2],FileLineData.linereport) + end @@ -1234,1 +1241,2 @@ - raise _INTL("Bad level: {1} (must be from 1-100)\r\n{2}",poke[1],FileLineData.linereport) if poke[1]<=0 || poke[1]>100 + raise _INTL("Bad level: {1} (must be from 1-{2})\r\n{3}",poke[1], + PBExperience::MAXLEVEL,FileLineData.linereport) if poke[1]<=0 || poke[1]>PBExperience::MAXLEVEL @@ -1394,1 +1402,1 @@ - pokedata.write("GrowthRate=" + ["Medium","Parabolic","Erratic","Fluctuating","Fast","Slow"][growthrate]+"\r\n") + pokedata.write("GrowthRate=" + ["Medium","Erratic","Fluctuating","Parabolic","Fast","Slow"][growthrate]+"\r\n") @@ -1769,1 +1777,1 @@ - pokedata.write("GrowthRate=" + ["Medium","Parabolic","Erratic","Fluctuating","Fast","Slow"][growthrate]+"\r\n") + pokedata.write("GrowthRate=" + ["Medium","Erratic","Fluctuating","Parabolic","Fast","Slow"][growthrate]+"\r\n") @@ -2145,1 +2153,1 @@ - "GrowthRate"=>[20,"e",["Medium","Parabolic","Erratic","Fluctuating","Fast","Slow"]], + "GrowthRate"=>[20,"e",["Medium","Erratic","Fluctuating","Parabolic","Fast","Slow"]], @@ -2548,0 +2556,1 @@ + @@ -2559,6 +2568,12 @@ -def pbCompileTrainerEvents - mapinfos=pbLoadRxData("Data/MapInfos") - Graphics.update - t = Time.now.to_i - for id in mapinfos.keys - filename=sprintf("Data/map%03d",id) +class MapData + def initialize + @mapinfos=pbLoadRxData("Data/MapInfos") + @system=pbLoadRxData("Data/System") + @tilesets=pbLoadRxData("Data/Tilesets") + @mapxy=[] + @mapWidths=[] + @mapHeights=[] + @maps=[] + end + def saveTilesets + filename="Data/Tilesets" @@ -2570,1 +2585,159 @@ - map=load_data(filename) + save_data(@tilesets,filename) + end + def switchName(id) + return @system.switches[id] || "" + end + def mapFilename(mapID) + filename=sprintf("Data/map%03d") + if $RPGVX + filename+=".rvdata" + else + filename+=".rxdata" + end + return filename + end + def getMap(mapID) + if @maps[mapID] + return @maps[mapID] + else + begin + @maps[mapID]=load_data(mapFilename(mapID)) + return @maps[mapID] + rescue + return nil + end + end + end + def isPassable?(mapID,x,y) + if !$RPGVX + map=getMap(mapID) + return false if !map + return false if x<0 || x>=map.width || y<0 || y>=map.height + passages=@tilesets[map.tileset_id].passages + priorities=@tilesets[map.tileset_id].priorities + for i in [2, 1, 0] + tile_id = map.data[x, y, i] + return false if tile_id == nil + return false if passages[tile_id] & 0x0f == 0x0f + return true if priorities[tile_id] == 0 + end + end + return true + end + def setCounterTile(mapID,x,y) + if !$RPGVX + map=getMap(mapID) + return if !map + passages=@tilesets[map.tileset_id].passages + for i in [2, 1, 0] + tile_id = map.data[x, y, i] + next if tile_id == 0 || tile_id==nil || !passages[tile_id] + passages[tile_id]|=0x80 + break + end + end + end + def isCounterTile?(mapID,x,y) + return false if $RPGVX + map=getMap(mapID) + return false if !map + passages=@tilesets[map.tileset_id].passages + for i in [2, 1, 0] + tile_id = map.data[x, y, i] + return false if tile_id == nil + return true if passages[tile_id] && passages[tile_id] & 0x80 == 0x80 + end + return false + end + def saveMap(mapID) + save_data(getMap(mapID),mapFilename(mapID)) + end + def getEventFromXY(mapID,x,y) + return nil if x<0 || y<0 + mapPositions=@mapxy[mapID] + if mapPositions + return mapPositions[y*@mapWidths[mapID]+x] + else + map=getMap(mapID) + return nil if !map + @mapWidths[mapID]=map.width + @mapHeights[mapID]=map.height + mapPositions=[] + width=map.width + for e in map.events.values + mapPositions[e.y*width+e.x]=e if e + end + @mapxy[mapID]=mapPositions + return mapPositions[y*width+x] + end + end + def getEventFromID(mapID,id) + map=getMap(mapID) + return nil if !map + return map.events[id] + end + def mapinfos + return @mapinfos + end +end + +class TrainerChecker + def initialize + @trainers=nil + @trainernames=nil + end + def pbTrainerTypeCheck(symbol) + ret=true + if $DEBUG + if !hasConst?(PBTrainers,symbol) + ret=false + else + trtype=PBTrainers.const_get(symbol) + @trainernames=load_data("Data/trainernames.dat") if !@trainernames + if !@trainernames || !@trainernames[trtype] + ret=false + end + end + if !ret + Kernel.pbMessage(_INTL("The trainer type {1} was not found in the trainer data.\1",symbol)) + if Kernel.pbConfirmMessage(_INTL("Would you like to add it now?")) + pbTrainerTypeEditorNew(symbol.to_s) + @trainers=nil + @trainernames=nil + end + $game_system.map_interpreter.command_end if $game_system + end + end + return ret + end + def pbTrainerBattleCheck(trtype,trname,trid) + if $DEBUG + if trtype.is_a?(String) || trtype.is_a?(Symbol) + pbTrainerTypeCheck(trtype) + return false if !hasConst?(PBTrainers,trtype) + trtype=PBTrainers.const_get(trtype) + end + @trainers=load_data("Data/trainers.dat") if !@trainers + if @trainers + for trainer in @trainers + name=trainer[1] + thistrainerid=trainer[0] + thispartyid=trainer[4] + next if name!=trname || thistrainerid!=trtype || thispartyid!=trid + return + end + end + pbMissingTrainer(trtype,trname,trid) + @trainers=nil + @trainernames=nil + end + end +end + + +def pbCompileTrainerEvents(mustcompile) + mapdata=MapData.new + t = Time.now.to_i + Graphics.update + trainerChecker=TrainerChecker.new + for id in mapdata.mapinfos.keys.sort @@ -2572,0 +2745,3 @@ + map=mapdata.getMap(id) + next if !map || !mapdata.mapinfos[id] + Win32API.SetWindowText(_INTL("Processing map {1} ({2})",id,mapdata.mapinfos[id].name)) @@ -2577,1 +2753,1 @@ - newevent=pbConvertToTrainerEvent(map.events[key]) + newevent=pbConvertToTrainerEvent(map.events[key],trainerChecker) @@ -2587,3 +2763,226 @@ - end - save_data(map,filename) if changed - end + newevent=pbFixWrongEventUse(map.events[key],mapdata) + if newevent + changed=true + map.events[key]=newevent + end + end + if Time.now.to_i - t >= 5 + Graphics.update + t = Time.now.to_i + end + changed=true if pbCheckCounters(map,id,mapdata) + if changed + mapdata.saveMap(id) + mapdata.saveTilesets + end + end +end + +def isPlainEvent?(event) + return event && event.pages.length<=1 && + event.pages[0].list.length<=1 && + event.pages[0].move_type==0 && + event.pages[0].condition.switch1_valid==false && + event.pages[0].condition.switch2_valid==false && + event.pages[0].condition.variable_valid==false && + event.pages[0].condition.self_switch_valid==false +end + +def isPlainEventOrMart?(event) + return event && + event.pages.length<=1 && + event.pages[0].move_type==0 && + event.pages[0].condition.switch1_valid==false && + event.pages[0].condition.switch2_valid==false && + event.pages[0].condition.variable_valid==false && + event.pages[0].condition.self_switch_valid==false && + ((event.pages[0].list.length<=1) || ( + event.pages[0].list.length<=10 && + event.pages[0].graphic.character_name!="" && + event.pages[0].list[0].code==355 && + event.pages[0].list[0].parameters[0][/^pbPokemonMart/]) + ) +end + +def applyPages(page,pages) + for p in pages + p.graphic=page.graphic + p.walk_anime=page.walk_anime + p.step_anime=page.step_anime + p.direction_fix=page.direction_fix + p.through=page.through + p.always_on_top=page.always_on_top + end +end + +def isLikelyCounter?(thisEvent,otherEvent,mapID,mapdata) + # Check whether other event is likely on a counter tile + yonderX=otherEvent.x+(otherEvent.x-thisEvent.x) + yonderY=otherEvent.y+(otherEvent.y-thisEvent.y) + return true if mapdata.isCounterTile?(mapID,otherEvent.x,otherEvent.y) + return thisEvent.pages[0].graphic.character_name!="" && + otherEvent.pages[0].graphic.character_name=="" && + otherEvent.pages[0].trigger==0 && + mapdata.isPassable?(mapID,thisEvent.x,thisEvent.y) && + !mapdata.isPassable?(mapID,otherEvent.x,otherEvent.y) && + mapdata.isPassable?(mapID,yonderX,yonderY) +end + +def pbCheckCounters(map,mapID,mapdata) + todelete=[] + changed=false + for key in map.events.keys + event=map.events[key] + firstCommand=event.pages[0].list[0] + if isPlainEventOrMart?(event) + # Empty event, check for counter events + neighbors=[] + neighbors.push(mapdata.getEventFromXY(mapID,event.x,event.y-1)) + neighbors.push(mapdata.getEventFromXY(mapID,event.x,event.y+1)) + neighbors.push(mapdata.getEventFromXY(mapID,event.x-1,event.y)) + neighbors.push(mapdata.getEventFromXY(mapID,event.x+1,event.y)) + neighbors.compact! + for otherEvent in neighbors + next if isPlainEvent?(otherEvent) + if isLikelyCounter?(event,otherEvent,mapID,mapdata) + mapdata.setCounterTile(mapID,otherEvent.x,otherEvent.y) + savedPage=event.pages[0] + event.pages=otherEvent.pages + applyPages(savedPage,event.pages) + todelete.push(otherEvent.id) + changed=true + end + end + end + end + for key in todelete + map.events.delete(key) + end + return changed +end + +def pbFixWrongEventUse(event,mapdata) + return nil if !event || event.pages.length==0 + changed=false + trainerMoneyRE=/^\s*\$Trainer\.money\s*(<|<=|>|>=)\s*(\d+)\s*$/ + itemBallRE=/^\s*(Kernel\.)?pbItemBall/ + # Detect old Trainer events + for page in event.pages + i=0 + list=page.list + while i" + params[2]=0 + params[1]=amount+1 + elsif operator==">=" + params[2]=0 + params[1]=amount + end + changed=true + elsif script[itemBallRE] && i>0 + # Using pbItemBall on non-item events + list[i].parameters[1]=script.sub(/pbItemBall/,"pbReceiveItem") + changed=true + elsif script[/^\s*(Kernel\.)?(pbTrainerBattle|pbDoubleTrainerBattle)/] + # Empty trainer battle conditional branches + j=i+1 + isempty=true + elseIndex=-1 + # Check if page is empty + while j=0 + list.insert(elseIndex+1, + RPG::EventCommand.new(115,list[i].indent+1,[]) # Exit Event Processing + ) + else + list.insert(i+1, + RPG::EventCommand.new(0,list[i].indent+1,[]), # Empty Event + RPG::EventCommand.new(411,list[i].indent,[]), # Else + RPG::EventCommand.new(115,list[i].indent+1,[]) # Exit Event Processing + ) + end + changed=true + end + end + end + i+=1 + end + end + return changed ? event : nil @@ -2637,14 +3036,1 @@ -def pbTrainerBattleCheck(trtype,trname,trid) - if $DEBUG - if trtype.is_a?(String) || trtype.is_a?(Symbol) - pbTrainerTypeCheck(trtype) - return false if !hasConst?(PBTrainers,trtype) - trtype=PBTrainers.const_get(trtype) - end - if !pbLoadTrainer(trtype,trname,trid) - pbMissingTrainer(trtype,trname,trid) - end - end -end - -def pbConvertToTrainerEvent(event) +def pbConvertToTrainerEvent(event,trainerChecker) @@ -2733,1 +3119,1 @@ - pbTrainerBattleCheck(trtype,trname,battleid) if !$INEDITOR + trainerChecker.pbTrainerBattleCheck(trtype,trname,battleid) if !$INEDITOR @@ -2915,1 +3301,1 @@ - pbCompileTrainerEvents + pbCompileTrainerEvents(mustcompile) Changed: Game_Player* @@ -22,139 +22,0 @@ - -def pbTurnTowardEvent(event,otherEvent) - sx = event.x - otherEvent.x - sy = event.y - otherEvent.y - if sx == 0 and sy == 0 - return - end - if sx.abs > sy.abs - sx > 0 ? event.turn_left : event.turn_right - else - sy > 0 ? event.turn_up : event.turn_down - end -end - -def pbMoveBehindEvent(leader,follower) - d=leader.direction - newX = leader.x + (d == 6 ? -1 : d == 4 ? 1 : 0) - newY = leader.y + (d == 2 ? -1 : d == 8 ? 1 : 0) - if follower.x!=newX || follower.y!=newY - follower.moveto(newX,newY) - end - case leader.direction - when 2 # down - follower.turn_down - when 4 # left - follower.turn_left - when 6 # right - follower.turn_right - when 8 # up - follower.turn_up - end -end - -def pbTestPass(follower,x,y,direction) - oldThrough=follower.through - follower.through=false - ret=follower.passableStrict?(x,y,direction) - follower.through=oldThrough - return ret -end - -def moveIfPossible(follower,direction) - deltaX=(direction == 6 ? 1 : direction == 4 ? -1 : 0) - deltaY=(direction == 2 ? 1 : direction == 8 ? -1 : 0) - newX = follower.x + deltaX - newY = follower.y + deltaY - if ($game_player.x==newX && $game_player.y==newY) || - pbTestPass(follower,newX,newY,0) - oldThrough=follower.through - follower.through=true - case direction - when 2 # down - follower.move_down - when 4 # left - follower.move_left - when 6 # right - follower.move_right - when 8 # up - follower.move_up - end - follower.through=oldThrough - end -end - -def pbFancyMoveTo(follower,newX,newY) - if follower.x-newX==-1 && follower.y==newY - moveIfPossible(follower,6) - elsif follower.x-newX==1 && follower.y==newY - moveIfPossible(follower,4) - elsif follower.y-newY==-1 && follower.x==newX - moveIfPossible(follower,2) - elsif follower.y-newY==1 && follower.x==newX - moveIfPossible(follower,8) - elsif follower.x-newX==-2 && follower.y==newY - middle=pbTestPass(follower,follower.x+1,newY,0) - ending=pbTestPass(follower,newX,newY,0) - if middle - moveIfPossible(follower,6) - moveIfPossible(follower,6) - elsif ending - follower.jump(2,0) - end - elsif follower.x-newX==2 && follower.y==newY - middle=pbTestPass(follower,follower.x-1,newY,0) - ending=pbTestPass(follower,newX,newY,0) - if middle - moveIfPossible(follower,4) - moveIfPossible(follower,4) - elsif ending - follower.jump(-2,0) - end - elsif follower.y-newY==-2 && follower.x==newX - middle=pbTestPass(follower,newX,follower.y+1,0) - ending=pbTestPass(follower,newX,newY,0) - if middle - moveIfPossible(follower,2) - moveIfPossible(follower,2) - elsif ending - follower.jump(0,2) - end - elsif follower.y-newY==2 && follower.x==newX - middle=pbTestPass(follower,newX,follower.y-1,0) - ending=pbTestPass(follower,newX,newY,0) - if middle - moveIfPossible(follower,8) - moveIfPossible(follower,8) - elsif ending - follower.jump(0,2) - end - elsif follower.x!=newX || follower.y!=newY - follower.moveto(newX,newY) - end -end - -def pbFollowEvent(leader,follower) - d=leader.direction - deltaX=(d == 6 ? -1 : d == 4 ? 1 : 0) - deltaY=(d == 2 ? -1 : d == 8 ? 1 : 0) - newX = leader.x + deltaX - newY = leader.y + deltaY - posX = newX + deltaX - posY = newY + deltaY - if (follower.x-newX==-1 && follower.y==newY) || - (follower.x-newX==1 && follower.y==newY) || - (follower.y-newY==-1 && follower.x==newX) || - (follower.y-newY==1 && follower.x==newX) || - (follower.x-newX==-2 && follower.y==newY) || - (follower.x-newX==2 && follower.y==newY) || - (follower.y-newY==-2 && follower.x==newX) || - (follower.y-newY==2 && follower.x==newX) - pbFancyMoveTo(follower,newX,newY) - elsif follower.x!=posX || follower.y!=posY - pbFancyMoveTo(follower,posX,posY) - pbFancyMoveTo(follower,newX,newY) - end -end - - - Changed: PokemonEvolution @@ -440,0 +440,1 @@ + removeItem=false @@ -441,1 +442,1 @@ - if evonib==14 + if evonib==14 # Shedinja @@ -443,0 +444,5 @@ + elsif evonib==6 || evonib==18 || evonib==19 # Evolves if traded with item/holding item + if poke==@newspecies + removeItem=true # Item is now consumed + end + next -1 @@ -447,0 +453,1 @@ + @pokemon.item=0 if removeItem Changed: PokemonEditor @@ -679,1 +679,1 @@ - if minlevel==0||minlevel>100 + if minlevel==0||minlevel>PBExperience::MAXLEVEL @@ -687,1 +687,1 @@ - if maxlevel==0||maxlevel>100 + if maxlevel==0||maxlevel>PBExperience::MAXLEVEL @@ -2467,1 +2467,1 @@ - [_INTL("Level"),LimitProperty.new(100), + [_INTL("Level"),LimitProperty.new(PBExperience::MAXLEVEL), Changed: PokemonUtilities @@ -274,1 +274,1 @@ - rescue Errno::ENOENT, RGSSError + rescue Errno::ENOENT, Errno::EACCES, RGSSError @@ -390,32 +390,3 @@ - def pbLoadPokemonBitmap(pokemon, back=false) - if pokemon.egg? - return BitmapCache.load_bitmap( - sprintf("Graphics/Pictures/egg.png")) - end - bitmapFileName=sprintf("Graphics/Battlers/%03d%s%s.png",pokemon.species, - pokemon.isShiny? ? "s" : "", - back ? "b" : "") - if isConst?(pokemon.species,PBSpecies,:SPINDA) && !back - bitmap=Bitmap.new(bitmapFileName) - pbSpindaSpots(pokemon,bitmap) - return bitmap - elsif isConst?(pokemon.species,PBSpecies,:UNOWN) - d=pokemon.personalID&3 - d|=((pokemon.personalID>>8)&3)<<2 - d|=((pokemon.personalID>>16)&3)<<4 - d|=((pokemon.personalID>>24)&3)<<6 - d%=28 # index of letter : ABCDEFGHIJKLMNOPQRSTUVWXYZ!? - begin - # Load special bitmap if found - # Example: 201b_02 for the letter C - return BitmapCache.load_bitmap( - sprintf("Graphics/Battlers/%03d%s%s_%02d.png",pokemon.species, - pokemon.isShiny? ? "s" : "", - back ? "b" : "", d) - ) - rescue - # Load plain bitmap as usual (see below) - end - end - return BitmapCache.load_bitmap(bitmapFileName) - end +def pbLoadPokemonBitmap(pokemon, back=false) + return pbLoadPokemonBitmapSpecies(pokemon,pokemon.species,back) +end Changed: PokemonItems @@ -832,1 +832,1 @@ - if pokemon.level>=100 + if pokemon.level>=PBExperience::MAXLEVEL Changed: PokemonScreen @@ -1333,1 +1333,1 @@ - _INTL("Set the Pokemon's level."),pkmn.level,1,100,pkmn.level) + _INTL("Set the Pokemon's level."),pkmn.level,1,PBExperience::MAXLEVEL,pkmn.level) Changed: PokemonStorage @@ -641,1 +641,1 @@ - _INTL("Set the Pokemon's level."),pkmn.level,1,100,pkmn.level) + _INTL("Set the Pokemon's level."),pkmn.level,1,PBExperience::MAXLEVEL,pkmn.level) Changed: DependentEvents @@ -23,0 +23,154 @@ + +def pbTurnTowardEvent(event,otherEvent) + sx = event.x - otherEvent.x + sy = event.y - otherEvent.y + if sx == 0 and sy == 0 + return + end + if sx.abs > sy.abs + sx > 0 ? event.turn_left : event.turn_right + else + sy > 0 ? event.turn_up : event.turn_down + end +end + +def pbMoveBehindEvent(leader,follower) + d=leader.direction + newX = leader.x + (d == 6 ? -1 : d == 4 ? 1 : 0) + newY = leader.y + (d == 2 ? -1 : d == 8 ? 1 : 0) + if follower.x!=newX || follower.y!=newY + follower.moveto(newX,newY) + end + case leader.direction + when 2 # down + follower.turn_down + when 4 # left + follower.turn_left + when 6 # right + follower.turn_right + when 8 # up + follower.turn_up + end +end + +def pbTestPass(follower,x,y,direction) + oldThrough=follower.through + follower.through=false + ret=follower.passableStrict?(x,y,direction) + follower.through=oldThrough + return ret +end + +def moveThrough(follower,direction) + deltaX=(direction == 6 ? 1 : direction == 4 ? -1 : 0) + deltaY=(direction == 2 ? 1 : direction == 8 ? -1 : 0) + newX = follower.x + deltaX + newY = follower.y + deltaY + oldThrough=follower.through + follower.through=true + case direction + when 2 # down + follower.move_down + when 4 # left + follower.move_left + when 6 # right + follower.move_right + when 8 # up + follower.move_up + end + follower.through=oldThrough +end + +def moveFancy(follower,direction) + deltaX=(direction == 6 ? 1 : (direction == 4 ? -1 : 0)) + deltaY=(direction == 2 ? 1 : (direction == 8 ? -1 : 0)) + newX = follower.x + deltaX + newY = follower.y + deltaY + # Move if new position is the player's, or the new + # position is passable, or the current position is + # not passable + if ($game_player.x==newX && $game_player.y==newY) || + pbTestPass(follower,newX,newY,0) || + !pbTestPass(follower,follower.x,follower.y,0) + oldThrough=follower.through + follower.through=true + case direction + when 2 # down + follower.move_down + when 4 # left + follower.move_left + when 6 # right + follower.move_right + when 8 # up + follower.move_up + end + follower.through=oldThrough + end +end + +def jumpFancy(follower,direction) + deltaX=(direction == 6 ? 2 : (direction == 4 ? -2 : 0)) + deltaY=(direction == 2 ? 2 : (direction == 8 ? -2 : 0)) + halfDeltaX=(direction == 6 ? 1 : (direction == 4 ? -1 : 0)) + halfDeltaY=(direction == 2 ? 1 : (direction == 8 ? -1 : 0)) + middle=pbTestPass(follower,follower.x+halfDeltaX,follower.y+halfDeltaY,0) + ending=pbTestPass(follower,follower.x+deltaX, follower.y+deltaY, 0) + if middle + moveFancy(follower,direction) + moveFancy(follower,direction) + elsif ending + if pbTestPass(follower,follower.x,follower.y,0) + follower.jump(deltaX,deltaY) + else + moveThrough(follower,direction) + moveThrough(follower,direction) + end + end +end + +def pbFancyMoveTo(follower,newX,newY) + if follower.x-newX==-1 && follower.y==newY + moveFancy(follower,6) + elsif follower.x-newX==1 && follower.y==newY + moveFancy(follower,4) + elsif follower.y-newY==-1 && follower.x==newX + moveFancy(follower,2) + elsif follower.y-newY==1 && follower.x==newX + moveFancy(follower,8) + elsif follower.x-newX==-2 && follower.y==newY + jumpFancy(follower,6) + elsif follower.x-newX==2 && follower.y==newY + jumpFancy(follower,4) + elsif follower.y-newY==-2 && follower.x==newX + jumpFancy(follower,2) + elsif follower.y-newY==2 && follower.x==newX + jumpFancy(follower,8) + elsif follower.x!=newX || follower.y!=newY + follower.moveto(newX,newY) + end +end + +def pbFollowEvent(leader,follower) + d=leader.direction + deltaX=(d == 6 ? -1 : d == 4 ? 1 : 0) + deltaY=(d == 2 ? -1 : d == 8 ? 1 : 0) + newX = leader.x + deltaX + newY = leader.y + deltaY + posX = newX + deltaX + posY = newY + deltaY + if (follower.x-newX==-1 && follower.y==newY) || + (follower.x-newX==1 && follower.y==newY) || + (follower.y-newY==-1 && follower.x==newX) || + (follower.y-newY==1 && follower.x==newX) || + (follower.x-newX==-2 && follower.y==newY) || + (follower.x-newX==2 && follower.y==newY) || + (follower.y-newY==-2 && follower.x==newX) || + (follower.y-newY==2 && follower.x==newX) + pbFancyMoveTo(follower,newX,newY) + elsif follower.x!=posX || follower.y!=posY + pbFancyMoveTo(follower,posX,posY) + pbFancyMoveTo(follower,newX,newY) + end +end + + @@ -87,1 +241,1 @@ - end + end @@ -117,0 +271,1 @@ + pbTurnTowardEvent(follower,leader) @@ -143,1 +298,0 @@ - debugEcho @@ -159,1 +313,0 @@ - debugEcho @@ -284,2 +437,1 @@ - } - echoln "Refreshed, sprites: #{@sprites.length}" + } Changed: PokemonDebug @@ -1027,1 +1027,1 @@ - _INTL("Set the Pokemon's level."),5,3,nil,100) + _INTL("Set the Pokemon's level."),5,3,nil,PBExperience::MAXLEVEL) Changed: PokemonMap Changed: PokeBattle_Pokemon Changed: PBExperience Changed: PokemonAnimEditor Changed: PokemonRoaming Changed: PokemonField Changed: PokemonTrainers Changed: Compiler Changed: Game_Player* Changed: PokemonEvolution Changed: PokemonEditor Changed: PokemonUtilities Changed: PokemonItems Changed: PokemonScreen Changed: PokemonStorage Changed: DependentEvents Changed: PokemonDebug