khanhdu

CSCA Encyclopedia

Jun 3rd, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 56.66 KB | None | 0 0
  1. =begin
  2. CSCA Encyclopedia
  3. version: 3.0.3 (Released: March 7, 2013)
  4. Created by: Casper Gaming (http://www.caspergaming.com/)
  5.  
  6. Compatibility:
  7. Made for RPGVXAce
  8. IMPORTANT: ALL CSCA Scripts should be compatible with each other unless
  9. otherwise noted.
  10. REQUIRES CSCA Core Script v1.0.5 or greater.
  11. ================================================================================
  12. UPDATES:
  13. version 1.1(April 14, 2012):
  14. - Added ability to set enemy/item/etc. to discovered through script call.
  15. - Bestiary MaxHP and MaxMP listed at top of parameters now instead of bottom.
  16. - Ability to restrict which items, armors, weapons, and enemies are shown to
  17. the player based on their ID(you can restrict which ID the list goes up to)
  18.  
  19. version 1.2(April 29, 2012):
  20. - No more max items listed. If you want to leave an item/enemy/etc. unlisted now,
  21. use the notetag <csca enc exclude>.
  22.  
  23. version 2.0(June 17, 2012):
  24. - Resized the windows to display more info on each item.
  25. - Added skills and states to the encyclopedia.
  26. - All commands(bestiary, items, etc.) are now able to be disabled.
  27. - Changed colors of some text.
  28. - Fixed bug with item occasion of Never.
  29. - Made code more efficient.
  30.  
  31. version 2.0b(June 17, 2012)
  32. - Removed add to menu option. Use the CSCA Menu Organizer for that instead.
  33.  
  34. version 2.1(July 12, 2012)
  35. - Added option to use a custom image for skills/items/etc. instead of just using
  36. the blown up icon for said skill/item/etc. Size of image is 72x72.
  37. - Added ability to change x coordinate of stat amounts.
  38. - Added ability to customize order encyclopedia lists are shown.
  39.  
  40. version 2.2(August 13, 2012)
  41. - Windows now resize properly with different resolutions.
  42.  
  43. version 2.2b(September 5, 2012)
  44. - Optimized script.
  45. - Added ability to set amount of a certain enemy defeated.
  46.  
  47. version 2.2c(September 11, 2012)
  48. - Param text now displays at the correct x coordinate automatically.
  49.  
  50. version 3.0(October 6, 2012)
  51. - Divided the totals window into 2 separate windows, one shows total completion %,
  52. the other shows category completion %.
  53. - Added support for CSCA Achievement System.
  54. - Users can now create their own custom categories.
  55.  
  56. version 3.0.1(October 14, 2012)
  57. - Added ability to re-order custom categories and default categories.
  58.  
  59. version 3.0.2(October 21, 2012)
  60. - Added ability to change descriptions of custom entries
  61.  
  62. version 3.0.3(March 7, 2013)
  63. - Compatibility patch for CSCA Currency System
  64. - Removed some duplicate code (now in Core Script)
  65. ================================================================================
  66. FFEATURES:
  67. This script creates an encyclopedia, with the option to insert it into the
  68. default main menu. The encyclopedia contains a seperate list for items, armors,
  69. weapons, and monsters(called bestiary).
  70.  
  71. BESTIARY: Shows enemy sprite(centered), name, currency gain, exp gain,
  72. 3 drop items, number of that enemy defeated, enemy parameters, location found,
  73. and custom note.
  74.  
  75. ITEMS: Shows sprite (stretched bigger), item name, key item status, price,
  76. HP Effect, MP Effect, TP Gain, success rate, occasion(menu/battle/none/both),
  77. state applications and removals, number in possession, and custom note.
  78.  
  79. WEAPONS: Shows sprite (stretched bigger), weapon name, price, type, parameters,
  80. speed bonus, state applications, attack element, number in possession, and
  81. custom note.
  82.  
  83. ARMORS: Shows sprite (stretched bigger), armor name, slot, price, type,
  84. parameters, state resists, and special effects(such as 2x gold), number in
  85. possession, and custom note.
  86.  
  87. SKILLS: Shows sprite(stretched bigger), skill name, tp and mp cost, element,
  88. damage type, state application and removal, scope, occasion, price(req. csca
  89. skill shop), critical, variance, and custom note.
  90.  
  91. STATES: Shows sprite(stretched bigger), state name, priority, restriction,
  92. removal types, chance of removal, max turns affected, min turns affected, and
  93. custom note.
  94.  
  95. SETUP
  96. This script requires setup further down.
  97. Instructions included below.
  98.  
  99. IMPORTANT:
  100. If using this script with an existing save file, you'll need to make the
  101. following script call: $game_party.csca_init_encyclopedia
  102.  
  103. Note: If you are updating an existing version of this script, that script
  104. call will revert everything back to undiscovered.
  105.  
  106. CREDIT:
  107. Free to use in noncommercial games if credit is given to:
  108. Casper Gaming (http://www.caspergaming.com/)
  109.  
  110. To use in a commercial game, please purchase a license here:
  111. http://www.caspergaming.com/licenses.html
  112.  
  113. TERMS:
  114. http://www.caspergaming.com/terms_of_use.html
  115. =end
  116. module CSCA_ENCYCLOPEDIA # Don't touch this.
  117.  
  118.   ####################
  119.   # NOTETAG COMMANDS #
  120.   ####################
  121.   # If you have an item/whatever you don't want to be listed, put this notetag
  122.   # code in the item/whatever's notebox: <csca enc exclude>
  123.   #
  124.   # To write a short note about anything, put this notetag code in the
  125.   # item/enemy/state/etc. notebox: <cscanote: Your Text Here>
  126.   #
  127.   # To fill in an enemy's location info, put this notetag code in the enemy's
  128.   # notebox: <cscafound: Your Text Here>
  129.   #
  130.   # To use a custom picture(size will be resized to 72x72 pixels) for the
  131.   # picture shown for an item/skill/weapon/armor/state, put this notetag in the
  132.   # item/skill/etc.'s notebox: <cscapic: picturename> (Do not include extension,
  133.   # .png is assumed. Other formats will not work.)
  134.   ################
  135.   # SCRIPT CALLS #
  136.   ################
  137.   # The following script calls allow you to set certain items to discovered.
  138.   #
  139.   # $game_party.csca_set_enemy_true(enemy_id)
  140.   # $game_party.csca_set_item_true(item_id)
  141.   # $game_party.csca_set_weapon_true(weapon_id)
  142.   # $game_party.csca_set_armor_true(armor_id)
  143.   # $game_party.csca_set_skill_true(skill_id)
  144.   # $game_party.csca_set_state_true(state_id)
  145.   # $game_party.csca_set_custom_true(custom_id)
  146.   #
  147.   #
  148.   # To change the amount of a certain enemy defeated, make script call:
  149.   #
  150.   # $game_party.csca_add_defeated(enemy_id,amount)
  151.   #
  152.   #
  153.   # To change descriptions for custom entries, use the following script call:
  154.   #
  155.   # $game_party.csca_change_desc(id, description)
  156.   # Where id is the ID of the description youw ant to change, and description is
  157.   # a new description array.
  158. #===============================================================================
  159.   # Main Script Options
  160.  
  161.   # This controls which commands will show, the order, and the text shown.
  162.   # DO NOT edit the first property(eg. :bestiary or :item).
  163.   COMMANDS = [ # Do not touch.
  164.  #[:symbol,   "Text", enabled?] (don't change default category symbols)
  165.   [:bestiary, "Quái Thú", true], # Re-order these any way you want.
  166.   [:town1,    "NPC'S"   , true], # Example for adding custom category
  167.   [:item,     "Vật Phẩm"   , true], # Re-order these any way you want.
  168.   [:weapon,   "Vũ Khí" , true], # Re-order these any way you want.
  169.   [:armor,    "Trang Bị"  , true], # Re-order these any way you want.
  170.   [:story,    "Câu Truyện"   , true], # Example for adding custom category
  171.   [:skill,    "Kĩ Năng"  , true], # Re-order these any way you want.
  172.   [:state,    "Trạng Thái"  , true], # Re-order these any way you want.
  173.   ] # Do not touch.
  174.  
  175.   ACTOR_ONLY = true # True means states will only be discovered when an actor
  176.                     # is inflicted with them. False means either actors or
  177.                     # enemies being inflicted will discover a state.
  178.  
  179.   TRIGGER = :C # Button used to toggle bestiary monster sprite and information.
  180.  
  181.   MONSTER_OPACITY = 75 # Opacity of the monster sprite while toggled off.
  182.   # Range of valid numbers is 0 - 255, 0 being transparent.
  183. #===============================================================================
  184.   # Vocab. The following are text that appear in the windows.
  185.  
  186.   HEADER = "Bách Khoa" # Name window displayed at top during scene.
  187.  
  188.   UNKNOWN = "Chưa Xuất Hiện" # Text to be displayed if item/monster/etc. is undiscovered.
  189.  
  190.   # Description for items/skills/weapons/armors/enemies not yet discovered.
  191.   UNKNOWN_DESCR = "Mục %s Chưa Chạm Mặt \nhay khám phá." # \n = new line
  192.  
  193.   # Text shown instructing players how to toggle opacity of the monster sprites.
  194.   TRIGGER_TEXT = "Nhấn nút Tác vụ để bật các Từ Điển."
  195.  
  196.   # This text shows after skill scopes that target dead allies. The default term
  197.   # "Dead" may be too harsh for some games so this is changeable here.
  198.   DEAD_TEXT = "(Đã Chết)"
  199. #===============================================================================
  200.   # Colors. These numbers correspond to the index of the color squares in
  201.   # the windowskin.
  202.  
  203.   GOOD_COLOR = 3 # Color for positive effects
  204.   BAD_COLOR  = 2 # Color for negative effects
  205. #===============================================================================
  206.   # Custom Category Settings - for advanced users only.
  207.   # With these options, you can create your own custom categories and define
  208.   # what each list contains, what each object displays, etc.
  209.  
  210.   CUSTOM = [] # Do not touch.
  211.   KEYS = [] # Do not touch.
  212.   DESCRIPTION = [] # Do not touch.
  213.  
  214.   # Description text shown in the information window of custom categories.
  215.   #DESCRIPTION[x] = [x,["Descriptive Text","Seperate lines with commas!"]]
  216.   # the first value before the text lines is the ID of the description.
  217.   # For example, DESCRIPTION[2838] = [2838,["text","here"]]
  218.   DESCRIPTION[0] = [0,["This citizen lives in","Example Town."]]
  219.   DESCRIPTION[1] = [1,["This citizen also lives","in Example Town"]]
  220.   DESCRIPTION[2] = [2,["This is the prologue of the game"]]
  221.  
  222.   # KEYS[x] = [Name, image path, description array, key, id, custom text 1,
  223.   # custom text 2]
  224.   # image path is relative to the main project folder. Set to nil if not using.
  225.   # the key determines which custom category this object will be shown in, it
  226.   # MUST match one of the custom categories' keys.
  227.   # id is the ID of the array, KEYS[0] has id of 0, KEYS[1] has id of 1, etc.
  228.   # custom texts are short strings shown next to the image at the top, if not
  229.   # using set to ""
  230.   #
  231.   # Comment out or Delete these if not using!
  232.   KEYS[0] = ["Citizen 1","Graphics/Encyclopedia/Test.png",DESCRIPTION[0],
  233.   :town1,0,"Location: Test Town","Name: Citizen 1"]
  234.  
  235.   KEYS[1] = ["Citizen 2","Graphics/Encyclopedia/Test.png",DESCRIPTION[1],
  236.   :town1,1,"Location: Test Town","Name: Citizen 2"]
  237.  
  238.   KEYS[2] = ["Prologue",nil,DESCRIPTION[2],:story,2,"",""]
  239.  
  240.   # CUSTOM[x] = [Category Name, key, text for unknown description]
  241.   # The key determines which KEYS will be shown in each category; their keys
  242.   # MUST match!
  243.   #
  244.   # Comment out or Delete these if not using!
  245.   CUSTOM[0] = ["NPC's",:town1,"NPC"]
  246.   CUSTOM[1] = ["Story",:story,"information"]
  247. #===============================================================================
  248. end # END SETUP #
  249. $imported = {} if $imported.nil?
  250. $imported["CSCA-Encyclopedia"] = true
  251. msgbox('Missing Script: CSCA Core Script! CSCA Encyclopedia requires this
  252. script to work properly.') if !$imported["CSCA-Core"]
  253. class Scene_CSCA_Encyclopedia < Scene_MenuBase
  254.  
  255.   def start
  256.     super
  257.     create_head_window
  258.     create_command_window
  259.     create_dummy_window
  260.     create_csca_info_window
  261.     create_specific_total_window
  262.     create_csca_list_window
  263.     create_total_window
  264.   end
  265.  
  266.   def create_background
  267.     super
  268.     @background_sprite.tone.set(0, 0, 0, 128)
  269.   end
  270.  
  271.   def create_command_window
  272.     @command_window = CSCA_Window_EncyclopediaMainSelect.new(0, @head_window.height)
  273.     @command_window.viewport = @viewport
  274.     @command_window.set_handler(:ok,     method(:on_category_ok))
  275.     @command_window.set_handler(:cancel, method(:return_scene))
  276.   end
  277.  
  278.   def create_head_window
  279.     @head_window = CSCA_Window_Header.new(0, 0, CSCA_ENCYCLOPEDIA::HEADER)
  280.     @head_window.viewport = @viewport
  281.   end
  282.  
  283.   def create_dummy_window
  284.     wx = (Graphics.width / 2) - 40
  285.     wy = @command_window.y + @command_window.height
  286.     wh = Graphics.height - wy
  287.     @dummy_window = Window_Base.new(wx, wy, Graphics.width - wx, wh)
  288.     @dummy_window.viewport = @viewport
  289.   end
  290.  
  291.   def create_specific_total_window
  292.     wy = @csca_info_window.height
  293.     wh = @head_window.height
  294.     wl = @dummy_window.width - 80
  295.     @specific_total_window = CSCA_Window_EncyclopediaSpecificTotal.new(0, wy, wl, wh)
  296.     @specific_total_window.viewport = @viewport
  297.     @command_window.csca_specific_total_window = @specific_total_window
  298.   end
  299.  
  300.   def create_total_window
  301.     wy = @csca_list_window.y + @csca_list_window.height + @specific_total_window.height
  302.     wh = @head_window.height
  303.     wl = @csca_list_window.width
  304.     @total_window = CSCA_Window_EncyclopediaTotal.new(0, wy, wl, wh)
  305.     @total_window.viewport = @viewport
  306.   end
  307.  
  308.   def create_csca_list_window
  309.     height = @dummy_window.height - (@command_window.height * 2)
  310.     width = @dummy_window.width - 80
  311.     wy = @dummy_window.y
  312.     @csca_list_window = CSCA_Window_ItemList.new(0, wy, width, height)
  313.     @csca_list_window.viewport = @viewport
  314.     @csca_list_window.help_window = @csca_info_window
  315.     @csca_list_window.set_handler(:cancel, method(:on_list_cancel))
  316.     @command_window.csca_list_window = @csca_list_window
  317.   end
  318.  
  319.   def create_csca_info_window
  320.     wy = @command_window.y + @command_window.height
  321.     wh = Graphics.height - wy
  322.     @csca_info_window = CSCA_Window_EncyclopediaInfo.new(@dummy_window.x, wy, @dummy_window.width, wh)
  323.     @csca_info_window.viewport = @viewport
  324.     @csca_info_window.hide
  325.   end
  326.  
  327.   def on_category_ok
  328.     @csca_list_window.activate
  329.     @csca_list_window.select(0)
  330.     @dummy_window.hide
  331.     @csca_info_window.show
  332.   end
  333.  
  334.   def on_list_cancel
  335.     @csca_list_window.unselect
  336.     @command_window.activate
  337.     @csca_info_window.hide
  338.     @dummy_window.show
  339.   end
  340.  
  341. end
  342. class CSCA_Window_EncyclopediaTotal < Window_Base
  343.  
  344.   def initialize(x, y, width, height)
  345.     super(x, y, width, height)
  346.     refresh
  347.   end
  348.  
  349.   def refresh
  350.     contents.clear
  351.     draw_text(0,0,contents.width,line_height,sprintf("Toàn Bộ: %1.2f%% Hoàn Thành",$game_party.csca_completion_percentage*100.00))
  352.   end
  353. end
  354. class CSCA_Window_EncyclopediaSpecificTotal < Window_Base
  355.  
  356.   def initialize(x, y, width, height)
  357.     super(x, y, width, height)
  358.     @category = :none
  359.   end
  360.  
  361.   def category=(category)
  362.     return if @category == category
  363.     @category = category
  364.     refresh
  365.   end
  366.  
  367.   def refresh
  368.     contents.clear
  369.     case @category
  370.     when :bestiary
  371.       draw_text(0,0,contents.width,line_height,sprintf("%s: %1.2f%% Hoàn Thành",
  372.         $game_party.csca_category_text(:bestiary), $game_party.csca_completion_percentage_bestiary*100.00))
  373.     when :item
  374.       draw_text(0,0,contents.width,line_height,sprintf("%s: %1.2f%% Hoàn Thành",
  375.         $game_party.csca_category_text(:item), $game_party.csca_completion_percentage_items*100.00))
  376.     when :weapon
  377.       draw_text(0,0,contents.width,line_height,sprintf("%s: %1.2f%% Hoàn Thành",
  378.         $game_party.csca_category_text(:weapon), $game_party.csca_completion_percentage_weapons*100.00))
  379.     when :armor
  380.       draw_text(0,0,contents.width,line_height,sprintf("%s: %1.2f%% Hoàn Thành",
  381.         $game_party.csca_category_text(:armor), $game_party.csca_completion_percentage_armors*100.00))
  382.     when :skill
  383.       draw_text(0,0,contents.width,line_height,sprintf("%s: %1.2f%% Hoàn Thành",
  384.         $game_party.csca_category_text(:skill), $game_party.csca_completion_percentage_skills*100.00))
  385.     when :state
  386.       draw_text(0,0,contents.width,line_height,sprintf("%s: %1.2f%% Hoàn Thành",
  387.         $game_party.csca_category_text(:state), $game_party.csca_completion_percentage_states*100.00))
  388.     else
  389.       draw_text(0,0,contents.width,line_height,sprintf("%s: %1.2f%% Hoàn Thành",
  390.         $game_party.csca_custom_text(@category), $game_party.csca_completion_percentage_cust(@category)*100.00))
  391.     end
  392.   end
  393.  
  394. end
  395. class CSCA_Window_EncyclopediaInfo < Window_Base
  396.   def initialize(x, y, width, height)
  397.     super(x, y, width, height)
  398.   end
  399.  
  400.   def set_text(text)
  401.     @text = text
  402.     draw_unknown_text
  403.   end
  404.  
  405.   def clear
  406.     set_text("")
  407.   end
  408.  
  409.   def set_item(item, sprite_in_front = 0)
  410.     contents.clear
  411.     contents.font.size = 24
  412.     if $game_party.encyclopedia_discovered(item)
  413.       if item.is_a?(RPG::Item)
  414.         draw_item_information(item)
  415.       elsif item.is_a?(RPG::Weapon)
  416.         draw_weapon_information(item)
  417.       elsif item.is_a?(RPG::Armor)
  418.         draw_armor_information(item)
  419.       elsif item.is_a?(RPG::State)
  420.         draw_state_information(item)
  421.       elsif item.is_a?(RPG::Skill)
  422.         draw_skill_information(item)
  423.       elsif item.is_a?(RPG::Enemy)
  424.         if sprite_in_front == 1
  425.           csca_draw_enemy_sprite(item)
  426.           csca_draw_toggle_tutorial
  427.         else
  428.           draw_enemy_information(item)
  429.         end
  430.       else
  431.         draw_custom_information(item) if !item.nil?
  432.       end
  433.     else
  434.       if item.is_a?(RPG::Item)
  435.         item_type = "item"
  436.       elsif item.is_a?(RPG::Weapon)
  437.         item_type = "weapon"
  438.       elsif item.is_a?(RPG::Armor)
  439.         item_type = "armor"
  440.       elsif item.is_a?(RPG::Enemy)
  441.         item_type = "enemy"
  442.       elsif item.is_a?(RPG::State)
  443.         item_type = "state"
  444.       elsif item.is_a?(RPG::Skill)
  445.         item_type = "skill"
  446.       else
  447.         if !item.nil?
  448.           for i in 0...CSCA_ENCYCLOPEDIA::CUSTOM.size
  449.             if CSCA_ENCYCLOPEDIA::CUSTOM[i][1] == item[3]
  450.               item_type = CSCA_ENCYCLOPEDIA::CUSTOM[i][2]
  451.               break
  452.             end
  453.           end
  454.         end
  455.       end
  456.       set_text(item ? sprintf(CSCA_ENCYCLOPEDIA::UNKNOWN_DESCR, item_type) : "")
  457.     end
  458.   end
  459.  
  460.   def draw_unknown_text
  461.     draw_text_ex(4, 0, @text)
  462.   end
  463.  
  464.   def draw_item_information(item)
  465.     csca_draw_icon(item)
  466.     csca_draw_name(item)
  467.     contents.font.size = 20
  468.     csca_draw_price(item)
  469.     item.key_item? ? key_item = "Yes" : key_item = "No"
  470.     draw_text(150,line_height,contents.width,line_height,key_item)
  471.     change_color(system_color)
  472.     draw_text(72,line_height,contents.width,line_height, "Key item:")
  473.     draw_text(0,line_height*3,contents.width,line_height,"HP Effect:")
  474.     draw_text(0,line_height*4-4,contents.width,line_height,"MP Effect:")
  475.     draw_text(0,line_height*5-8,contents.width,line_height,"TP gain:")
  476.     draw_text(0,line_height*6-12,contents.width,line_height,"Applies:")
  477.     draw_text(0,line_height*7-10,contents.width,line_height,"Removes:")
  478.     draw_text(0,line_height*8-10,contents.width,line_height,"Occasion:")
  479.     draw_text(0,line_height*9-14,contents.width,line_height,"Success Rate:")
  480.     change_color(normal_color)
  481.     occasion = ""
  482.     case item.occasion
  483.     when 0; occasion = "Always"
  484.     when 1; occasion = "Battle Only"
  485.     when 2; occasion = "Menu only"
  486.     when 3; occasion = "Never"
  487.     end
  488.     draw_text(78,line_height*8-10,contents.width,line_height,occasion)
  489.     draw_text(110,line_height*9-14,contents.width,line_height,item.success_rate.to_s + "%")
  490.     cscatpgain = 0
  491.     for effect in item.effects
  492.       next unless effect.code == 13
  493.       cscatpgain += (effect.value1 * 100).to_i
  494.     end
  495.     cscatpgain += item.tp_gain
  496.     cscatpgain = 100 if cscatpgain > 100
  497.     change_color(text_color(CSCA_ENCYCLOPEDIA::GOOD_COLOR)) if cscatpgain > 0
  498.     cscatpgain > 0 ? string = "+" : string = ""
  499.     draw_text(70,line_height*5-8,contents.width,line_height,sprintf(string +
  500.     "%d%%", cscatpgain))
  501.     change_color(normal_color)
  502.     csca_draw_value(11, 85,line_height*3, item) # 11 = HP
  503.     csca_draw_value(12, 85,line_height*4-4, item) # 12 = MP
  504.     csca_draw_states(0,item)
  505.     csca_draw_states(1,item)
  506.     csca_draw_possession(0,line_height*10-16,contents.width,line_height,item)
  507.     csca_draw_custom_note(0,line_height*11-20,contents.width,line_height,item)
  508.   end
  509.  
  510.   def draw_weapon_information(item)
  511.     csca_draw_icon(item)
  512.     csca_draw_name(item)
  513.     contents.font.size = 20
  514.     csca_draw_type(item,120,line_height,contents.width-120,line_height)
  515.     csca_draw_price(item)
  516.     csca_draw_all_params(item)
  517.     change_color(system_color)
  518.     draw_text(72,line_height,contents.width,line_height,"Type:")
  519.     draw_text(0,line_height*7-16,contents.width,line_height,"Element:")
  520.     draw_text(0,line_height*8-20,contents.width,line_height,"Speed:")
  521.     draw_text(0,line_height*9-20,contents.width,line_height,"Applies:")
  522.     change_color(normal_color)
  523.     csca_draw_type(item,70,line_height*7-16,contents.width-70,line_height,1)
  524.     csca_draw_wpn_speed(item)
  525.     csca_draw_states(3,item)
  526.     csca_draw_possession(0,line_height*10-16,contents.width,line_height,item)
  527.     csca_draw_custom_note(0,line_height*11-20,contents.width,line_height,item)
  528.   end
  529.  
  530.   def draw_armor_information(item)
  531.     csca_draw_icon(item)
  532.     csca_draw_name(item)
  533.     contents.font.size = 20
  534.     csca_draw_price(item)
  535.     case item.etype_id
  536.     when 1; type = "Shield"
  537.     when 2; type = "Head"
  538.     when 3; type = "Body"
  539.     when 4; type = "Accessory"
  540.     end
  541.     draw_text(165,line_height,contents.width,line_height,type)
  542.     csca_draw_all_params(item)
  543.     change_color(system_color)
  544.     draw_text(72,line_height,contents.width,line_height,"Armor Slot:")
  545.     draw_text(0,line_height*7-12,contents.width,line_height,"Resists:")
  546.     draw_text(0,line_height*8-12,contents.width,line_height,"Armor Type:")
  547.     draw_text(0,line_height*9-16,contents.width,line_height,"Special:")
  548.     change_color(normal_color)
  549.     csca_draw_states(2,item)
  550.     csca_draw_type(item,95,line_height*8-12,contents.width-100,line_height)
  551.     string = "None"
  552.     for feature in item.features
  553.       string = feature.data_id if feature.code == 64
  554.     end
  555.     case string
  556.     when 0; string = "50% Encounter Rate"
  557.     when 1; string = "0% Encounter Rate"
  558.     when 2; string = "0% Surprise Rate"
  559.     when 3; string = "Raise Preemptive Rate"
  560.     when 4; string = "200% Gold Drop Rate"
  561.     when 5; string = "200% Item Drop Rate"
  562.     end
  563.     draw_text(70,line_height*9-16,contents.width,line_height,string)
  564.     csca_draw_possession(0,line_height*10-16,contents.width,line_height,item)
  565.     csca_draw_custom_note(0,line_height*11-20,contents.width,line_height,item)
  566.   end
  567.  
  568.   def draw_state_information(item)
  569.     csca_draw_icon(item)
  570.     csca_draw_name(item)
  571.     contents.font.size = 20
  572.     change_color(system_color)
  573.     draw_text(72,line_height,contents.width,line_height,"Restriction:")
  574.     draw_text(72,line_height*2-4,contents.width,line_height,"Priority:")
  575.     draw_text(0,line_height*3,contents.width,line_height,"Minimum Turns:")
  576.     draw_text(0,line_height*4-4,contents.width,line_height,"Maximum Turns:")
  577.     draw_text(0,line_height*5-8,contents.width,line_height,"Remove After Battle:")
  578.     draw_text(0,line_height*6-12,contents.width,line_height,"Remove By Restriction:")
  579.     draw_text(0,line_height*7-16,contents.width,line_height,"Remove By Damage:")
  580.     draw_text(0,line_height*8-20,contents.width,line_height,"Chance On Damage:")
  581.     draw_text(0,line_height*8,contents.width,line_height,"Remove By Walking:")
  582.     draw_text(0,line_height*9-4,contents.width,line_height,"Steps To Remove:")
  583.     change_color(normal_color)
  584.     restriction_string = item.restriction
  585.     case restriction_string
  586.     when 0; restriction_string = "None"
  587.     when 1; restriction_string = "Attack Enemies"
  588.     when 2; restriction_string = "Attack Anyone"
  589.     when 3; restriction_string = "Attack Allies"
  590.     when 4; restriction_string = "Can't Move"
  591.     end
  592.     if item.auto_removal_timing != 1 && item.auto_removal_timing != 2
  593.       max_turn = "N/A"
  594.       min_turn = "N/A"
  595.     else
  596.       max_turn = item.max_turns.to_s
  597.       min_turn = item.min_turns.to_s
  598.     end
  599.     item.remove_at_battle_end ? b_remove = "Yes" : b_remove = "No"
  600.     item.remove_by_restriction ? r_remove = "Yes" : r_remove = "No"
  601.     if item.remove_by_damage
  602.       d_remove = "Yes"
  603.       d_chance = item.chance_by_damage.to_s + "%"
  604.     else
  605.       d_remove = "No"
  606.       d_chance = "N/A"
  607.     end
  608.     if item.remove_by_walking
  609.       w_remove = "Yes"
  610.       w_steps = item.steps_to_remove.to_s
  611.     else
  612.       w_remove = "No"
  613.       w_steps = "N/A"
  614.     end
  615.     draw_text(170,line_height,contents.width,line_height,restriction_string)
  616.     draw_text(147,line_height*2-4,contents.width,line_height,item.priority.to_s)
  617.     draw_text(115,line_height*3,contents.width,line_height,min_turn)
  618.     draw_text(115,line_height*4-4,contents.width,line_height,max_turn)
  619.     draw_text(165,line_height*5-8,contents.width,line_height,b_remove)
  620.     draw_text(180,line_height*6-12,contents.width,line_height,r_remove)
  621.     draw_text(140,line_height*7-16,contents.width,line_height,d_remove)
  622.     draw_text(140,line_height*8-20,contents.width,line_height,d_chance)
  623.     draw_text(150,line_height*8,contents.width,line_height,w_remove)
  624.     draw_text(135,line_height*9-4,contents.width,line_height,w_steps)
  625.     csca_draw_custom_note(0,line_height*11-12,contents.width,line_height,item)
  626.   end
  627.  
  628.   def draw_skill_information(item)
  629.     csca_draw_icon(item)
  630.     csca_draw_name(item)
  631.     contents.font.size = 20
  632.     change_color(system_color)
  633.     draw_text(0,line_height*9-16,contents.width,line_height,"Element:")
  634.     draw_text(72,line_height,contents.width,line_height,"MP Cost:")
  635.     draw_text(72,line_height*2-4,contents.width,line_height,"TP Cost:")
  636.     draw_text(0,line_height*3-4,contents.width,line_height,"Type:")
  637.     draw_text(0,line_height*4-8,contents.width,line_height,"Damage:")
  638.     draw_text(0,line_height*5-12,contents.width,line_height,"Critical:")
  639.     draw_text(0,line_height*6-12,contents.width,line_height,"Applies:")
  640.     draw_text(0,line_height*7-12,contents.width,line_height,"Removes:")
  641.     draw_text(0,line_height*8-12,contents.width,line_height,"Variance:")
  642.     draw_text(0,line_height*10-20,contents.width,line_height,"Scope:")
  643.     $imported["CSCA-SkillShop"] ?
  644.     draw_text(0,line_height*10,contents.width,line_height,"Price:") :
  645.     draw_text(0,line_height*10,contents.width,line_height,"Occasion:")
  646.     change_color(normal_color)
  647.     damage_string = item.damage.type
  648.     scope_string = item.scope
  649.     occasion_string = item.occasion
  650.     case damage_string
  651.     when 0; damage_string = "None"
  652.     when 1; damage_string = "HP Damage"
  653.     when 2; damage_string = "MP Damage"
  654.     when 3; damage_string = "HP Recovery"
  655.     when 4; damage_string = "MP Recovery"
  656.     when 5; damage_string = "HP Drain"
  657.     when 6; damage_string = "MP Drain"
  658.     end
  659.     case scope_string
  660.     when 0; scope_string = "None"
  661.     when 1; scope_string = "One Enemy"
  662.     when 2; scope_string = "All Enemies"
  663.     when 3; scope_string = "One Random Enemy"
  664.     when 4; scope_string = "Two Random Enemies"
  665.     when 5; scope_string = "Three Random Enemies"
  666.     when 6; scope_string = "Four Random Enemies"
  667.     when 7; scope_string = "One Ally"
  668.     when 8; scope_string = "All Allies"
  669.     when 9; scope_string = "One Ally " + CSCA_ENCYCLOPEDIA::DEAD_TEXT
  670.     when 10; scope_string = "All Allies " + CSCA_ENCYCLOPEDIA::DEAD_TEXT
  671.     when 11; scope_string = "The user"
  672.     end
  673.     case occasion_string
  674.     when 0; occasion_string = "Always"
  675.     when 1; occasion_string = "Battle Only"
  676.     when 2; occasion_string = "Menu only"
  677.     when 3; occasion_string = "Never"
  678.     end
  679.     item.damage.critical ? critical = "Yes" : critical = "No"
  680.     draw_text(140,line_height,contents.width,line_height,item.mp_cost.to_s)
  681.     draw_text(140,line_height*2-4,contents.width,line_height,item.tp_cost.to_s)
  682.     csca_draw_type(item,47,line_height*3-4,contents.width-70,line_height)
  683.     csca_draw_type(item,70,line_height*9-16,contents.width-70,line_height,1)
  684.     draw_text(65,line_height*4-8,contents.width,line_height,damage_string)
  685.     draw_text(75,line_height*5-12,contents.width,line_height,critical)
  686.     draw_text(75,line_height*8-12,contents.width,line_height,item.damage.variance.to_s + "%")
  687.     csca_draw_states(0,item)
  688.     csca_draw_states(1,item)
  689.     draw_text(55,line_height*10-20,contents.width,line_height,scope_string)
  690.     $imported["CSCA-SkillShop"] ?
  691.     draw_text(55,line_height*10,contents.width,line_height,item.skill_price.to_s + Vocab::currency_unit) :
  692.     draw_text(78,line_height*10,contents.width,line_height,occasion_string)
  693.     csca_draw_custom_note(0,line_height*11-4,contents.width,line_height,item)
  694.   end
  695.  
  696.   def draw_enemy_information(item)
  697.     csca_draw_enemy_sprite(item, CSCA_ENCYCLOPEDIA::MONSTER_OPACITY)
  698.     csca_draw_name(item, 1)
  699.     contents.font.size = 20
  700.     csca_draw_enemy_rewards(item, 0, line_height)
  701.     csca_draw_enemy_rewards(item, 1, line_height*2-4)
  702.     csca_draw_all_params(item, 1)
  703.     draw_text(88,line_height*6,contents.width,line_height,"1.")
  704.     draw_text(88,line_height*7-4,contents.width,line_height,"2.")
  705.     draw_text(88,line_height*8-8,contents.width,line_height,"3.")
  706.     csca_draw_enemy_treasures(item)
  707.     change_color(system_color)
  708.     draw_text(0,line_height*6,contents.width,line_height,"Treasures:")
  709.     draw_text(0,line_height*9-12,contents.width,line_height,"Number Defeated:")
  710.     draw_text(0,line_height*10-16,contents.width,line_height,"Found:")
  711.     change_color(normal_color)
  712.     string = $game_party.csca_enemies_defeated(item).to_s
  713.     draw_text(130,line_height*9-12,contents.width,line_height," "+string)
  714.     draw_text(45,line_height*10-16,contents.width,line_height," "+item.csca_locations)
  715.     csca_draw_custom_note(0,line_height*11-20,contents.width,line_height,item)
  716.     csca_draw_toggle_tutorial
  717.   end
  718.  
  719.   def draw_custom_information(item)
  720.     item[1].nil? ? x = 0 : x = 72
  721.     contents.font.bold = true
  722.     draw_text(x,0,contents.width-72,line_height,item[0])
  723.     contents.font.bold = false
  724.     unless item[1].nil?
  725.       bitmap = Bitmap.new(item[1])
  726.       target = Rect.new(0,0,72,72)
  727.       contents.stretch_blt(target, bitmap, bitmap.rect, 255)
  728.     end
  729.     contents.font.size = 20
  730.     y = line_height
  731.     draw_text(x,y,contents.width-72,line_height,item[5])
  732.     item[5] != "" ? y += line_height : y += 0
  733.     draw_text(x,y,contents.width-72,line_height,item[6])
  734.     item[6] != "" ? y += line_height-4 : y += 0
  735.     description = $game_party.csca_descriptions[item[2][0]]
  736.     for i in 0...description[1].size
  737.       draw_text(0,y,contents.width,line_height,description[1][i])
  738.       y += line_height-4
  739.     end
  740.   end
  741.  
  742.   def csca_draw_possession(x,y,width,height,item)
  743.     change_color(system_color)
  744.     draw_text(x,y,width,height,"Possession:")
  745.     change_color(normal_color)
  746.     draw_text(x+95,y,width,height,$game_party.item_number(item).to_s)
  747.   end
  748.  
  749.   def csca_draw_custom_note(x,y,width,height,item)
  750.     change_color(system_color)
  751.     draw_text(x,y,width,height,"Note:")
  752.     change_color(normal_color)
  753.     draw_text(x+40,y,width,height," "+item.csca_custom_note)
  754.   end
  755.  
  756.   def csca_draw_toggle_tutorial
  757.     contents.font.size = 16
  758.     draw_text(0,line_height*12-12,contents.width,line_height,CSCA_ENCYCLOPEDIA::TRIGGER_TEXT,1)
  759.   end
  760.  
  761.   def csca_draw_enemy_sprite(item, opacity = 255)
  762.     bitmap = Cache.battler(item.battler_name, item.battler_hue)
  763.     x = (contents.width / 2) - (bitmap.width / 2)
  764.     y = (contents.height / 2) - (bitmap.height / 2)
  765.     if bitmap.width > contents.width && bitmap.height > contents.height
  766.       target = Rect.new(0, 0, contents.width, contents.height)
  767.     elsif bitmap.width > contents.width
  768.       target = Rect.new(0, y, contents.width, bitmap.height)
  769.     elsif bitmap.height > contents.height
  770.       target = Rect.new(x, 0, bitmap.width, contents.height)
  771.     else
  772.       target = Rect.new(x,y,bitmap.width,bitmap.height)
  773.     end
  774.     contents.stretch_blt(target, bitmap, bitmap.rect, opacity)
  775.   end
  776.  
  777.   def csca_draw_enemy_treasures(enemy)
  778.     drop1 = "Nothing"
  779.     drop2 = "Nothing"
  780.     drop3 = "Nothing"
  781.     items = []
  782.     for item in enemy.drop_items
  783.       if items[0].nil?
  784.         items[0] = item
  785.         next
  786.       end
  787.       if items[1].nil?
  788.         items[1] = item
  789.         next
  790.       end
  791.       items[2] = item
  792.     end
  793.     case items[0].kind
  794.     when 1; drop1 = $data_items[items[0].data_id].name
  795.     when 2; drop1 = $data_weapons[items[0].data_id].name
  796.     when 3; drop1 = $data_armors[items[0].data_id].name
  797.     end
  798.     case items[1].kind
  799.     when 1; drop2 = $data_items[items[1].data_id].name
  800.     when 2; drop2 = $data_weapons[items[1].data_id].name
  801.     when 3; drop2 = $data_armors[items[1].data_id].name
  802.     end
  803.     case items[2].kind
  804.     when 1; drop3 = $data_items[items[2].data_id].name
  805.     when 2; drop3 = $data_weapons[items[2].data_id].name
  806.     when 3; drop3 = $data_armors[items[2].data_id].name
  807.     end
  808.     draw_text(105,line_height*6,contents.width-96,line_height,drop1)
  809.     draw_text(105,line_height*7-4,contents.width-96,line_height,drop2)
  810.     draw_text(105,line_height*8-8,contents.width-96,line_height,drop3)
  811.   end
  812.  
  813.   def csca_draw_enemy_rewards(item, type, y)
  814.     if type == 0
  815.       currency = $game_party.get_csca_cs_currency(item.currency_symbol) if $imported["CSCA-CurrencySystem"]
  816.       reward = item.gold
  817.       string1 = "Currency: "
  818.       string2 = $imported["CSCA-CurrencySystem"] ? currency[:currency_unit] : Vocab::currency_unit
  819.       x = 78
  820.     else
  821.       reward = item.exp
  822.       string1 = "Experience: "
  823.       string2 = ""
  824.       x = 95
  825.     end
  826.     change_color(system_color)
  827.     draw_text(0,y,contents.width,line_height,string1)
  828.     change_color(type == 0 && $imported["CSCA-CurrencySystem"] ? currency[:color] : normal_color)
  829.     number = $csca.split_number(reward)
  830.     if number[0] >= 1
  831.       draw_text(x,y,contents.width,line_height,sprintf("%d,%03d,%03d"+string2,number[0],number[1],number[2]))
  832.     elsif number[0] == 0 && number[1] >= 1
  833.       draw_text(x,y,contents.width,line_height,sprintf("%d,%03d"+string2,number[1],number[2]))
  834.     else
  835.       draw_text(x,y,contents.width,line_height,sprintf("%d"+string2,number[2]))
  836.     end
  837.     change_color(normal_color)
  838.   end
  839.  
  840.   def csca_draw_icon(item)
  841.     if item.csca_custom_picture == ""
  842.       icon_index = item.icon_index
  843.       bitmap = Cache.system("Iconset")
  844.       rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  845.       target = Rect.new(0,0,72,72)
  846.       contents.stretch_blt(target, bitmap, rect)
  847.     else
  848.       bitmap = Bitmap.new("Graphics/Pictures/"+item.csca_custom_picture+".png")
  849.       target = Rect.new(0,0,72,72)
  850.       contents.stretch_blt(target, bitmap, bitmap.rect, 255)
  851.     end
  852.   end
  853.  
  854.   def csca_draw_name(item, center = 0)
  855.     contents.font.bold = true
  856.     center != 0 ? draw_text(0,0,contents.width,line_height,item.name,center) :
  857.       draw_text(72,0,contents.width-72,line_height,item.name)
  858.     contents.font.bold = false
  859.   end
  860.  
  861.   def csca_draw_price(item)
  862.     number = $csca.split_number(item.price)
  863.     currency = $game_party.get_csca_cs_currency(item.currency_symbol) if $imported["CSCA-CurrencySystem"]
  864.     unit = $imported["CSCA-CurrencySystem"] ? currency[:currency_unit] : Vocab::currency_unit
  865.     change_color(system_color)
  866.     draw_text(72,line_height*2-4,contents.width,line_height,"Price:")
  867.     change_color(item.price > 0 && $imported["CSCA-CurrencySystem"] ? currency[:color] : normal_color)
  868.     if number[0] >= 1
  869.       draw_text(125,line_height*2-4,contents.width,line_height,sprintf("%d,%03d,%03d" + unit, number[0], number[1], number[2]))
  870.     elsif number[0] == 0 && number[1] >= 1
  871.       draw_text(125,line_height*2-4,contents.width,line_height,sprintf("%d,%03d" + unit, number[1], number[2]))
  872.     elsif number[0] == 0 && number[1] == 0 && number[2] >= 1
  873.       draw_text(125,line_height*2-4,contents.width,line_height,sprintf("%d" + unit, number[2]))
  874.     else
  875.       draw_text(125,line_height*2-4,contents.width,line_height,"N/A")
  876.     end
  877.     change_color(normal_color)
  878.   end
  879.  
  880.   def csca_draw_all_params(item, type = 0)
  881.     w = contents.width/2
  882.     if type == 0
  883.       y1 = line_height*3
  884.       y2 = line_height*4-4
  885.       y3 = line_height*5-8
  886.       y4 = line_height*6-12
  887.     else
  888.       y4 = line_height*3-8
  889.       y1 = line_height*4-12
  890.       y2 = line_height*5-16
  891.       y3 = line_height*6-20
  892.     end
  893.     change_color(system_color)
  894.     param_0 = Vocab::param(0)+": "
  895.     param_1 = Vocab::param(1)+": "
  896.     param_2 = Vocab::param(2)+": "
  897.     param_3 = Vocab::param(3)+": "
  898.     param_4 = Vocab::param(4)+": "
  899.     param_5 = Vocab::param(5)+": "
  900.     param_6 = Vocab::param(6)+": "
  901.     param_7 = Vocab::param(7)+": "
  902.     draw_text(0,y1,contents.width,line_height,param_2)
  903.     draw_text(w,y1,contents.width,line_height,param_3)
  904.     draw_text(0,y2,contents.width,line_height,param_4)
  905.     draw_text(w,y2,contents.width,line_height,param_5)
  906.     draw_text(0,y3,contents.width,line_height,param_6)
  907.     draw_text(w,y3,contents.width,line_height,param_7)
  908.     draw_text(0,y4,contents.width,line_height,param_0)
  909.     draw_text(w,y4,contents.width,line_height,param_1)
  910.     change_color(normal_color)
  911.     csca_draw_param(2,item,text_size(param_2).width,y1)
  912.     csca_draw_param(3,item,w+text_size(param_3).width,y1)
  913.     csca_draw_param(4,item,text_size(param_4).width,y2)
  914.     csca_draw_param(5,item,w+text_size(param_5).width,y2)
  915.     csca_draw_param(6,item,text_size(param_6).width,y3)
  916.     csca_draw_param(7,item,w+text_size(param_7).width,y3)
  917.     csca_draw_param(0,item,text_size(param_0).width,y4)
  918.     csca_draw_param(1,item,w+text_size(param_1).width,y4)
  919.   end
  920.  
  921.   def csca_draw_param(param_id, item, x, y)
  922.     parameter = item.params[param_id]
  923.     string = ""
  924.     if parameter > 0
  925.       unless item.is_a?(RPG::Enemy)
  926.         change_color(text_color(CSCA_ENCYCLOPEDIA::GOOD_COLOR))
  927.         string = "+"
  928.       end
  929.     elsif parameter < 0
  930.       change_color(text_color(CSCA_ENCYCLOPEDIA::BAD_COLOR))
  931.       string = ""
  932.     else
  933.       change_color(normal_color)
  934.       string = ""
  935.     end
  936.     string += parameter.to_s
  937.     draw_text(x,y,contents.width,line_height,string)
  938.     change_color(normal_color)
  939.   end
  940.  
  941.   def csca_draw_type(item,x,y,w,h,elm = 0)
  942.     if item.is_a?(RPG::Armor)
  943.       csca_array = $data_system.armor_types
  944.       item.atype_id == 0 ? string = "None" : string = csca_array[item.atype_id]
  945.     elsif item.is_a?(RPG::Weapon)
  946.       case elm
  947.       when 0
  948.         csca_array = $data_system.weapon_types
  949.         item.wtype_id == 0 ? string = "None" : string = csca_array[item.wtype_id]
  950.       when 1
  951.         csca_array = $data_system.elements
  952.         string = "None"
  953.         for feature in item.features
  954.           case feature.code
  955.           when 31
  956.             feature.data_id == 0 ? string = "None" : string = csca_array[feature.data_id]
  957.           end
  958.         end
  959.       end
  960.     elsif item.is_a?(RPG::Skill)
  961.       case elm
  962.       when 0
  963.         csca_array = $data_system.skill_types
  964.         item.stype_id == 0 ? string = "None" : string = csca_array[item.stype_id]
  965.       when 1
  966.         csca_array = $data_system.elements
  967.         item.damage.element_id < 0 ? string = "Normal Attack" :
  968.         item.damage.element_id == 0 ? string = "None" : string = csca_array[item.damage.element_id]
  969.       end
  970.     end
  971.     draw_text(x,y,w,h,string)
  972.   end
  973.  
  974.   def csca_draw_wpn_speed(item)
  975.     speed = 0
  976.     for feature in item.features
  977.       case feature.code
  978.       when 33
  979.         speed += feature.value.to_i
  980.       end
  981.     end
  982.     if speed > 0
  983.       change_color(text_color(CSCA_ENCYCLOPEDIA::GOOD_COLOR))
  984.       string = "+"
  985.     elsif speed < 0
  986.       change_color(text_color(CSCA_ENCYCLOPEDIA::BAD_COLOR))
  987.       string = ""
  988.     else
  989.       change_color(normal_color)
  990.       string = ""
  991.     end
  992.     draw_text(50,line_height*8-20,contents.width,line_height,string + speed.to_s)
  993.     change_color(normal_color)
  994.   end
  995.  
  996.   def csca_draw_value(code,x,y,item)
  997.     p = 0
  998.     c = 0
  999.     string = ""
  1000.     for effect in item.effects
  1001.       next unless effect.code == code
  1002.       p = (effect.value1 * 100).to_i
  1003.       c += effect.value2.to_i
  1004.     end
  1005.     c *= item.repeats
  1006.     if c != 0
  1007.       if c > 0
  1008.         change_color(text_color(CSCA_ENCYCLOPEDIA::GOOD_COLOR))
  1009.         string = "+"
  1010.       else
  1011.         change_color(text_color(CSCA_ENCYCLOPEDIA::BAD_COLOR))
  1012.         string = ""
  1013.       end
  1014.       draw_text(x,y,contents.width,line_height,sprintf(string+"%d", c))
  1015.     elsif p != 0
  1016.       if p > 0
  1017.         change_color(text_color(CSCA_ENCYCLOPEDIA::GOOD_COLOR))
  1018.         string = "+"
  1019.       else
  1020.         change_color(text_color(CSCA_ENCYCLOPEDIA::BAD_COLOR))
  1021.         string = ""
  1022.       end
  1023.       draw_text(x,y,contents.width,line_height,sprintf(string+"%d%%", p))
  1024.     else
  1025.       draw_text(x,y,contents.width,line_height,"0")
  1026.     end
  1027.     change_color(normal_color)
  1028.   end
  1029.  
  1030.   def csca_draw_states(applies,item)
  1031.     icons = []
  1032.     if item.is_a?(RPG::Item) || item.is_a?(RPG::Skill)
  1033.       for effect in item.effects
  1034.         if applies == 0
  1035.           case effect.code
  1036.           when 21
  1037.             next unless effect.value1 > 0
  1038.             next if $data_states[effect.value1].nil?
  1039.             next if effect.data_id == 0
  1040.             icons.push($data_states[effect.data_id].icon_index)
  1041.           end
  1042.           icons.delete(0)
  1043.           break if icons.size >= 9
  1044.         else
  1045.           case effect.code
  1046.           when 22
  1047.             next unless effect.value1 > 0
  1048.             next if $data_states[effect.value1].nil?
  1049.             next if effect.data_id == 0
  1050.             icons.push($data_states[effect.data_id].icon_index)
  1051.           end
  1052.           icons.delete(0)
  1053.           break if icons.size >= 9
  1054.         end
  1055.       end
  1056.     elsif item.is_a?(RPG::Armor)
  1057.       for feature in item.features
  1058.         icons.push($data_states[feature.data_id].icon_index) if feature.code == 14
  1059.         icons.delete(0)
  1060.         break if icons.size >= 9
  1061.       end
  1062.     else
  1063.       for feature in item.features
  1064.         icons.push($data_states[feature.data_id].icon_index) if feature.code == 32
  1065.         icons.delete(0)
  1066.         break if icons.size >= 9
  1067.       end
  1068.     end
  1069.     case applies
  1070.     when 0; y = line_height*6-12
  1071.     when 1; y = line_height*7-10
  1072.     when 2; y = line_height*7-12
  1073.     when 3; y = line_height*9-20
  1074.     end
  1075.     csca_draw_icons(70, y, contents.width, icons)
  1076.   end
  1077.  
  1078.   def csca_draw_icons(x, y, width, icons)
  1079.     for icon_id in icons
  1080.       draw_icon(icon_id, x, y)
  1081.       x += 24
  1082.     end
  1083.     if icons.size == 0
  1084.       draw_text(70,y,contents.width,line_height,"Nothing")
  1085.     end
  1086.   end
  1087.  
  1088. end
  1089. class CSCA_Window_EncyclopediaMainSelect < Window_HorzCommand
  1090.   attr_reader :csca_list_window
  1091.   attr_reader :csca_specific_total_window
  1092.  
  1093.   def initialize(x, y)
  1094.     super(x,y)
  1095.   end
  1096.  
  1097.   def update
  1098.     super
  1099.     @csca_list_window.category = current_symbol if @csca_list_window
  1100.     @csca_specific_total_window.category = current_symbol if @csca_specific_total_window
  1101.   end
  1102.  
  1103.   def make_command_list
  1104.     for i in 0...CSCA_ENCYCLOPEDIA::COMMANDS.size
  1105.       if CSCA_ENCYCLOPEDIA::COMMANDS[i][2]
  1106.         add_command(CSCA_ENCYCLOPEDIA::COMMANDS[i][1],CSCA_ENCYCLOPEDIA::COMMANDS[i][0])
  1107.       end
  1108.     end
  1109.   end
  1110.  
  1111.   def csca_list_window=(csca_list_window)
  1112.     @csca_list_window = csca_list_window
  1113.     update
  1114.   end
  1115.  
  1116.   def csca_specific_total_window=(csca_specific_total_window)
  1117.     @csca_specific_total_window = csca_specific_total_window
  1118.     update
  1119.   end
  1120.  
  1121.   def window_width
  1122.     return Graphics.width
  1123.   end
  1124.  
  1125. end
  1126. class CSCA_Window_ItemList < Window_Selectable
  1127.  
  1128.   def initialize(x, y, width, height)
  1129.     super
  1130.     @category = :none
  1131.     @data = []
  1132.     @csca_monster_in_front = false
  1133.   end
  1134.  
  1135.   def category=(category)
  1136.     return if @category == category
  1137.     @category = category
  1138.     refresh
  1139.     self.oy = 0
  1140.   end
  1141.  
  1142.   def item_max
  1143.     @data ? @data.size : 1
  1144.   end
  1145.  
  1146.   def item
  1147.     @data && index >= 0 ? @data[index] : nil
  1148.   end
  1149.  
  1150.   def include?(item)
  1151.     case @category
  1152.     when :bestiary
  1153.       item.is_a?(RPG::Enemy) && !item.csca_encyclopedia_exclude?
  1154.     when :item
  1155.       item.is_a?(RPG::Item) && !item.csca_encyclopedia_exclude?
  1156.     when :weapon
  1157.       item.is_a?(RPG::Weapon) && !item.csca_encyclopedia_exclude?
  1158.     when :armor
  1159.       item.is_a?(RPG::Armor) && !item.csca_encyclopedia_exclude?
  1160.     when :state
  1161.       item.is_a?(RPG::State) && !item.csca_encyclopedia_exclude?
  1162.     when :skill
  1163.       item.is_a?(RPG::Skill) && !item.csca_encyclopedia_exclude?
  1164.     else
  1165.       false
  1166.     end
  1167.   end
  1168.  
  1169.   def cust_include?(item)
  1170.     item[3] == @category
  1171.   end
  1172.    
  1173.   def make_item_list
  1174.     @data = $data_items.select {|item| include?(item)}
  1175.     @data += $data_weapons.select {|item| include?(item)}
  1176.     @data += $data_armors.select {|item| include?(item)}
  1177.     @data += $data_enemies.select {|item| include?(item)}
  1178.     @data += $data_skills.select {|item| include?(item)}
  1179.     @data += $data_states.select {|item| include?(item)}
  1180.     @data += CSCA_ENCYCLOPEDIA::KEYS.select {|item| cust_include?(item)}
  1181.     @data.push(nil) if include?(nil)
  1182.   end
  1183.  
  1184.   def draw_item(index)
  1185.     item = @data[index]
  1186.     if item
  1187.       rect = item_rect(index)
  1188.       draw_item_id(rect, index)
  1189.       if $game_party.encyclopedia_discovered(item)
  1190.         if item.is_a?(RPG::Enemy)
  1191.           draw_text(rect.x+40,rect.y,contents.width-40,line_height,item.name)
  1192.         elsif not_custom(item)
  1193.           draw_item_name(item, rect.x + 40, rect.y, true, contents.width - 60)
  1194.         else
  1195.           draw_text(rect.x+40,rect.y,contents.width-40,line_height,item[0])
  1196.         end
  1197.       else
  1198.         draw_unknown_text(rect)
  1199.       end
  1200.     end
  1201.   end
  1202.  
  1203.   def draw_item_id(rect, index)
  1204.     draw_text(rect, sprintf("%3d.", index + 1))
  1205.   end
  1206.  
  1207.   def draw_unknown_text(rect)
  1208.     draw_text(rect, sprintf("    %s", CSCA_ENCYCLOPEDIA::UNKNOWN))
  1209.   end
  1210.  
  1211.   def not_custom(item)
  1212.     item.is_a?(RPG::Item) || item.is_a?(RPG::Weapon) || item.is_a?(RPG::Armor) ||
  1213.     item.is_a?(RPG::Skill) || item.is_a?(RPG::State) || item.is_a?(RPG::Enemy)
  1214.   end
  1215.  
  1216.   def update_help
  1217.     if @category == :bestiary && @csca_monster_in_front == true
  1218.       @help_window.set_item(item, 1)
  1219.     else
  1220.       @help_window.set_item(item, 0)
  1221.     end
  1222.   end
  1223.  
  1224.   def refresh
  1225.     refresh_button_input
  1226.     make_item_list
  1227.     create_contents
  1228.     draw_all_items
  1229.   end
  1230.  
  1231.   def update
  1232.     super
  1233.     refresh_button_input
  1234.   end
  1235.  
  1236.   def refresh_button_input
  1237.     if Input.trigger?(CSCA_ENCYCLOPEDIA::TRIGGER) && @csca_monster_in_front && @category == :bestiary
  1238.       @csca_monster_in_front = false
  1239.       Sound.play_ok
  1240.       update_help
  1241.     elsif Input.trigger?(CSCA_ENCYCLOPEDIA::TRIGGER) && !@csca_monster_in_front && @category == :bestiary
  1242.       @csca_monster_in_front = true
  1243.       Sound.play_ok
  1244.       update_help
  1245.     end
  1246.   end
  1247.  
  1248. end
  1249. class Game_Party < Game_Unit
  1250.   attr_reader :csca_enemies
  1251.   attr_reader :csca_items
  1252.   attr_reader :csca_weapons
  1253.   attr_reader :csca_armors
  1254.   attr_reader :csca_defeated_number
  1255.   attr_reader :csca_states
  1256.   attr_reader :csca_skills
  1257.   attr_reader :csca_custom_enc
  1258.   attr_reader :csca_descriptions
  1259.  
  1260.   alias csca_init_all_items init_all_items
  1261.   def init_all_items
  1262.     csca_init_all_items
  1263.     csca_init_encyclopedia
  1264.   end
  1265.  
  1266.   def csca_init_encyclopedia
  1267.     @csca_enemies = []
  1268.     @csca_items = []
  1269.     @csca_weapons = []
  1270.     @csca_armors = []
  1271.     @csca_defeated_number = []
  1272.     @csca_states = []
  1273.     @csca_skills = []
  1274.     @csca_custom_enc = []
  1275.     @csca_descriptions = []
  1276.     @enemy_number = 0
  1277.     for i in 0..$data_enemies.size
  1278.       @csca_enemies[i] = false
  1279.       @csca_defeated_number[i] = 0
  1280.     end
  1281.     for i in 0..$data_items.size
  1282.       @csca_items[i] = false
  1283.     end
  1284.     for i in 0..$data_weapons.size
  1285.       @csca_weapons[i] = false
  1286.     end
  1287.     for i in 0..$data_armors.size
  1288.       @csca_armors[i] = false
  1289.     end
  1290.     for i in 0..$data_skills.size
  1291.       @csca_skills[i] = false
  1292.     end
  1293.     for i in 0..$data_states.size
  1294.       @csca_states[i] = false
  1295.     end
  1296.     for i in 0...CSCA_ENCYCLOPEDIA::KEYS.size
  1297.       @csca_custom_enc[i] = false
  1298.     end
  1299.     for i in 0...CSCA_ENCYCLOPEDIA::DESCRIPTION.size
  1300.       @csca_descriptions[i] = CSCA_ENCYCLOPEDIA::DESCRIPTION[i]
  1301.     end
  1302.   end
  1303.  
  1304.   alias csca_gain_item gain_item
  1305.   def gain_item(item, amount, include_equip = false)
  1306.     csca_gain_item(item, amount)
  1307.     csca_set_discovered(item)
  1308.   end
  1309.  
  1310.   def csca_change_desc(id, description)
  1311.     @csca_descriptions[id] = [id,description]
  1312.   end
  1313.  
  1314.   def csca_set_discovered(item, discover = true)
  1315.     if item.is_a?(RPG::Item)
  1316.       @csca_items[item.id] = discover
  1317.     elsif item.is_a?(RPG::Weapon)
  1318.       @csca_weapons[item.id] = discover
  1319.     elsif item.is_a?(RPG::Armor)
  1320.       @csca_armors[item.id] = discover
  1321.     elsif item.is_a?(RPG::Enemy)
  1322.       @csca_enemies[item.id] = discover
  1323.     elsif item.is_a?(RPG::Skill)
  1324.       @csca_skills[item.id] = discover
  1325.     elsif item.is_a?(RPG::State)
  1326.       @csca_states[item.id] = discover
  1327.     elsif !item.nil?
  1328.       @csca_custom_enc[item] = discover
  1329.     end
  1330.   end
  1331.  
  1332.   def csca_set_defeated(enemy, number = 1)
  1333.     @csca_defeated_number[enemy.id] += number
  1334.   end
  1335.  
  1336.   def csca_enemies_defeated(enemy)
  1337.     @csca_defeated_number[enemy.id]
  1338.   end
  1339.  
  1340.   def encyclopedia_discovered(item)
  1341.     if item.is_a?(RPG::Item)
  1342.       @csca_items[item.id]
  1343.     elsif item.is_a?(RPG::Weapon)
  1344.       @csca_weapons[item.id]
  1345.     elsif item.is_a?(RPG::Armor)
  1346.       @csca_armors[item.id]
  1347.     elsif item.is_a?(RPG::Enemy)
  1348.       @csca_enemies[item.id]
  1349.     elsif item.is_a?(RPG::Skill)
  1350.       @csca_skills[item.id]
  1351.     elsif item.is_a?(RPG::State)
  1352.       @csca_states[item.id]
  1353.     else
  1354.       unless item.nil?
  1355.         @csca_custom_enc[item[4]]
  1356.       end
  1357.     end
  1358.   end
  1359.  
  1360.   def enemies_discovered
  1361.     number = 0
  1362.     for i in 0..@csca_enemies.size
  1363.       if @csca_enemies[i] == true && !$data_enemies[i].csca_encyclopedia_exclude?
  1364.         number += 1
  1365.       end
  1366.     end
  1367.     return number
  1368.   end
  1369.  
  1370.   def items_discovered
  1371.     number = 0
  1372.     for i in 0..@csca_items.size
  1373.       if @csca_items[i] == true && !$data_items[i].csca_encyclopedia_exclude?
  1374.         number += 1
  1375.       end
  1376.     end
  1377.     return number
  1378.   end
  1379.  
  1380.   def weapons_discovered
  1381.     number = 0
  1382.     for i in 0..@csca_weapons.size
  1383.       if @csca_weapons[i] == true && !$data_weapons[i].csca_encyclopedia_exclude?
  1384.         number += 1
  1385.       end
  1386.     end
  1387.     return number
  1388.   end
  1389.  
  1390.   def armors_discovered
  1391.     number = 0
  1392.     for i in 0..@csca_armors.size
  1393.       if @csca_armors[i] == true && !$data_armors[i].csca_encyclopedia_exclude?
  1394.         number += 1
  1395.       end
  1396.     end
  1397.     return number
  1398.   end
  1399.  
  1400.   def states_discovered
  1401.     number = 0
  1402.     for i in 0..@csca_states.size
  1403.       if @csca_states[i] == true && !$data_states[i].csca_encyclopedia_exclude?
  1404.         number += 1
  1405.       end
  1406.     end
  1407.     return number
  1408.   end
  1409.  
  1410.   def skills_discovered
  1411.     number = 0
  1412.     for i in 0..@csca_skills.size
  1413.       if @csca_skills[i] == true && !$data_skills[i].csca_encyclopedia_exclude?
  1414.         number += 1
  1415.       end
  1416.     end
  1417.     return number
  1418.   end
  1419.  
  1420.   def custom_enc_discovered(symbol)
  1421.     number = 0
  1422.     for i in 0..@csca_custom_enc.size
  1423.       if @csca_custom_enc[i] == true && CSCA_ENCYCLOPEDIA::KEYS[i][3] == symbol
  1424.         number += 1
  1425.       end
  1426.     end
  1427.     return number
  1428.   end
  1429.  
  1430.   def csca_set_enemy_true(enemy_id)
  1431.     csca_set_discovered($data_enemies[enemy_id])
  1432.   end
  1433.  
  1434.   def csca_set_item_true(item_id)
  1435.     csca_set_discovered($data_items[item_id])
  1436.   end
  1437.  
  1438.   def csca_set_armor_true(armor_id)
  1439.     csca_set_discovered($data_armors[armor_id])
  1440.   end
  1441.  
  1442.   def csca_set_weapon_true(weapon_id)
  1443.     csca_set_discovered($data_weapons[weapon_id])
  1444.   end
  1445.  
  1446.   def csca_set_state_true(state_id)
  1447.     csca_set_discovered($data_states[state_id])
  1448.   end
  1449.  
  1450.   def csca_set_skill_true(skill_id)
  1451.     csca_set_discovered($data_skills[skill_id])
  1452.   end
  1453.  
  1454.   def csca_set_custom_true(custom_id)
  1455.     csca_set_discovered(custom_id)
  1456.   end
  1457.  
  1458.   def csca_add_defeated(enemy_id,amount)
  1459.     csca_set_defeated($data_enemies[enemy_id],amount)
  1460.   end
  1461.  
  1462.   def csca_total_enemies
  1463.     total = 0
  1464.     for i in 0..$data_enemies.size
  1465.       if $data_enemies[i].is_a?(RPG::Enemy)
  1466.         total += 1 if !$data_enemies[i].csca_encyclopedia_exclude?
  1467.       end
  1468.     end
  1469.     return total
  1470.   end
  1471.  
  1472.   def csca_total_items
  1473.     total = 0
  1474.     for i in 0..$data_items.size
  1475.       if $data_items[i].is_a?(RPG::Item)
  1476.         total += 1 if !$data_items[i].csca_encyclopedia_exclude?
  1477.       end
  1478.     end
  1479.     return total
  1480.   end
  1481.  
  1482.   def csca_total_weapons
  1483.     total = 0
  1484.     for i in 0..$data_weapons.size
  1485.       if $data_weapons[i].is_a?(RPG::Weapon)
  1486.         total += 1 if !$data_weapons[i].csca_encyclopedia_exclude?
  1487.       end
  1488.     end
  1489.     return total
  1490.   end
  1491.  
  1492.   def csca_total_armors
  1493.     total = 0
  1494.     for i in 0..$data_armors.size
  1495.       if $data_armors[i].is_a?(RPG::Armor)
  1496.         total += 1 if !$data_armors[i].csca_encyclopedia_exclude?
  1497.       end
  1498.     end
  1499.     return total
  1500.   end
  1501.  
  1502.   def csca_total_skills
  1503.     total = 0
  1504.     for i in 0..$data_skills.size
  1505.       if $data_skills[i].is_a?(RPG::Skill)
  1506.         total += 1 if !$data_skills[i].csca_encyclopedia_exclude?
  1507.       end
  1508.     end
  1509.     return total
  1510.   end
  1511.  
  1512.   def csca_total_states
  1513.     total = 0
  1514.     for i in 0..$data_states.size
  1515.       if $data_states[i].is_a?(RPG::State)
  1516.         total += 1 if !$data_states[i].csca_encyclopedia_exclude?
  1517.       end
  1518.     end
  1519.     return total
  1520.   end
  1521.  
  1522.   def csca_total_custom_enc(symbol)
  1523.     total = 0
  1524.     for i in 0...CSCA_ENCYCLOPEDIA::KEYS.size
  1525.       total += 1 if CSCA_ENCYCLOPEDIA::KEYS[i][3] == symbol
  1526.     end
  1527.     return total
  1528.   end
  1529.  
  1530.   def csca_completion_percentage_bestiary
  1531.     csca_total_enemies == 0 ? 0 : (enemies_discovered.to_f/csca_total_enemies)
  1532.   end
  1533.  
  1534.   def csca_completion_percentage_items
  1535.     csca_total_items == 0 ? 0 : (items_discovered.to_f/csca_total_items)
  1536.   end
  1537.  
  1538.   def csca_completion_percentage_weapons
  1539.     csca_total_weapons == 0 ? 0 : (weapons_discovered.to_f/csca_total_weapons)
  1540.   end
  1541.  
  1542.   def csca_completion_percentage_armors
  1543.     csca_total_armors == 0 ? 0 : (armors_discovered.to_f/csca_total_armors)
  1544.   end
  1545.  
  1546.   def csca_completion_percentage_skills
  1547.     csca_total_skills == 0 ? 0 : (skills_discovered.to_f/csca_total_skills)
  1548.   end
  1549.  
  1550.   def csca_completion_percentage_states
  1551.     csca_total_states == 0 ? 0 : (states_discovered.to_f/csca_total_states)
  1552.   end
  1553.  
  1554.   def csca_completion_percentage_cust(symbol)
  1555.     total = csca_total_custom_enc(symbol)
  1556.     total == 0 ? 0 : (custom_enc_discovered(symbol).to_f/total)
  1557.   end
  1558.    
  1559.  
  1560.   def csca_completion_percentage
  1561.     total = 0
  1562.     total += csca_total_enemies if csca_command_enabled?(:bestiary)
  1563.     total += csca_total_items if csca_command_enabled?(:item)
  1564.     total += csca_total_weapons if csca_command_enabled?(:weapon)
  1565.     total += csca_total_armors if csca_command_enabled?(:armor)
  1566.     total += csca_total_skills if csca_command_enabled?(:skill)
  1567.     total += csca_total_states if csca_command_enabled?(:state)
  1568.     total += CSCA_ENCYCLOPEDIA::KEYS.size
  1569.     disc = 0
  1570.     disc += enemies_discovered if csca_command_enabled?(:bestiary)
  1571.     disc += items_discovered if csca_command_enabled?(:item)
  1572.     disc += weapons_discovered if csca_command_enabled?(:weapon)
  1573.     disc += armors_discovered if csca_command_enabled?(:armor)
  1574.     disc += skills_discovered if csca_command_enabled?(:skill)
  1575.     disc += states_discovered if csca_command_enabled?(:state)
  1576.     for i in 0...CSCA_ENCYCLOPEDIA::KEYS.size
  1577.       disc += 1 if @csca_custom_enc[i]
  1578.     end
  1579.     return disc.to_f/total
  1580.   end
  1581.  
  1582.   def csca_commands
  1583.     CSCA_ENCYCLOPEDIA::COMMANDS
  1584.   end
  1585.  
  1586.   def csca_command_enabled?(category)
  1587.     for i in 0..csca_commands.size
  1588.       next if csca_commands[i].nil?
  1589.       return true if csca_commands[i][0] == category && csca_commands[i][2]
  1590.     end
  1591.     return false
  1592.   end
  1593.  
  1594.   def csca_category_text(category)
  1595.     for i in 0..csca_commands.size
  1596.       return csca_commands[i][1] if csca_commands[i][0] == category
  1597.     end
  1598.     return ""
  1599.   end
  1600.  
  1601.   def csca_custom_text(symbol)
  1602.     for i in 0..CSCA_ENCYCLOPEDIA::CUSTOM.size
  1603.       if CSCA_ENCYCLOPEDIA::CUSTOM[i][1] == symbol
  1604.         return CSCA_ENCYCLOPEDIA::CUSTOM[i][0]
  1605.       end
  1606.     end
  1607.     return ""
  1608.   end
  1609.  
  1610. end
  1611. class Game_Enemy < Game_Battler
  1612.   alias csca_collapse perform_collapse_effect
  1613.   def perform_collapse_effect
  1614.     csca_collapse
  1615.     $game_party.csca_set_discovered(enemy)
  1616.     $game_party.csca_set_defeated(enemy)
  1617.   end
  1618. end
  1619. class Game_Actor < Game_Battler
  1620.   alias csca_enc_learn_skill learn_skill
  1621.   def learn_skill(skill_id)
  1622.     $game_party.csca_set_discovered($data_skills[skill_id]) unless skill_learn?($data_skills[skill_id])
  1623.     csca_enc_learn_skill(skill_id)
  1624.   end
  1625. end
  1626. class Game_Battler < Game_BattlerBase
  1627.   alias csca_enc_add_new_state add_new_state
  1628.   def add_new_state(state_id)
  1629.     $game_party.csca_set_discovered($data_states[state_id]) if csca_actor_check
  1630.     csca_enc_add_new_state(state_id)
  1631.   end
  1632.   def csca_actor_check
  1633.     return true if actor?
  1634.     return true if !actor? && !CSCA_ENCYCLOPEDIA::ACTOR_ONLY
  1635.     return false
  1636.   end
  1637. end
  1638. class RPG::BaseItem
  1639.   def csca_encyclopedia_exclude?
  1640.     @note =~ /<csca enc exclude>/i
  1641.   end
  1642.   def csca_custom_note
  1643.     @note =~ /<cscanote: (.*)>/i ? $1.to_s : ""
  1644.   end
  1645.   def csca_custom_picture
  1646.     @note =~ /<cscapic: (.*)>/i ? $1.to_s : ""
  1647.   end
  1648. end
  1649. class RPG::Enemy < RPG::BaseItem
  1650.   def csca_locations
  1651.     @note =~ /<cscafound: (.*)>/i ? $1.to_s : ""
  1652.   end
  1653. end
Advertisement
Add Comment
Please, Sign In to add comment