Advertisement
bo4p5687

Soot Grass

Feb 5th, 2021 (edited)
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.60 KB | None | 0 0
  1. #===============================================================================
  2. # ? Sootgrass fix by KleinStudio
  3. # http://kleinstudio.deviantart.com
  4. #
  5. # bo4p5687 (update)
  6. #
  7. # * The fix added a new feature, now you can warp the sootgrass tile with another
  8. # one if you want. If you don't add that setting the tile will just be delete
  9. # like in the original system. If you use different sootgrass tiles you can
  10. # add a custom setting for all of them.
  11. #
  12. # There are 2 methods for adding tile id
  13. # 1. If there are many tilesets in your project and set it in many maps,
  14. #    set SetMapForSoot = true
  15. #
  16. # To add a new setting, copy and paste this below #SootGrasses Settings
  17. #
  18. # SootGrasses.push([[[oldTileId, newTileId]], map id])
  19. #
  20. # If you want more in one map, use this
  21. # SootGrasses.push([[[oldTileId, newTileId],[oldTileId, newTileId]], map id])
  22. #
  23. # 2. If you want like the old script, many maps but same tile id or one map
  24. #    many tile id, set SetMapForSoot = false
  25. #
  26. # To add a new setting, copy and paste this below #SootGrasses Settings
  27. #
  28. # SootGrasses.push([oldTileId, newTileId])
  29. #
  30. # * How to get the tile id
  31. #    Imagine this is a tileset, tiles id are like this
  32. #    [00][01][02][03][04][05][06][07]
  33. #    [08][09][10][11][12][13][14][15]
  34. #    [16][17][18][19][20][21][22][23]...
  35. #===============================================================================
  36. PluginManager.register({
  37.   :name => "Sootgrass fix",
  38.   :credits => ["KleinStudio (original)","bo4p5687 (update)"]
  39. })
  40. #===============================================================================
  41. SetMapForSoot = false
  42. # Add in this
  43. SootGrasses=[]
  44. #SootGrasses Settings
  45. # Add
  46.  
  47.  
  48. # Gather soot from soot grass
  49. Events.onStepTakenFieldMovement += proc { |_sender,e|
  50.   event = e[0] # Get the event affected by field movement
  51.   thistile = $MapFactory.getRealTilePos(event.map.map_id,event.x,event.y)
  52.   mapid = event.map.map_id
  53.   map = $MapFactory.getMap(thistile[0])
  54.   sootlevel = -1
  55.   for i in [2,1,0]
  56.     tile_id = map.data[thistile[1],thistile[2],i]
  57.     next if tile_id==nil
  58.     if map.terrain_tags[tile_id]==PBTerrain::SootGrass
  59.       sootlevel = i
  60.       break
  61.     end
  62.   end
  63.   if sootlevel>=0 && hasConst?(PBItems,:SOOTSACK)
  64.     newTile = nil
  65.     for tile in SootGrasses
  66.       if SetMapForSoot
  67.         for tile2 in tile[0]
  68.           newTile = tile2[1]+384 if tile2[0]+384==map.data[thistile[1],thistile[2],sootlevel]
  69.         end if mapid==tile[1]
  70.       else
  71.         for tile in SootGrasses
  72.           newTile = tile[1]+384 if tile[0]+384==map.data[thistile[1],thistile[2],sootlevel]
  73.         end
  74.       end
  75.     end
  76.     $PokemonGlobal.sootsack = 0 if !$PokemonGlobal.sootsack
  77. #    map.data[thistile[1],thistile[2],sootlevel]=0
  78.     $game_map.setSootTileChange(thistile[1],thistile[2],sootlevel,map.data[thistile[1],thistile[2],sootlevel])
  79.     map.data[thistile[1],thistile[2],sootlevel] = (newTile!=nil)? newTile : 0
  80.     if event==$game_player && $PokemonBag.pbHasItem?(:SOOTSACK)
  81.       $PokemonGlobal.sootsack += 1
  82.     end
  83. #    $scene.createSingleSpriteset(map.map_id)
  84.     $scene.spriteset.reloadTiles if $scene.spriteset
  85.   end
  86. }
  87.  
  88. class Game_Map
  89.   attr_accessor :sootTiles
  90.   def getSootChanges
  91.     @sootTiles=[] if !@sootTiles
  92.     return @sootTiles
  93.   end
  94.  
  95.   def setSootTileChange(x,y,l,old)
  96.     @sootTiles=[] if !@sootTiles
  97.     @sootTiles.push([x,y,l,old])
  98.   end
  99. end
  100.  
  101. class PokemonMapFactory
  102.   def setCurrentMap
  103.     return if $game_player.moving?
  104.     return if $game_map.valid?($game_player.x,$game_player.y)
  105.     newmap=getNewMap($game_player.x,$game_player.y)
  106.     return if !newmap
  107.     for soot in $game_map.getSootChanges
  108.       $game_map.data[soot[0],soot[1],soot[2]] = soot[3]
  109.     end
  110.     if $game_map.getSootChanges.length!=0
  111.       $scene.spriteset.reloadTiles if $scene.spriteset
  112.       $game_map.sootTiles.clear
  113.     end
  114.     oldmap=$game_map.map_id
  115.     if oldmap!=0 && oldmap!=newmap[0].map_id
  116.       setMapChanging(newmap[0].map_id,newmap[0])
  117.     end
  118.     $game_map = newmap[0]
  119.     @mapIndex = getMapIndex($game_map.map_id)
  120.     $game_player.moveto(newmap[1],newmap[2])
  121.     $game_map.update
  122.     pbAutoplayOnTransition
  123.     $game_map.refresh
  124.     setMapChanged(oldmap)
  125.   end
  126. end
  127.  
  128. class Spriteset_Map
  129.   def reloadTiles
  130.     @tilemap.dispose
  131.     @tilemap = TilemapLoader.new(@@viewport1)
  132.     @tilemap.tileset = pbGetTileset(@map.tileset_name)
  133.     for i in 0...7
  134.       autotile_name = @map.autotile_names[i]
  135.       @tilemap.autotiles[i] = pbGetAutotile(autotile_name)
  136.     end
  137.     @tilemap.map_data = @map.data
  138.     @tilemap.priorities = @map.priorities
  139.     @tilemap.terrain_tags = @map.terrain_tags
  140.   end
  141. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement