Guest User

Untitled

a guest
Dec 15th, 2016
77
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ==============================================================================
  2. # Vampyr Kernel 1.4
  3. #==============================================================================
  4. # This module is necessary to activate and enhance compatibility of all Vampyr's Scripts
  5. #------------------------------------------------------------------------------
  6. module Vampyr_Kernel
  7.  
  8. @scripts = {}
  9. @warnings = {}
  10.  
  11. Print_Errors = false
  12.  
  13. def self.register(script, version, date)
  14. @scripts[script] = [version, date]
  15. end
  16.  
  17. def self.enabled?(script, version=nil)
  18. if @scripts.has_key?(script)
  19. if version.nil?
  20. return true
  21. elsif @scripts[script][0] >= version
  22. return true
  23. else
  24. if @warnings[script].nil? and Print_Errors
  25. print "'#{script}' is obsolete.\r\nSome functions won't work correctly"
  26. @warnings[script] = ["is obsolete"]
  27. self.write_log
  28. end
  29. return false
  30. end
  31. else
  32. if $TEST and @warnings[script].nil? and Print_Errors
  33. print "Unable to find script '#{script}' or it is placed in wrong place.\r\nSome functions won't work correctly"
  34. @warnings[script] = ["Unable to find"]
  35. self.write_log
  36. end
  37. return false
  38. end
  39. end
  40.  
  41. def self.show_scripts(alert=true)
  42. list = "Vampyr Scripts [#{@scripts.size}]:\r\n\r\n"
  43. @scripts.each { |key, value| list += "#{key.gsub("Vampyr ", "")} #{value[0]} #{value[1]}\r\n" }
  44. list += "\r\nWarnings:\r\n" if @warnings != {}
  45. @warnings.each { |key, value| list += "#{key} #{value}\r\n" }
  46. return print list if alert
  47. return list
  48. end
  49.  
  50. def self.write_log
  51. file = File.new("Vampyr_Log-#{Time.now.strftime("%m_%d_%Y")}.txt", "wb")
  52. file.write(self.show_scripts(false))
  53. file.close
  54. end
  55.  
  56. def self.selfswitch(event_id, switch, status)
  57. key = [$game_map.map_id, event_id, switch]
  58. if status == nil
  59. $game_self_switches[key] = !$game_self_switches[key]
  60. else
  61. $game_self_switches[key] = status
  62. end
  63. $game_map.need_refresh = true
  64. end
  65.  
  66. end
  67.  
  68. #------------------------------------------------------------------------------
  69. # Object
  70. #------------------------------------------------------------------------------
  71. class Object
  72.  
  73. def to_b
  74. return true if self == "true"
  75. return true if self.to_i > 0
  76. return false
  77. end
  78.  
  79. def number?
  80. return true unless self.scan(/\d/).empty?
  81. return false
  82. end
  83.  
  84. def transform
  85. return self.to_i if self.number?
  86. return self.to_s
  87. end
  88.  
  89. def get_width
  90. b = Bitmap.new(1, 1)
  91. w = a.text_size(self.to_s).width
  92. b.dispose
  93. return w
  94. end
  95.  
  96. def to_rgb
  97. x = self.delete("#").scan(/../).map { |i| i.to_i(16) }
  98. return Color.new(x[0].to_f, x[1].to_f, x[2].to_f)
  99. end
  100.  
  101. end
  102.  
  103. #------------------------------------------------------------------------------
  104. # Sprite
  105. #------------------------------------------------------------------------------
  106. class Sprite
  107.  
  108. def draw_icon(icon, x, y)
  109. return if self.bitmap == nil
  110. rect = Rect.new(icon%16*24, icon/16*24, 24, 24)
  111. self.bitmap.blt(x, y, Cache.system("Iconset"), rect)
  112. end
  113.  
  114. end
  115.  
  116. #------------------------------------------------------------------------------
  117. # Bitmap
  118. #------------------------------------------------------------------------------
  119. class Bitmap
  120.  
  121. def draw_outlined_text(*args)
  122. if args[0].is_a?(Rect)
  123. x = args[0].x; y = args[0].y
  124. w = args[0].width; h = args[0].height
  125. s = args[1]
  126. a = (args[2].nil? ? 0 : args[2])
  127. c = (args[3].nil? ? Font.default_color : args[3])
  128. else
  129. x = args[0]; y = args[1]
  130. w = args[2]; h = args[3]
  131. s = args[4]
  132. a = (args[5].nil? ? 0 : args[5])
  133. c = (args[6].nil? ? Font.default_color : args[6])
  134. end
  135. font.shadow = false
  136. font.color = Color.new(0,0,0)
  137. draw_text(x-1, y-1, w, h, s, a)
  138. draw_text(x+1, y-1, w, h, s, a)
  139. draw_text(x-1, y+1, w, h, s, a)
  140. draw_text(x+1, y+1, w, h, s, a)
  141. font.color = c
  142. draw_text(x, y, w, h, s, a)
  143. end
  144.  
  145. end
  146.  
  147. #------------------------------------------------------------------------------
  148. # Game Interpreter
  149. #------------------------------------------------------------------------------
  150. class Game_Interpreter
  151.  
  152. def selfswitch(event_id, switch, status)
  153. key = [$game_map.map_id, event_id, switch]
  154. if status == nil
  155. $game_self_switches[key] = !$game_self_switches[key]
  156. else
  157. $game_self_switches[key] = status
  158. end
  159. $game_map.need_refresh = true
  160. end
  161.  
  162. end
  163.  
  164. #------------------------------------------------------------------------------
  165. # High Priority
  166. #------------------------------------------------------------------------------
  167. Win32API.new("kernel32", "SetPriorityClass", "pi", "i").call(-1, 0x80)
RAW Paste Data