Guest User

Untitled

a guest
Jan 22nd, 2018
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.94 KB | None | 0 0
  1. #==============================================================================
  2. # ** Window_SkillBattle
  3. #------------------------------------------------------------------------------
  4. # This window displays usable skills on the skill and battle screens.
  5. #==============================================================================
  6.  
  7. class Window_SkillBattle < Window_Selectable
  8. #--------------------------------------------------------------------------
  9. # * Object Initialization
  10. # actor : actor
  11. #--------------------------------------------------------------------------
  12. def initialize(actor)
  13. super(0, 128, 640, 352)
  14. @actor = actor
  15. @column_max = 2
  16. refresh
  17. self.index = 0
  18. # If in battle, move window to center of screen
  19. # and make it semi-transparent
  20. if $game_temp.in_battle
  21. self.y = 64
  22. self.height = 256
  23. self.back_opacity = 160
  24. end
  25. end
  26. #--------------------------------------------------------------------------
  27. # * Acquiring Skill
  28. #--------------------------------------------------------------------------
  29. def skill
  30. return @data[self.index]
  31. end
  32. #--------------------------------------------------------------------------
  33. # * Refresh
  34. #--------------------------------------------------------------------------
  35. def refresh(actor=nil)
  36. if actor != nil
  37. @actor = actor
  38. end
  39. if self.contents != nil
  40. self.contents.dispose
  41. self.contents = nil
  42. end
  43. @data = []
  44. for i in 0...@actor.skills.size
  45. skill = $data_skills[@actor.skills[i]]
  46. if skill != nil
  47. @data.push(skill)
  48. end
  49. end
  50. # If item count is not 0, make a bit map and draw all items
  51. @item_max = @data.size
  52. if @item_max > 0
  53. self.contents = Bitmap.new(width - 32, row_max * 32)
  54. self.get_column_width(width - 32)
  55. for i in 0...@item_max
  56. draw_item(i)
  57. end
  58. end
  59. end
  60. #--------------------------------------------------------------------------
  61. # * Draw Item
  62. # index : item number
  63. #--------------------------------------------------------------------------
  64. def draw_item(index)
  65. skill = @data[index]
  66. if @actor.skill_can_use?(skill.id)
  67. self.contents.font.color = normal_color
  68. else
  69. self.contents.font.color = disabled_color
  70. end
  71. x = 4 + index % 2 * (288 + 32)
  72. y = index / 2 * 32
  73. rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  74. self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  75. bitmap = RPG::Cache.icon(skill.icon_name)
  76. opacity = self.contents.font.color == normal_color ? 255 : 128
  77. self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  78. self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
  79. self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2)
  80. end
  81. #--------------------------------------------------------------------------
  82. # * Help Text Update
  83. #--------------------------------------------------------------------------
  84. def update_help
  85. @help_window.set_text(self.skill == nil ? "" : self.skill.description)
  86. end
  87. end
  88.  
  89.  
  90. #==============================================================================
  91. # ■ Window_SkillBattle
  92. #==============================================================================
  93. class Window_SkillBattle < Window_Selectable
  94. #--------------------------------------------------------------------------
  95. def initialize(actor)
  96. @actor = actor
  97. initialize_scroll if !$game_temp.in_battle
  98. super(0, 128, 640, 352)
  99. @actor = actor
  100. @column_max = 2
  101. get_column_width if !$game_temp.in_battle
  102. @thin = $game_temp.in_battle ? 0 : 32#38
  103. @decrease = $game_temp.in_battle ? 0 : 20
  104. @move_x_right = $game_temp.in_battle ? 0 : -3
  105. @sld = $game_temp.in_battle ? false : true
  106. @actor = $game_party.actors[@actor] if @actor.is_a?(Fixnum)
  107. self.index = 0
  108. if $game_temp.in_battle
  109. self.y = 320
  110. self.height = 160
  111. self.z = 2100
  112. self.back_opacity = MENU_OPACITY
  113. else
  114. # SLD
  115. self.x = 54
  116. self.y = 103 - 16
  117. self.width = 520
  118. self.height = 290
  119. self.back_opacity = 0
  120. self.opacity = 0
  121. end
  122. refresh
  123. end
  124. def initialize_scroll
  125. @scrolling = true # just saying to the script that there'll be scrolling
  126. @scroll_x = 550 # where the scroll should be horizontally (note that you CAN'T use self.x, as it's not specified yet)
  127. @scroll_y = 105 # where the scroll should be vertically (note that you CAN'T use self.y, as it's not specified yet)
  128. @scroll_width = 24 # the scroll's width. if going vertically, you still need to specify the width, which is the width of the scroll's images. Otherwise, it should be self.width - 32 (but don't use self.width, not specified)
  129. @scroll_height = 255 # the scroll's height. if going horizontally, you still need to specify the height, which is the height of the scroll's images. Otherwise, it should be self.height - 32 (but don't use self.height, not specified)
  130. @scroll_dir = :ver # :hor => horizontally, :ver => vertically
  131. @scroll_max_size = 452 # this is used so that the scroll understands how many pixels there are to scroll. Use the width (or height if going vertically) of the window's bitmap (self.contents). Not specified yet, so don't use the bitmap directly!
  132. @scroll_row_max = @actor.skills.size / 2 - 7 # this sets the number of scrolls there are. If you put 5 for example, you'll have 4 clicks to do to get from the first items to the last ones. I suggest going like this:
  133. # if you go horizontally, take (not directly, not specified yet!) @column_max, and substract the number of columns shown in one page - 1.
  134. # Example : @column_max = 12, @column_width = 50, window's width = 200. I'll see 4 items per page, so: 12 - (4 - 1) = 9.
  135. # Same thing when you go vertically, except you'll use self.row_max (which is @item_max / @column_max) instead (not directly, again!). May not be very clear at first, but you'll figure this out! o/
  136. @scroll_z = 200 # the z value of the scroll.
  137. end
  138. #--------------------------------------------------------------------------
  139. def draw_item(index)
  140. skill = @data[index]
  141. if @actor.skill_can_use?(skill.id)
  142. self.contents.font.color = normal_color
  143. else
  144. self.contents.font.color = disabled_color
  145. end
  146. if !@sld
  147. x = 4 + index % 2 * (288 + 32)
  148. y = index / 2 * 32
  149. rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  150. self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  151. bitmap = RPG::Cache.icon(skill.icon_name)
  152. opacity = self.contents.font.color == normal_color ? 255 : 128
  153. self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  154. self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
  155. cost = @actor.calc_sp_cost(@actor, skill)
  156. self.contents.draw_text(x + 232, y, 48, 32, cost.to_s, 2)
  157. else
  158. x = 4 + index % 2 * 257
  159. y = index / 2 * 32
  160. rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  161. self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  162. bitmap = RPG::Cache.icon(skill.icon_name)
  163. opacity = self.contents.font.color == normal_color ? 255 : 128
  164. self.contents.font.size = $fontsize2
  165. self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  166. self.contents.draw_text(x + 28, y, 200, 32, skill.name, 0)
  167. cost = @actor.calc_sp_cost(@actor, skill)
  168. self.contents.draw_text(x + 175, y, 50, 32, cost.to_s, 2)
  169. end
  170. end
  171. end
  172.  
  173. #==============================================================================
  174. # ** Window_SkillStatus
  175. #------------------------------------------------------------------------------
  176. # This window displays the skill user's status on the skill screen.
  177. #==============================================================================
  178.  
  179. class Window_SkillStatusHUD < Window_Base
  180. #--------------------------------------------------------------------------
  181. # * Object Initialization
  182. # actor : actor
  183. #--------------------------------------------------------------------------
  184. def initialize(actor)
  185. super(0, 64, 520, 64)
  186. self.contents = Bitmap.new(width - 32, height - 32)
  187. @actor = actor
  188. refresh
  189. end
  190. #--------------------------------------------------------------------------
  191. # * Refresh
  192. #--------------------------------------------------------------------------
  193. def refresh
  194. self.contents.clear
  195. self.contents.font.size = $fontsize
  196. x = 6
  197. draw_actor_name(@actor, x, 0)
  198. x += 100
  199. draw_actor_state(@actor, x, 2)
  200. x += 70
  201. draw_bar(@actor, x + 63, 0, 75, 16, @actor.hp, @actor.maxhp, text_color(12))
  202. draw_actor_hp(@actor, x, -1, 140)
  203. x += 160
  204. draw_bar(@actor, x + 63, 0, 75, 16, @actor.sp, @actor.maxsp, text_color(13))
  205. draw_actor_sp(@actor, x, -1, 140)
  206. end
  207. end
  208.  
  209. #==============================================================================
  210. # ** Window_ReverseSkill
  211. #==============================================================================
  212.  
  213. class Window_Skill
  214. #--------------------------------------------------------------------------
  215. Window_BG = 'Background'
  216. #--------------------------------------------------------------------------
  217. def initialize(actor)#_index)
  218. @disposed = false
  219. #@actor_index = actor_index
  220. @actor = $game_party.actors[actor]
  221. #@actor = actor
  222. create_windows
  223. @started = 0
  224. end
  225. #--------------------------------------------------------------------------
  226. def create_windows
  227. @hud = Sprite.new
  228. @hud.bitmap = RPG::Cache.picture("Window_Skill/"+Window_BG)
  229. #@name_window = Window_ActorName.new(@actor)
  230. @skill_list = Window_SkillBattle.new(@actor)#Window_ReverseSkillList.new(@actor)
  231. @help_window = Window_Help.new(54,356,510,66)
  232. @help_window.opacity = 0
  233. #@help_window.x = 54
  234. #@help_window.y = @help_window.y + 356
  235. #@help_window.width = 510
  236. #@help_window.height = 66
  237. @skill_list.help_window = @help_window
  238. @status_window = Window_SkillStatusHUD.new(@actor)
  239. @status_window.opacity = 0
  240. @status_window.x = 58
  241. @status_window.y = @status_window.y - 18
  242. end
  243. #--------------------------------------------------------------------------
  244. def initialize_popup(style)
  245. img = RPG::Cache.picture("Window_ReverseSkill/BackgroundPopup")
  246. @popup = Window_Popup.new(img)
  247. @counting = [0,50]
  248. if style == :question
  249. @popup.set_main(["Do you really want to","reverse this skill?"])
  250. @popup.set_choice(0, "Yes")
  251. @popup.set_choice(1, "No")
  252. @popup.index = 1
  253. else
  254. @popup.set_main(["You reversed the skill into","a Clean Scroll and Magic Orb!"])
  255. @popup.set_choice(0, "OK")
  256. @popup.index = 0
  257. end
  258. update_popup
  259. end
  260. #--------------------------------------------------------------------------
  261. def update
  262. return if @disposed
  263. $game_player.prevent_movement_with_mouse = true
  264. $game_player.prevent_movement = true
  265. if @popup
  266. update_popup
  267. return
  268. end
  269. @skill_list.update
  270. @help_window.update
  271. @status_window.update
  272. @started += 1
  273. return if @started < 5
  274. update_input
  275. end
  276. #--------------------------------------------------------------------------
  277. def update_input
  278. if Keys.trigger?(:B) || Mouse.trigger?(1)
  279. $game_system.se_play($data_system.cancel_se)
  280. #$game_temp.freeze_save_call = true
  281. #self.dispose
  282. HUD.close_window
  283. elsif Keys.trigger?(:C) || Mouse.trigger?(0)
  284. # Get currently selected data on the skill window
  285. @skill = @skill_list.skill
  286. # If unable to use
  287. if @skill == nil or not @actor.skill_can_use?(@skill.id)
  288. # Play buzzer SE
  289. $game_system.se_play($data_system.buzzer_se)
  290. return
  291. end
  292. # Play decision SE
  293. $game_system.se_play($data_system.decision_se)
  294. # If effect scope is ally
  295. if @skill.scope >= 3
  296. # Activate target window
  297. @skill_list.active = false
  298. #@target_window.x = (@skill_list.index + 1) % 2 * 304
  299. #@target_window.visible = true
  300. #@target_window.active = true
  301. # Set cursor position to effect scope (single / all)
  302. #if @skill.scope == 4 || @skill.scope == 6
  303. # @target_window.index = -1
  304. #elsif @skill.scope == 7
  305. # @target_window.index = @actor_index - 10
  306. #else
  307. # @target_window.index = 0
  308. #end
  309.  
  310. HUD.start_select(:actors, [0, ["Window_Skill.new", :window],
  311. ["Window_Skill.new", :skill_use]])
  312.  
  313. # If effect scope is other than ally
  314. else
  315. # If common event ID is valid
  316. if @skill.common_event_id > 0
  317. # Common event call reservation
  318. $game_temp.common_event_id = @skill.common_event_id
  319. # Play use skill SE
  320. $game_system.se_play(@skill.menu_se)
  321. # Use up SP
  322. @actor.sp -= @skill.sp_cost
  323. # Remake each window content
  324. @status_window.refresh
  325. @skill_list.refresh
  326. #@target_window.refresh
  327. # Switch to map screen
  328. $scene = Scene_Map.new
  329. return
  330. end
  331. end
  332. return
  333. #skill = @skill_list.skill
  334. #if skill.nil?
  335. # $game_system.se_play($data_system.buzzer_se)
  336. # return
  337. #end
  338. #$game_system.se_play($data_system.decision_se)
  339. #initialize_popup(:question)
  340. # If R button was pressed
  341. # If R button was pressed
  342. elsif Keys.trigger?(:R)
  343. # Play cursor SE
  344. $game_system.se_play($data_system.cursor_se)
  345. # To next actor
  346. @actor_index += 1
  347. @actor_index %= $game_party.actors.size
  348. @actor = $game_party.actors[actor_index]
  349. # Switch to different skill screen
  350. @skill_list.refresh(@actor)
  351. return
  352. # If L button was pressed
  353. elsif Keys.trigger?(:L)
  354. # Play cursor SE
  355. $game_system.se_play($data_system.cursor_se)
  356. # To previous actor
  357. @actor_index += $game_party.actors.size - 1
  358. @actor_index %= $game_party.actors.size
  359. @actor = $game_party.actors[actor_index]
  360. # Switch to different skill screen
  361. @skill_list.refresh(@actor)
  362. return
  363. end
  364. end
  365. #--------------------------------------------------------------------------
  366. def update_popup
  367. @popup.update
  368. if @popup.main != ["Do you really want to","reverse this skill?"]
  369. @counting[0] += 1
  370. if @counting[0] >= @counting[1]
  371. dispose_popup
  372. @started = 0
  373. return
  374. end
  375. end
  376. case @popup.decision
  377. when 0
  378. if @popup.main == ["Do you really want to","reverse this skill?"]
  379. $game_system.se_play(($data_system.decision_se))
  380. skill = @skill_list.skill
  381. @actor.forget_skill(skill.id)
  382. $game_party.gain_item(49, 1)
  383. $game_party.gain_item(50, 1)
  384. @skill_list.refresh
  385. dispose_popup
  386. initialize_popup(:reversed)
  387. else
  388. $game_system.se_play($data_system.decision_se)
  389. dispose_popup
  390. end
  391. @started = 0
  392. when 1, -1
  393. $game_system.se_play($data_system.cancel_se)
  394. dispose_popup
  395. @started = 0
  396. end
  397. end
  398. #--------------------------------------------------------------------------
  399. def dispose_popup
  400. @popup.dispose unless @popup.nil?
  401. @popup = nil
  402. end
  403. #--------------------------------------------------------------------------
  404. def dispose
  405. @hud.dispose
  406. #HUD.main.reset_tone
  407. #@name_window.dispose
  408. @skill_list.dispose
  409. @help_window.dispose
  410. @status_window.dispose
  411. dispose_popup
  412. $game_player.prevent_movement_with_mouse = false
  413. $game_player.prevent_movement = false
  414. @disposed = true
  415. end
  416. #--------------------------------------------------------------------------
  417. def disposed?
  418. return @disposed
  419. end
  420. end
Add Comment
Please, Sign In to add comment