Advertisement
roninator2

Yanfly Slippery Tiles - Events Slide mod

Dec 4th, 2024
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 10.03 KB | None | 0 0
  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - Slippery Tiles v1.00 - mod
  4. # -- Last Updated: 2011.12.03
  5. # -- Level: Normal
  6. # -- Requires: n/a
  7. # -- Mod by Roninator2 - Events slide
  8. #==============================================================================
  9.  
  10. $imported = {} if $imported.nil?
  11. $imported["YEA-SlipperyTiles"] = true
  12.  
  13. #==============================================================================
  14. # ▼ Updates
  15. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  16. # 2011.12.03 - Started Script and Finished.
  17. #
  18. #==============================================================================
  19. # ▼ Introduction
  20. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  21. # Want slippery tiles without needing to make hundreds of events? Now you can!
  22. # This script binds slippery tile properties to individual tiles through usage
  23. # of notetags and terrain tags.
  24. #
  25. #==============================================================================
  26. # ▼ Instructions
  27. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  28. # To install this script, open up your script editor and copy/paste this script
  29. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  30. #
  31. # -----------------------------------------------------------------------------
  32. # Tileset Notetags - These notetags go in the tileset notebox in the database.
  33. # -----------------------------------------------------------------------------
  34. # <slippery: x>
  35. # <slippery: x, x>
  36. # Sets the tiles marked with terrain tag x to be slippery for that particular
  37. # tileset. When the player walks over a slippery terrain, the player will keep
  38. # moving forward until stopped by an object or until the player lands on ground
  39. # without slippery properties.
  40. #
  41. #==============================================================================
  42. # ▼ Compatibility
  43. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  44. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  45. # it will run with RPG Maker VX without adjusting.
  46. #
  47. #==============================================================================
  48.  
  49. module YEA
  50.   module SLIPPERY_TILES
  51.    
  52.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  53.     # - Sliding Animation -
  54.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  55.     # Set what sliding frame you want characters to use when they're on
  56.     # slippery tiles. Standing frame is 1.
  57.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  58.     SLIDE_FRAME = 2
  59.    
  60.   end # SLIPPERY_TILES
  61. end # YEA
  62.  
  63. #==============================================================================
  64. # ▼ Editting anything past this point may potentially result in causing
  65. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  66. # halitosis so edit at your own risk.
  67. #==============================================================================
  68.  
  69. module YEA
  70.   module REGEXP
  71.   module TILESET
  72.    
  73.     SLIPPERY = /<(?:SLIPPERY|slippery tile):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
  74.    
  75.   end # TILESET
  76.   end # REGEXP
  77. end # YEA
  78.  
  79. #==============================================================================
  80. # ■ DataManager
  81. #==============================================================================
  82.  
  83. module DataManager
  84.  
  85.   #--------------------------------------------------------------------------
  86.   # alias method: load_database
  87.   #--------------------------------------------------------------------------
  88.   class <<self; alias load_database_st load_database; end
  89.   def self.load_database
  90.     load_database_st
  91.     load_notetags_st
  92.   end
  93.  
  94.   #--------------------------------------------------------------------------
  95.   # new method: load_notetags_st
  96.   #--------------------------------------------------------------------------
  97.   def self.load_notetags_st
  98.     groups = [$data_tilesets]
  99.     for group in groups
  100.       for obj in group
  101.         next if obj.nil?
  102.         obj.load_notetags_st
  103.       end
  104.     end
  105.   end
  106.  
  107. end # DataManager
  108.  
  109. #==============================================================================
  110. # ■ RPG::Tileset
  111. #==============================================================================
  112.  
  113. class RPG::Tileset
  114.  
  115.   #--------------------------------------------------------------------------
  116.   # public instance variables
  117.   #--------------------------------------------------------------------------
  118.   attr_accessor :slippery
  119.  
  120.   #--------------------------------------------------------------------------
  121.   # common cache: load_notetags_st
  122.   #--------------------------------------------------------------------------
  123.   def load_notetags_st
  124.     @slippery = []
  125.     #---
  126.     self.note.split(/[\r\n]+/).each { |line|
  127.       case line
  128.       #---
  129.       when YEA::REGEXP::TILESET::SLIPPERY
  130.         $1.scan(/\d+/).each { |num|
  131.         @slippery.push(num.to_i) if num.to_i > 0 }
  132.       #---
  133.       end
  134.     } # self.note.split
  135.     #---
  136.   end
  137.  
  138. end # RPG::Tileset
  139.  
  140. #==============================================================================
  141. # ■ Game_Map
  142. #==============================================================================
  143.  
  144. class Game_Map
  145.  
  146.   #--------------------------------------------------------------------------
  147.   # new method: slippery_floor?
  148.   #--------------------------------------------------------------------------
  149.   def slippery_floor?(dx, dy)
  150.     return (valid?(dx, dy) && slippery_tag?(dx, dy))
  151.   end
  152.  
  153.   #--------------------------------------------------------------------------
  154.   # new method: slippery_tag?
  155.   #--------------------------------------------------------------------------
  156.   def slippery_tag?(dx, dy)
  157.     return tileset.slippery.include?(terrain_tag(dx, dy))
  158.   end
  159.  
  160. end # Game_Map
  161.  
  162. #==============================================================================
  163. # ■ Game_CharacterBase
  164. #==============================================================================
  165.  
  166. class Game_CharacterBase
  167.  
  168.   #--------------------------------------------------------------------------
  169.   # new method: on_slippery_floor?
  170.   #--------------------------------------------------------------------------
  171.   def on_slippery_floor?; $game_map.slippery_floor?(@x, @y); end
  172.  
  173.   #--------------------------------------------------------------------------
  174.   # new method: slippery_pose?
  175.   #--------------------------------------------------------------------------
  176.   def slippery_pose?
  177.     return false unless on_slippery_floor?
  178.     return false if @step_anime
  179.     return true
  180.   end
  181.  
  182. end # Game_CharacterBase
  183.  
  184. # Patch to make events slide on slippery tiles
  185. # requires yanfly's slippery tiles script.
  186. # patch by Roninator2
  187.  
  188. class Game_Event < Game_Character
  189.  
  190.   #--------------------------------------------------------------------------
  191.   # alias method: update
  192.   #--------------------------------------------------------------------------
  193.   alias game_event_update_st update
  194.   def update
  195.     game_event_update_st
  196.     update_event_slippery
  197.   end
  198.  
  199.   #--------------------------------------------------------------------------
  200.   # new method: update_event_slippery
  201.   #--------------------------------------------------------------------------
  202.   def update_event_slippery
  203.     return if $game_map.interpreter.running?
  204.     return unless on_slippery_floor?
  205.     return if moving?
  206.     move_straight(@direction)
  207.   end
  208.  
  209.   #--------------------------------------------------------------------------
  210.   # new method: pattern
  211.   #--------------------------------------------------------------------------
  212.   def pattern
  213.     return YEA::SLIPPERY_TILES::SLIDE_FRAME if slippery_pose?
  214.     return @pattern
  215.   end
  216. end
  217.  
  218. #==============================================================================
  219. # ■ Game_Player
  220. #==============================================================================
  221.  
  222. class Game_Player < Game_Character
  223.  
  224.   #--------------------------------------------------------------------------
  225.   # alias method: dash?
  226.   #--------------------------------------------------------------------------
  227.   alias game_player_dash_st dash?
  228.   def dash?
  229.     return false if on_slippery_floor?
  230.     return game_player_dash_st
  231.   end
  232.  
  233.   #--------------------------------------------------------------------------
  234.   # alias method: update
  235.   #--------------------------------------------------------------------------
  236.   alias game_player_update_st update
  237.   def update
  238.     game_player_update_st
  239.     update_slippery
  240.   end
  241.  
  242.   #--------------------------------------------------------------------------
  243.   # new method: update_slippery
  244.   #--------------------------------------------------------------------------
  245.   def update_slippery
  246.     return if $game_map.interpreter.running?
  247.     return unless on_slippery_floor?
  248.     return if moving?
  249.     move_straight(@direction)
  250.   end
  251.  
  252.   #--------------------------------------------------------------------------
  253.   # new method: pattern
  254.   #--------------------------------------------------------------------------
  255.   def pattern
  256.     return YEA::SLIPPERY_TILES::SLIDE_FRAME if slippery_pose?
  257.     return @pattern
  258.   end
  259.  
  260. end # Game_Player
  261.  
  262. #==============================================================================
  263. # ■ Game_Follower
  264. #==============================================================================
  265.  
  266. class Game_Follower < Game_Character
  267.  
  268.   #--------------------------------------------------------------------------
  269.   # new method: pattern
  270.   #--------------------------------------------------------------------------
  271.   def pattern
  272.     return YEA::SLIPPERY_TILES::SLIDE_FRAME if slippery_pose?
  273.     return @pattern
  274.   end
  275.  
  276. end # Game_Follower
  277.  
  278. #==============================================================================
  279. #
  280. # ▼ End of File
  281. #
  282. #==============================================================================
  283.  
  284.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement