khanhdu

CSCA Core Script

May 31st, 2017
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 9.30 KB | None | 0 0
  1. =begin
  2. CSCA Core Script
  3. version: 1.0.7
  4. Created by: Casper Gaming (http://www.caspergaming.com/)
  5.  
  6. Scripts that REQUIRE this script to work:
  7. CSCA Colosseum
  8. CSCA Dungeon Tools
  9. CSCA Achievements
  10. CSCA Encyclopedia
  11. CSCA Treasure Maps
  12. CSCA Menu MOD
  13. CSCA SaveFile Plus
  14. CSCA Vehicle System
  15. CSCA Sidequests
  16. CSCA Professions
  17.  
  18. Version History:
  19. 1.0.1 - Adds CSCA_Item class, used by scripts to get information about an item.
  20. 1.0.2 - Adds CSCA_Fish class, used by Vehicle System to get fishing data.
  21. 1.0.3 - Adds Window_HorzCommand fix to allow unlimited horizontal commands.
  22. 1.0.4 - Adds CSCA_Core class, used for csca script data that needs to be saved.
  23. 1.0.5 - Adds shorter access to variables/switches in Event script command.
  24. 1.0.6 - Adds troubleshooting error/warning reports.
  25. 1.0.7 - Adds vowel detection for strings.
  26.  
  27. COMPATIBILITY
  28. PLACE THIS SCRIPT ABOVE ALL OTHER CSCA SCRIPTS!
  29. Compatible only for VXAce.
  30. IMPORTANT: ALL CSCA Scripts should be compatible with each other unless
  31. otherwise noted.
  32.  
  33. FFEATURES
  34. This script includes classes and functions used by other CSCA Scripts.
  35.  
  36. SETUP
  37. Plug n play. Make sure this script is ABOVE all other CSCA Scripts.
  38.  
  39. CREDIT:
  40. Free to use in noncommercial games if credit is given to:
  41. Casper Gaming (http://www.caspergaming.com/)
  42.  
  43. To use in a commercial game, please purchase a license here:
  44. http://www.caspergaming.com/licenses.html
  45.  
  46. TERMS:
  47. http://www.caspergaming.com/terms_of_use.html
  48. =end
  49. $imported = {} if $imported.nil?
  50. $imported["CSCA-Core"] = true
  51. #==============================================================================
  52. # ** DataManager
  53. #------------------------------------------------------------------------------
  54. # Handles csca class data.
  55. # Aliases: make_save_contents, create_game_objects, extract_save_contents
  56. #==============================================================================
  57. module DataManager
  58.   #--------------------------------------------------------------------------
  59.   # alias method
  60.   #--------------------------------------------------------------------------
  61.   class <<self; alias csca_core_create_game_objects create_game_objects; end
  62.   def self.create_game_objects
  63.     csca_core_create_game_objects
  64.     $csca = CSCA_Core.new
  65.   end
  66.   #--------------------------------------------------------------------------
  67.   # overwrite method
  68.   #--------------------------------------------------------------------------
  69.   class <<self; alias csca_core_save_contents make_save_contents; end
  70.   def self.make_save_contents
  71.     contents = csca_core_save_contents
  72.     contents[:csca] = $csca
  73.     contents
  74.   end
  75.   #--------------------------------------------------------------------------
  76.   # alias method
  77.   #--------------------------------------------------------------------------
  78.   class <<self; alias csca_core_extract_save_contents extract_save_contents; end
  79.   def self.extract_save_contents(contents)
  80.     csca_core_extract_save_contents(contents)
  81.     $csca = contents[:csca]
  82.   end
  83. end
  84. #==============================================================================
  85. # ** CSCA_Window_Header
  86. #------------------------------------------------------------------------------
  87. # This window displays the header window, used by many CSCA Scripts.
  88. #==============================================================================
  89. class CSCA_Window_Header < Window_Base
  90.   #--------------------------------------------------------------------------
  91.   # Object Initialization
  92.   #--------------------------------------------------------------------------
  93.   def initialize(x, y, width = Graphics.width, height = line_height*2, text)
  94.     super(x, y, width, height)
  95.     refresh(text)
  96.   end
  97.   #--------------------------------------------------------------------------
  98.   # Refresh
  99.   #--------------------------------------------------------------------------
  100.   def refresh(text)
  101.     contents.clear
  102.     draw_text(0, 0, contents.width, line_height, text, 1)
  103.   end
  104. end
  105. #==============================================================================
  106. # ** Game_Map
  107. #------------------------------------------------------------------------------
  108. # Easy csca access to the map's note.
  109. #==============================================================================
  110. class Game_Map
  111.   #--------------------------------------------------------------------------
  112.   # Get Map Note
  113.   #--------------------------------------------------------------------------
  114.   def csca_map_note; @map.note; end
  115. end
  116. #==============================================================================
  117. # ** Window_HorzCommand
  118. #------------------------------------------------------------------------------
  119. # Allow unlimited horizontal commands.
  120. # Overwrites: top_col=
  121. #==============================================================================
  122. class Window_HorzCommand < Window_Command
  123.   #--------------------------------------------------------------------------
  124.   # Overwrite Method
  125.   #--------------------------------------------------------------------------
  126.   def top_col=(col)
  127.     col = 0 if col < 0
  128.     self.ox = col * (item_width + spacing)
  129.   end
  130. end
  131. #==============================================================================
  132. # ** Game_Interpreter
  133. #------------------------------------------------------------------------------
  134. #  Shorter access to variables and switches.
  135. #==============================================================================
  136. class Game_Interpreter
  137.   #--------------------------------------------------------------------------
  138.   # Get variables
  139.   #--------------------------------------------------------------------------
  140.   def csca_v(var)
  141.     $game_variables[var]
  142.   end
  143.   #--------------------------------------------------------------------------
  144.   # Get switches
  145.   #--------------------------------------------------------------------------
  146.   def csca_s(swi)
  147.     $game_switches[swi]
  148.   end
  149. end
  150. #==============================================================================
  151. # ** CSCA_Item
  152. #------------------------------------------------------------------------------
  153. # CSCA Items, used as rewards/wagers in various scripts.
  154. #==============================================================================
  155. class CSCA_Item
  156.   attr_reader :id
  157.   attr_reader :amount
  158.   attr_reader :type
  159.   #--------------------------------------------------------------------------
  160.   # Initialize
  161.   #--------------------------------------------------------------------------
  162.   def initialize(amount,id,type)
  163.     @id = id
  164.     @amount = amount
  165.     @type = type
  166.   end
  167. end
  168. #==============================================================================
  169. # ** CSCA_Fish
  170. #------------------------------------------------------------------------------
  171. # CSCA Fish, used to specify data about fish.
  172. #==============================================================================
  173. class CSCA_Fish
  174.   attr_reader :item_id
  175.   attr_reader :water_type
  176.   attr_reader :weight
  177.   attr_reader :region
  178.   #--------------------------------------------------------------------------
  179.   # Initialize
  180.   #--------------------------------------------------------------------------
  181.   def initialize(id, water, weight, region = 0)
  182.     @item_id = id
  183.     @water_type = water
  184.     @weight = weight
  185.     @region = region
  186.   end
  187. end
  188. #==============================================================================
  189. # ** CSCA_Core
  190. #------------------------------------------------------------------------------
  191. # Used to provide global methods for csca scripts. Data is included in save.
  192. #==============================================================================
  193. class CSCA_Core
  194.   #--------------------------------------------------------------------------
  195.   # Initialize
  196.   #--------------------------------------------------------------------------
  197.   def initialize
  198.   end
  199.   #--------------------------------------------------------------------------
  200.   # Report wrong setup
  201.   #--------------------------------------------------------------------------
  202.   def report_error(error, script, suggestion, warning = false)
  203.     string1 = warning ? "Warning: " : "Error: "
  204.     msgbox(string1 + error + "\nOccurred in: " + script + "\nRecommended fix: " + suggestion)
  205.   end
  206.   #--------------------------------------------------------------------------
  207.   # Split number into millions, thousands, hundreds
  208.   #--------------------------------------------------------------------------
  209.   def split_number(start)
  210.     number = []
  211.     number[0] = start / 1000 / 1000
  212.     number[1] = start / 1000 % 1000
  213.     number[2] = start % 1000
  214.     return number
  215.   end
  216.   #--------------------------------------------------------------------------
  217.   # Split number into hours, minutes, seconds
  218.   #--------------------------------------------------------------------------
  219.   def split_playtime(start)
  220.     number = []
  221.     number[0] = start / 60 / 60
  222.     number[1] = start / 60 % 60
  223.     number[2] = start % 60
  224.     return number
  225.   end
  226.   #--------------------------------------------------------------------------
  227.   # Determine if letter is a vowel or not
  228.   #--------------------------------------------------------------------------
  229.   def is_a_vowel(letter, space = false)
  230.     letter.upcase
  231.     return letter == "A" || letter == "E" || letter == "I" || letter == "O" || letter == "U" || (letter == "X" && space == true)
  232.   end
  233. end
Advertisement
Add Comment
Please, Sign In to add comment