Advertisement
ichigogeta

Lens of Truth para v19.1

Mar 18th, 2025
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 7.00 KB | None | 0 0
  1. #===============================================================================
  2. # **                   Eye/Lens of Truth for Essentials                       **
  3. #                                 by Drimer
  4. #===============================================================================
  5. # Events with '#EOT' on their names will be affected by this script.
  6. #   If you want to hide an event appent the tag 'HIDE' or 'SHOW' to... show it!
  7. #  
  8. #   You can also add a third tag which must be a number and will be used as
  9. #   the event limit opacity (to show or hide)
  10. #
  11. #   Examples:
  12. #     #EOT HIDE
  13. #     #EOT HIDE 100
  14. #     #EOT SHOW
  15. #     #EOF SHOW 100
  16. #
  17. #   The item must use the constant 'LENSOFTRUTH' (Don't forget to define it!)
  18. #   You can use the format below to define it in PBS/items.txt
  19. #
  20. #   XXX,LENSOFTRUTH,Lens of Truth,Lens of Truth,8,0,"Description",2,0,6,
  21. #===============================================================================
  22.  
  23. module LensOfTruth
  24.   # Time in seconds
  25.   DURATION = 10
  26.  
  27.   # Range, max is 4
  28.   RANGE = 4
  29. end
  30.  
  31. class Scene_Map
  32.   attr_accessor :eye_of_truth_time
  33.  
  34.   def initialize
  35.     @eye_of_truth_time = 0
  36.   end
  37. end
  38.  
  39. class Game_Event
  40.   attr_accessor :event, :opacity, :through, :character_hue
  41.  
  42.   alias _update_lens update
  43.   def update
  44.     if self.name[/#EOT/]
  45.       if self.name[/HIDE/]
  46.         if InRange?(self.event, LensOfTruth::RANGE%5) &&
  47.             ($scene.is_a?(Scene_Map) ? $scene.eye_of_truth_time > 0 : false)
  48.           opacity = self.name[/(\d+)/] ? $1.to_i : 0
  49.           self.through = true
  50.           self.opacity -= 25.5 if self.opacity > opacity
  51.         else
  52.           if !onEvent?
  53.             self.through = false
  54.           end
  55.           self.opacity += 25.5 if self.opacity < 255
  56.         end
  57.       elsif self.name[/SHOW/]
  58.         if InRange?(self.event, LensOfTruth::RANGE%5) &&
  59.             ($scene.is_a?(Scene_Map) ? $scene.eye_of_truth_time > 0 : false)
  60.           opacity = self.name[/(\d+)/] ? $1.to_i : 255
  61.           if !onEvent?
  62.             self.through = false
  63.           end
  64.           self.opacity += 25.5 if self.opacity < opacity
  65.         else
  66.           self.through = true
  67.           self.opacity -= 25.5 if self.opacity > 0
  68.         end        
  69.       end
  70.     end
  71.     _update_lens
  72.   end
  73. end
  74.  
  75. module LenteVerdad
  76.   @eye_graphic = Sprite.new
  77.   @eye_graphic.z = 3
  78.   @mask = Sprite.new
  79.   @mask.z = 1
  80.   @effect = Sprite.new
  81.   @effect.z = 2
  82.  
  83.  
  84.   def self.create
  85.     @eye_graphic.bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Lens/truth_circle")
  86.     @eye_graphic.ox = @eye_graphic.bitmap.width/2
  87.     @eye_graphic.oy = @eye_graphic.bitmap.height/2
  88.     @eye_graphic.x = Graphics.width/2
  89.     @eye_graphic.y = Graphics.height/2
  90.     @eye_graphic.opacity = 0
  91.    
  92.     @mask.bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Lens/mask")
  93.     @mask.ox = @mask.bitmap.width/2
  94.     @mask.oy = @mask.bitmap.height/2
  95.     @mask.x = Graphics.width/2
  96.     @mask.y = Graphics.height/2
  97.     @mask.opacity = 0
  98.  
  99.     @effect.bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Lens/wave")
  100.     @effect.ox = @effect.bitmap.width/2
  101.     @effect.oy = @effect.bitmap.height/2
  102.     @effect.x = Graphics.width/2
  103.     @effect.y = Graphics.height/2
  104.     @effect.zoom_x = @effect.zoom_y = 0
  105.    
  106.     @created = true
  107.   end
  108.  
  109.   def self.show
  110.     self.create if !@created
  111.   end
  112.  
  113.   def self.update
  114.     return if !@created
  115.     return if $game_temp && $game_temp.in_menu
  116.     if $scene.is_a?(Scene_Map) && $scene.eye_of_truth_time > 0
  117.         @effect.visible = true if !@effect.visible
  118.         @mask.x = @eye_graphic.x = @effect.x = $game_player.x
  119.         @mask.y = @eye_graphic.y = @effect.y = $game_player.y
  120.         $scene.eye_of_truth_time -= 1
  121.         if @eye_graphic.opacity < 255
  122.           @eye_graphic.opacity += 25.5
  123.           @mask.opacity += 25.5
  124.         end
  125.         if @effect.zoom_x < 1.0
  126.           @effect.zoom_x = @effect.zoom_y += 0.025
  127.         else
  128.           if @effect.opacity > 0
  129.             @effect.opacity -= 51
  130.           else
  131.             @effect.zoom_x = @effect.zoom_y = 0
  132.             @effect.opacity = 255
  133.           end
  134.         end
  135.         @eye_graphic.angle += 1
  136.       else
  137.         if @eye_graphic.opacity > 0
  138.           @eye_graphic.angle += 1
  139.           @eye_graphic.opacity -= 25.5
  140.           @mask.opacity -= 25.5
  141.           @effect.visible = false
  142.           @effect.opacity = 255
  143.           @effect.zoom_x = @effect.zoom_y = 0
  144.         end
  145.       end
  146.      
  147.       #--------------------
  148.      
  149.      
  150.     end
  151.    
  152.     def InRange?(event, distance)
  153.       return false if distance<=0
  154.       rad = (Math.hypot((event.x - $game_player.x),(event.y - $game_player.y))).abs
  155.       return true if (rad <= distance)
  156.       return false
  157.     end
  158. end
  159.  
  160. module Graphics
  161.   class << self
  162.     alias _update_eye_update update
  163.     def update
  164.       _update_eye_update
  165.     end
  166.   end
  167. end
  168.  
  169. def pbLensOfTruth
  170.   if ($scene.eye_of_truth_time == 0)
  171.     return true
  172.   else
  173.     Kernel.pbMessage(_INTL("The item is already in use."))
  174.     return false
  175.   end
  176. end
  177.  
  178. ItemHandlers::UseInField.add(:LENSOFTRUTH,proc{|item|
  179.   Kernel.pbMessage(_INTL("\\PN used the Lens of Truth!"))
  180.   waves = []
  181.   @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
  182.   @star["star"]=Sprite.new(@viewport)
  183.   @star["star"].z = 2
  184.   @star["star"].bitmap=RPG::Cache.load_bitmap("Graphics/Pictures/Lens/","part")
  185.   @star["star"].ox = @star.bitmap.width/2
  186.   @star["star"].oy = @star.bitmap.height/2
  187.   @star["star"].x = $game_player.screen_x
  188.   @star["star"].y = $game_player.screen_y
  189.   @star["star"].zoom_x = star.zoom_y = 0
  190.   count = 0
  191.   10.times do
  192.     s = Sprite.new
  193.     s.z = 1
  194.     s.bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Lens/wave")
  195.     s.zoom_x = s.zoom_y = 0
  196.     s.x = $game_player.screen_x
  197.     s.y = $game_player.screen_y
  198.     s.ox = s.bitmap.width/2
  199.     s.oy = s.bitmap.height/2
  200.     waves.push(s)
  201.   end
  202.   pbSEPlay("shiny")
  203.   15.times do
  204.     Graphics.update
  205.     @star["star"].zoom_x = @star["star"].zoom_y += 1.0/15.0
  206.     @star["star"].angle += 3
  207.   end
  208.   pbSEPlay("Saint6")
  209.   30.times do
  210.     Graphics.update
  211.     @star["star"].angle += 3
  212.     count += 1
  213.     for i in 0...waves.length
  214.       next if !waves[i].visible
  215.       if waves[i].zoom_x >= 1.0
  216.         waves[i].visible = false
  217.       end
  218.       waves[i].zoom_x = waves[i].zoom_y += 0.01*i
  219.     end
  220.   end
  221.   5.times do
  222.     Graphics.update
  223.     for i in 0...waves.length
  224.       next if !waves[i].visible
  225.       if waves[i].zoom_x >= 1.0
  226.         waves[i].visible = false
  227.       end
  228.       waves[i].zoom_x = waves[i].zoom_y += 0.01*i
  229.       waves[i].opacity -= 255/5
  230.     end
  231.     @star["star"].zoom_x = star["star"].zoom_y -= 1.0/5.0
  232.     @star["star"].angle += 3
  233.   end
  234.   waves.each{|i| i.dispose}
  235.   @star["star"].dispose
  236.   $scene.eye_of_truth_time = LensOfTruth::DURATION * Graphics.frame_rate if $scene.is_a?(Scene_Map)
  237. })
  238.      
  239. ItemHandlers::UseFromBag.add(:LENSOFTRUTH,proc{|item|
  240.         if pbLensOfTruth
  241.           next 2
  242.         else
  243.           next 0
  244.         end
  245.       })
  246.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement