Advertisement
SSTrihan

HorrorVale Bolt sprite change

Feb 8th, 2023
1,044
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 6.79 KB | Source Code | 0 0
  1. #-------------------------------------------------------------------------------
  2. # Don't remove this header!
  3. #-------------------------------------------------------------------------------
  4. # Region Based Sprite Script
  5. # by Black Mage (https://burningwizard.wordpress.com/)
  6. #
  7. # Version : 1.4 (Trihan)
  8. #
  9. # This script is commisioned by Batworks Software.
  10. #-------------------------------------------------------------------------------
  11.  
  12. #-------------------------------------------------------------------------------
  13. # Version History
  14. #-------------------------------------------------------------------------------
  15. # 1.4 - Added switch to prevent Alice graphic changes (Trihan)
  16. # 1.3 - Fix a bug where the character under DEATH_STATE_ID is using their
  17. #       default sprite instead of ignoring the script.
  18. #
  19. # 1.2 - Fix a bug where the followers registered inside the setting still has
  20. #       appears on the map even when the followers visibily is turned off.
  21. #
  22. # 1.1 - Fix a bug where the sprite with $ sign are displayed incorrectly when
  23. #       the character index is greater than 0.
  24. #
  25. # 1.0 - Initial design.
  26. #-------------------------------------------------------------------------------
  27.  
  28. #-------------------------------------------------------------------------------
  29. # What this script do?
  30. #-------------------------------------------------------------------------------
  31. # Upon entering certain region, the player/follower sprite will change to the
  32. # one that assigned inside the SPRITE_LIST.
  33. #
  34. # Region ID of value -1 is reserved as the default sprite to be assigned when
  35. # the sprite that corresponds to current player character region ID is not
  36. # assigned inside the SPRITE_LIST. If the value -1 itself is not registered,
  37. # the sprite that will be used is the one that will be shown if the script is
  38. # not used at all (in other words, the sprite will behave like how the default
  39. # system would be).
  40. #
  41. # NOTE: The graphic files must be present inside the Graphics/Characters folder,
  42. # as the script doesn't have ability to read whether certain file exists inside
  43. # the RTP.
  44. #-------------------------------------------------------------------------------
  45.  
  46. #-------------------------------------------------------------------------------
  47. # Settings for the script.
  48. #-------------------------------------------------------------------------------
  49. module BLACK
  50.   # Any actor that has any state listed below would not be affected by this
  51.   # script.
  52.   DEATH_STATE_ID = [1,90]
  53.  
  54.   ALICE_SWITCH_ID = 582
  55.  
  56.   SPRITE_LIST = {
  57.   # actor id
  58.     1         => {
  59.                 # region ID        file name
  60.                   -1            => "actor4",
  61.                   3             => "actor2",  
  62.                   4             => "actor3",
  63.                   },
  64.                
  65.     5         => {
  66.                   -1            => "$bolt-2",
  67.                   20             => "$bolt-2side",
  68.                   },
  69.                  
  70.     17         => {
  71.                   -1            => "$wendy",
  72.                   20             => "$wendyside",
  73.                   },
  74.                  
  75.     19         => {
  76.                   -1            => "$flynt",
  77.                   20             => "$flyntside",
  78.                   },
  79.                  
  80.     24         => {
  81.                   -1            => "$buckethead",
  82.                   20             => "$bucketheadside",
  83.                   },
  84.                  
  85.     31         => {
  86.                   -1            => "$rojo",
  87.                   20             => "$rojoside",
  88.                   },
  89.                  
  90.     33         => {
  91.                   -1            => "$george",
  92.                   20             => "$georgeside",
  93.                   },
  94.   }
  95. end
  96. #-------------------------------------------------------------------------------
  97.  
  98. #-------------------------------------------------------------------------------
  99. # * Beyond this is the sacred land of code. You need programming qualification
  100. #   to dwelve deeper, or it'll cause many unnecessary problems. Proceed on your
  101. #   own risk.
  102. #-------------------------------------------------------------------------------
  103.  
  104. class Game_CharacterBase
  105.   attr_accessor :cur_region
  106.   alias b_reg_spr_init initialize
  107.   def initialize; b_reg_spr_init; @cur_region = 0; end
  108. end
  109.  
  110. class Sprite_Character < Sprite_Base
  111.   include BLACK
  112.   def graphic_changed?
  113.     @tile_id != @character.tile_id ||
  114.     @character_name != @character.character_name ||
  115.     @character_index != @character.character_index ||
  116.     black_region_check
  117.   end
  118.   def black_region_check
  119.     return false if !black_actor?
  120.     #char_stt_id = @character.actor.states.collect {|stt| stt.id }
  121.     #return false if !(char_stt_id & DEATH_STATE_ID).empty?
  122.     return false if !black_actor?
  123.     a = @character.cur_region == @character.region_id
  124.     if a
  125.       return false
  126.     else
  127.       @character.cur_region = @character.region_id
  128.       return true
  129.     end
  130.   end
  131.   def black_actor?
  132.     return false if @character.id != 0
  133.     return false if @character.class.name == "Game_Vehicle"
  134.     return false if @character.actor.nil?
  135.     return true
  136.   end
  137.   def set_character_bitmap
  138.     a = get_sprite_name; b = @character_name
  139.     (b = a[0] if File.exists?(a[1])) if !a.nil?
  140.     if black_actor?
  141.       char_stt_id = @character.actor.states.collect {|stt| stt.id }
  142.       b = @character_name if !(char_stt_id & DEATH_STATE_ID).empty?
  143.     end
  144.     self.bitmap = Cache.character(b)
  145.     sign = b[/^[\!\$]./]
  146.     if sign && sign.include?('$')
  147.       @cw = bitmap.width / 3; @ch = bitmap.height / 4
  148.     else
  149.       @cw = bitmap.width / 12; @ch = bitmap.height / 8
  150.     end
  151.     self.ox = @cw / 2; self.oy = @ch
  152.   end
  153.   def get_sprite_name
  154.     return nil if @character.id != 0
  155.     return nil if @character.class.name == "Game_Follower" && !$game_player.followers.visible
  156.     return nil if !["Game_Follower","Game_Player"].include?(@character.class.name)
  157.     return nil if @character.actor.nil?
  158.     return nil if @character.actor.id == 1 && !$game_switches[ALICE_SWITCH_ID]
  159.     return nil if SPRITE_LIST[@character.actor.id].nil?
  160.     a = SPRITE_LIST[@character.actor.id][@character.region_id]
  161.     a = SPRITE_LIST[@character.actor.id][-1] if a.nil?
  162.     return nil if a.nil?
  163.     return [a, "Graphics/Characters/" + a + ".png"]
  164.   end
  165.   def update_src_rect
  166.     if @tile_id == 0
  167.       index = @character.character_index
  168.       a = get_sprite_name; b = @character_name
  169.       (b = a[0] if File.exists?(a[1])) if !a.nil?
  170.       sign = b[/^[\!\$]./]
  171.       index = 0 if sign && sign.include?('$')
  172.       pattern = @character.pattern < 3 ? @character.pattern : 1
  173.       sx = (index % 4 * 3 + pattern) * @cw
  174.       sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch
  175.       self.src_rect.set(sx, sy, @cw, @ch)
  176.     end
  177.   end
  178.  
  179.     end
  180.  
  181.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement