Guest User

Untitled

a guest
Feb 19th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.42 KB | None | 0 0
  1. #--------------------------------------------------
  2. #in a event add a new script : #
  3. #change_color(eventid,color) #
  4. #to self event id use "@event_id" #
  5. #By Zarby, no credit needed #
  6. #--------------------------------------------------
  7.  
  8.  
  9. class Game_Interpreter
  10. def change_color(eventid,color)
  11. $game_map.events[eventid].changecolor(color)
  12. end
  13. end
  14.  
  15.  
  16. class Spriteset_Map
  17.  
  18. def create_characters
  19. @character_sprites = []
  20. for i in $game_map.events.keys.sort
  21. sprite = Sprite_Character.new(@viewport1, $game_map.events[i],$game_map.events[i].color)
  22. @character_sprites.push(sprite)
  23. end
  24. for vehicle in $game_map.vehicles
  25. sprite = Sprite_Character.new(@viewport1, vehicle)
  26. @character_sprites.push(sprite)
  27. end
  28. @character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
  29. end
  30.  
  31. end
  32.  
  33. class Sprite_Character < Sprite_Base
  34.  
  35.  
  36. def initialize(viewport, character = nil,color = 0)
  37. super(viewport)
  38. @character = character
  39. @balloon_duration = 0
  40. @color = color
  41. update
  42. end
  43.  
  44.  
  45. def update_bitmap
  46. if @tile_id != @character.tile_id or
  47. @character_name != @character.character_name or
  48. @character_index != @character.character_index
  49. @tile_id = @character.tile_id
  50. @character_name = @character.character_name
  51. @character_index = @character.character_index
  52. if @tile_id > 0
  53. sx = (@tile_id / 128 % 2 * 8 + @tile_id % 8) * 32;
  54. sy = @tile_id % 256 / 8 % 16 * 32;
  55. self.bitmap = tileset_bitmap(@tile_id)
  56. self.src_rect.set(sx, sy, 32, 32)
  57. self.ox = 16
  58. self.oy = 32
  59. else
  60. self.bitmap = @character.bitmap
  61. sign = @character_name[/^[\!\$]./]
  62.  
  63. @cw = self.bitmap.width / 3
  64. @ch = self.bitmap.height / 4
  65. self.ox = @cw / 2
  66. self.oy = @ch
  67. end
  68. end
  69. if @character.color != @character.oldcolor
  70. self.bitmap.hue_change(@character.color)
  71. @character.oldcolor = @character.color
  72. end
  73. end
  74.  
  75.  
  76. def update_src_rect
  77. if @tile_id == 0
  78. index = 0
  79. pattern = @character.pattern < 3 ? @character.pattern : 1
  80. sx = (index % 4 * 3 + pattern) * @cw
  81. sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch
  82. self.src_rect.set(sx, sy, @cw, @ch)
  83. end
  84. end
  85. end
  86.  
  87.  
  88. class Game_Player < Game_Character
  89.  
  90. def refresh
  91. if $game_party.members.size == 0
  92. @character_name = ""
  93. @character_index = 0
  94. else
  95. actor = $game_party.members[0] # Get front actor
  96. @character_name = actor.character_name
  97. @character_index = actor.character_index
  98. set_graphic(@character_name,@character_index)
  99. end
  100. end
  101.  
  102. end
  103.  
  104.  
  105. class Game_Event < Game_Character
  106.  
  107.  
  108. def setup(new_page)
  109. @page = new_page
  110. if @page == nil
  111. @tile_id = 0
  112. @character_name = ""
  113. @character_index = 0
  114. @move_type = 0
  115. @through = true
  116. @trigger = nil
  117. @list = nil
  118. @interpreter = nil
  119. else
  120. @tile_id = @page.graphic.tile_id
  121. @character_name = @page.graphic.character_name
  122. @character_index = @page.graphic.character_index
  123. if @tile_id == 0
  124. set_graphic(@character_name,@character_index)
  125. end
  126. if @original_direction != @page.graphic.direction
  127. @direction = @page.graphic.direction
  128. @original_direction = @direction
  129. @prelock_direction = 0
  130. end
  131. if @original_pattern != @page.graphic.pattern
  132. @pattern = @page.graphic.pattern
  133. @original_pattern = @pattern
  134. end
  135. @move_type = @page.move_type
  136. @move_speed = @page.move_speed
  137. @move_frequency = @page.move_frequency
  138. @move_route = @page.move_route
  139. @move_route_index = 0
  140. @move_route_forcing = false
  141. @walk_anime = @page.walk_anime
  142. @step_anime = @page.step_anime
  143. @direction_fix = @page.direction_fix
  144. @through = @page.through
  145. @priority_type = @page.priority_type
  146. @trigger = @page.trigger
  147. @list = @page.list
  148. @interpreter = nil
  149. if @trigger == 4 # Trigger is [Parallel Process]?
  150. @interpreter = Game_Interpreter.new # For parallel processing
  151. end
  152. end
  153. update_bush_depth
  154.  
  155. end
  156.  
  157. end
  158.  
  159.  
  160.  
  161.  
  162. class Game_Character
  163. attr_accessor :color
  164. attr_accessor :oldcolor
  165. attr_accessor :bitmap
  166. def initialize
  167. @id = 0
  168. @x = 0
  169. @y = 0
  170. @real_x = 0
  171. @real_y = 0
  172. @tile_id = 0
  173. @character_name = ""
  174. @character_index = 0
  175. @opacity = 255
  176. @blend_type = 0
  177. @direction = 2
  178. @pattern = 1
  179. @move_route_forcing = false
  180. @priority_type = 1
  181. @through = false
  182. @bush_depth = 0
  183. @animation_id = 0
  184. @balloon_id = 0
  185. @transparent = false
  186. @original_direction = 2 # Original direction
  187. @original_pattern = 1 # Original pattern
  188. @move_type = 0 # Movement type
  189. @move_speed = 4 # Movement speed
  190. @move_frequency = 6 # Movement frequency
  191. @move_route = nil # Move route
  192. @move_route_index = 0 # Move route index
  193. @original_move_route = nil # Original move route
  194. @original_move_route_index = 0 # Original move route index
  195. @walk_anime = true # Walking animation
  196. @step_anime = false # Stepping animation
  197. @direction_fix = false # Fixed direction
  198. @anime_count = 0 # Animation count
  199. @stop_count = 0 # Stop count
  200. @jump_count = 0 # Jump count
  201. @jump_peak = 0 # Jump peak count
  202. @wait_count = 0 # Wait count
  203. @locked = false # Locked flag
  204. @prelock_direction = 0 # Direction before lock
  205. @move_failed = false # Movement failed flag
  206. @color = 0
  207. @oldcolor = 0
  208. @bitmap = Bitmap.new(96,128)
  209. end
  210.  
  211. def set_graphic(character_name, character_index)
  212. @tile_id = 0
  213. @character_name = character_name
  214. @character_index = character_index
  215. frombitmap = Cache.character(@character_name)
  216.  
  217. @bitmap.clear
  218. if @character_name.include?('!')
  219. if @character_index <= 3
  220. ch = frombitmap.height/2
  221. @bitmap = Bitmap.new(96,ch)
  222. @bitmap.blt(0,0,frombitmap,Rect.new(@character_index*96,0,96,ch))
  223.  
  224. end
  225. if @character_index > 3
  226. ch = frombitmap.height/2
  227. @ci = @character_index-4
  228. @bitmap = Bitmap.new(96,ch)
  229. @bitmap.blt(0,0,frombitmap,Rect.new(@ci*96,ch,96,ch))
  230. end
  231. end
  232. if @character_name.include?('$')
  233. @bitmap.clear
  234. @bitmap = Bitmap.new(frombitmap.width,frombitmap.height)
  235. @bitmap.blt(0,0,frombitmap,Rect.new(0,0,frombitmap.width,frombitmap.height))
  236. end
  237. if @character_name.include?('$') == false and @character_name.include?('!') == false
  238. @bitmap.clear
  239. if @character_index <= 3
  240. @bitmap.blt(0,0,frombitmap,Rect.new(@character_index*96,0,96,128))
  241. end
  242. if @character_index > 3
  243. @ci = @character_index-4
  244. @bitmap.blt(0,0,frombitmap,Rect.new(@ci*96,128,96,128))
  245. end
  246. end
  247. @bitmap.hue_change(@color)
  248. end
  249.  
  250.  
  251. def changecolor(color)
  252. @color = color
  253. refresh
  254. end
  255.  
  256. end
Add Comment
Please, Sign In to add comment