Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ==============================================================================
- # Vampyr Kernel 1.4
- #==============================================================================
- # This module is necessary to activate and enhance compatibility of all Vampyr's Scripts
- #------------------------------------------------------------------------------
- module Vampyr_Kernel
- @scripts = {}
- @warnings = {}
- Print_Errors = false
- def self.register(script, version, date)
- @scripts[script] = [version, date]
- end
- def self.enabled?(script, version=nil)
- if @scripts.has_key?(script)
- if version.nil?
- return true
- elsif @scripts[script][0] >= version
- return true
- else
- if @warnings[script].nil? and Print_Errors
- print "'#{script}' is obsolete.\r\nSome functions won't work correctly"
- @warnings[script] = ["is obsolete"]
- self.write_log
- end
- return false
- end
- else
- if $TEST and @warnings[script].nil? and Print_Errors
- print "Unable to find script '#{script}' or it is placed in wrong place.\r\nSome functions won't work correctly"
- @warnings[script] = ["Unable to find"]
- self.write_log
- end
- return false
- end
- end
- def self.show_scripts(alert=true)
- list = "Vampyr Scripts [#{@scripts.size}]:\r\n\r\n"
- @scripts.each { |key, value| list += "#{key.gsub("Vampyr ", "")} #{value[0]} #{value[1]}\r\n" }
- list += "\r\nWarnings:\r\n" if @warnings != {}
- @warnings.each { |key, value| list += "#{key} #{value}\r\n" }
- return print list if alert
- return list
- end
- def self.write_log
- file = File.new("Vampyr_Log-#{Time.now.strftime("%m_%d_%Y")}.txt", "wb")
- file.write(self.show_scripts(false))
- file.close
- end
- def self.selfswitch(event_id, switch, status)
- key = [$game_map.map_id, event_id, switch]
- if status == nil
- $game_self_switches[key] = !$game_self_switches[key]
- else
- $game_self_switches[key] = status
- end
- $game_map.need_refresh = true
- end
- end
- #------------------------------------------------------------------------------
- # Object
- #------------------------------------------------------------------------------
- class Object
- def to_b
- return true if self == "true"
- return true if self.to_i > 0
- return false
- end
- def number?
- return true unless self.scan(/\d/).empty?
- return false
- end
- def transform
- return self.to_i if self.number?
- return self.to_s
- end
- def get_width
- b = Bitmap.new(1, 1)
- w = a.text_size(self.to_s).width
- b.dispose
- return w
- end
- def to_rgb
- x = self.delete("#").scan(/../).map { |i| i.to_i(16) }
- return Color.new(x[0].to_f, x[1].to_f, x[2].to_f)
- end
- end
- #------------------------------------------------------------------------------
- # Sprite
- #------------------------------------------------------------------------------
- class Sprite
- def draw_icon(icon, x, y)
- return if self.bitmap == nil
- rect = Rect.new(icon%16*24, icon/16*24, 24, 24)
- self.bitmap.blt(x, y, Cache.system("Iconset"), rect)
- end
- end
- #------------------------------------------------------------------------------
- # Bitmap
- #------------------------------------------------------------------------------
- class Bitmap
- def draw_outlined_text(*args)
- if args[0].is_a?(Rect)
- x = args[0].x; y = args[0].y
- w = args[0].width; h = args[0].height
- s = args[1]
- a = (args[2].nil? ? 0 : args[2])
- c = (args[3].nil? ? Font.default_color : args[3])
- else
- x = args[0]; y = args[1]
- w = args[2]; h = args[3]
- s = args[4]
- a = (args[5].nil? ? 0 : args[5])
- c = (args[6].nil? ? Font.default_color : args[6])
- end
- font.shadow = false
- font.color = Color.new(0,0,0)
- draw_text(x-1, y-1, w, h, s, a)
- draw_text(x+1, y-1, w, h, s, a)
- draw_text(x-1, y+1, w, h, s, a)
- draw_text(x+1, y+1, w, h, s, a)
- font.color = c
- draw_text(x, y, w, h, s, a)
- end
- end
- #------------------------------------------------------------------------------
- # Game Interpreter
- #------------------------------------------------------------------------------
- class Game_Interpreter
- def selfswitch(event_id, switch, status)
- key = [$game_map.map_id, event_id, switch]
- if status == nil
- $game_self_switches[key] = !$game_self_switches[key]
- else
- $game_self_switches[key] = status
- end
- $game_map.need_refresh = true
- end
- end
- #------------------------------------------------------------------------------
- # High Priority
- #------------------------------------------------------------------------------
- Win32API.new("kernel32", "SetPriorityClass", "pi", "i").call(-1, 0x80)
RAW Paste Data