JaxxLTiming

NPC_HUD_0001

Jul 14th, 2013
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.38 KB | None | 0 0
  1. #===== Rpg Makver VX ACE Script =============================
  2. #= NPC HUD
  3. #===== By: ==================================================
  4. #= Jaxx L.Timing ---------------------- VERSION: 7/14/2013 =#
  5. #===== Credit to: ===========================================
  6. #= lilcooldude69
  7. #= For his 'Very Simple Hud' which I used as a referece.
  8. #= http://forums.rpgmakerweb.com/index.php?/topic/1057-very-simple-hud/
  9. #===== Compatible With: =====================================
  10. #= Rpg Maker VX ACE
  11. #===== Description: =========================================
  12. #= Shows the stats of any character you want.
  13. #===== Instructions: ========================================
  14. #= Step One: == Create an actor to represent your NPC and write
  15. #=  down their position in the list for later reference.
  16. #= Step Two: == Create an event using the NPC's sprite.
  17. #= Step Three: == Create an empty event next to the event you just made.
  18. #= Step Four: == Set the event to switch ON a Switch of your choosing,
  19. #=  write down the Switch number. Set the event to trigger on player contact.
  20. #= Step Five: == Set the event to substitute a variable's value of your choosing
  21. #=  with the position number from Step One as a CONSTANT, write down
  22. #=  the Variable number you choose. Set the event to trigger on player contact.
  23. #= Step Six: Copy and paste this empty event on each side of your NPC.
  24. #= Step Seven: == Set up a different empty event surrounding your empty events
  25. #=  that will turn OFF the Switch from Step Four and surround the events you made.
  26. #= Final Step: == Plug the Switch and Variable numbers you wrote down into
  27. #=  the 'Customization Settings' below.
  28. #============================================================
  29.  
  30. module NPC_HUD_Settings
  31.  
  32.   #----------------------------------------------------
  33.   # * Customization Settings
  34.   #----------------------------------------------------
  35.     SWITCH = 1          # Switch to activate NPC_HUD
  36.     VARIABLE = 1        # Variable set to actor values
  37.     TRANSPARENT = false # Make 'true' if you want the portrait to appear semi-transparent.
  38.     SEPARATOR = " / "   # Set the separator between Name and Title
  39.     VERTICAL = 280      # Pixels between the top of the screen and the HUD
  40.     HORIZONTAL = 62     # Pixels between the LEFT side of the screen and the HUD
  41.                         # *HORIZONTAL = 62 centers the HUD*
  42.                        
  43. end
  44.  
  45. include NPC_HUD_Settings
  46.  
  47. class NPC_HUD < Window_Base
  48.   #----------------------------------------------------
  49.   # * Object Initialization
  50.   #----------------------------------------------------
  51.     def initialize
  52.       super(HORIZONTAL,VERTICAL,420,125)
  53.       self.visible = $game_switches[SWITCH]
  54.       $game_variables[VARIABLE] = 1
  55.       @actor = $game_actors[$game_variables[VARIABLE]]
  56.       refresh
  57.     end
  58.   #----------------------------------------------------
  59.   # * Refresh
  60.   #----------------------------------------------------
  61.     def refresh
  62.       self.contents.clear
  63.       contents.clear
  64.       draw_window_content
  65.     end
  66.   #----------------------------------------------------
  67.   # * Draw Window Contents
  68.   #----------------------------------------------------
  69.     def draw_window_content
  70.       @actor = $game_actors[$game_variables[VARIABLE]]
  71.       @level = @actor.level
  72.       @hp = @actor.hp
  73.       @mp = @actor.mp
  74.       contents.font.size = 20
  75.       draw_face(@actor.face_name, @actor.face_index, 0, 0, enabled = TRANSPARENT)
  76.       draw_actor_name(@actor, 110, 0)
  77.       draw_actor_nickname(@actor, 126+$game_actors[$game_variables[VARIABLE]].name.size*9, 0)
  78.       draw_text(107+$game_actors[$game_variables[VARIABLE]].name.size*9, 0, 13, 24, SEPARATOR, 2)
  79.       draw_actor_level(@actor, 334, 0)
  80.       draw_actor_hp(@actor, 110, 20, 280)
  81.       draw_actor_mp(@actor, 110, 40, 280)
  82.       draw_actor_params(@actor, 110, 65, 2)
  83.       draw_actor_params(@actor, 150, 65, 3)
  84.       draw_actor_params(@actor, 190, 65, 4)
  85.       draw_actor_params(@actor, 230, 65, 5)
  86.       draw_actor_params(@actor, 270, 65, 6)
  87.       draw_actor_params(@actor, 310, 65, 7)
  88.     end
  89.   #--------------------------------------------------------------------------
  90.   # * Draw Parameters
  91.   #--------------------------------------------------------------------------
  92.     def draw_actor_params(actor, x, y, param_id)
  93.       change_color(normal_color)
  94.       draw_text(x, y + 15, 36, line_height, actor.param(param_id), 2)
  95.       change_color(system_color)
  96.       draw_text(x, y, 120, line_height, Vocab::param(param_id))
  97.     end
  98.   #-----------------------------------------------------
  99.   # * Update
  100.   #-----------------------------------------------------
  101.     def update
  102.       super
  103.       self.visible = $game_switches[SWITCH]
  104.       return if !self.visible
  105.       if @actor != $game_actors[$game_variables[VARIABLE]]
  106.         refresh
  107.       end
  108.     end
  109. end
  110.  
  111. class Scene_Map < Scene_Base
  112.   #------------------------------------------------------
  113.   # * Scene_Map Class
  114.   #------------------------------------------------------
  115.   alias jlt_start_scenemap_eh849h       start
  116.   alias jlt_terminate_scenemap_eh849h   terminate
  117.   alias jlt_update_scenemap_eh849h      update
  118.     def start
  119.       jlt_start_scenemap_eh849h()
  120.       @winhud = NPC_HUD.new
  121.       update
  122.     end
  123.     def terminate
  124.       @winhud.dispose
  125.       jlt_terminate_scenemap_eh849h()
  126.     end
  127.     def update
  128.       jlt_update_scenemap_eh849h()
  129.       @winhud.update
  130.     end
  131. end
Advertisement
Add Comment
Please, Sign In to add comment