Advertisement
ForeverZer0

[RMXP] RPG Module

Jun 25th, 2011
438
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 46.32 KB | None | 0 0
  1. # Included Classes
  2. #   RPG::Actor
  3. #   RPG::Animation
  4. #   RPG::Animation::Frame
  5. #   RPG::Animation::Timing
  6. #   RPG::Armor
  7. #   RPG::AudioFile
  8. #   RPG::Cache
  9. #   RPG::Class
  10. #   RPG::Class::Learning
  11. #   RPG::CommonEvent
  12. #   RPG::Enemy
  13. #   RPG::Enemy::Action
  14. #   RPG::Event
  15. #   RPG::Event::Page
  16. #   RPG::Event::Page::Condition
  17. #   RPG::Event::Page::Graphic
  18. #   RPG::EventCommand
  19. #   RPG::Item
  20. #   RPG::Map
  21. #   RPG::MapInfo
  22. #   RPG::MoveCommand
  23. #   RPG::MoveRoute
  24. #   RPG::Skill
  25. #   RPG::Sprite
  26. #   RPG::State
  27. #   RPG::System
  28. #   RPG::System::TestBattler
  29. #   RPG::System::Words
  30. #   RPG::Tileset
  31. #   RPG::Troop
  32. #   RPG::Troop::Member
  33. #   RPG::Troop::Page
  34. #   RPG::Troop::Page::Condition
  35. #   RPG::Weapon
  36. #   RPG::Weather
  37.  
  38. module RPG
  39. #-------------------------------------------------------------------------------------
  40. # RPG::Actor
  41. #-------------------------------------------------------------------------------------
  42.   class Actor
  43.     attr_accessor :id
  44.     attr_accessor :name
  45.     attr_accessor :class_id
  46.     attr_accessor :initial_level
  47.     attr_accessor :final_level
  48.     attr_accessor :exp_basis
  49.     attr_accessor :exp_inflation
  50.     attr_accessor :character_name
  51.     attr_accessor :character_hue
  52.     attr_accessor :battler_name
  53.     attr_accessor :battler_hue
  54.     attr_accessor :parameters
  55.     attr_accessor :weapon_id
  56.     attr_accessor :armor1_id
  57.     attr_accessor :armor2_id
  58.     attr_accessor :armor3_id
  59.     attr_accessor :armor4_id
  60.     attr_accessor :weapon_fix
  61.     attr_accessor :armor1_fix
  62.     attr_accessor :armor2_fix
  63.     attr_accessor :armor3_fix
  64.     attr_accessor :armor4_fix
  65.     def initialize
  66.       @id = 0
  67.       @name = ""
  68.       @class_id = 1
  69.       @initial_level = 1
  70.       @final_level = 99
  71.       @exp_basis = 30
  72.       @exp_inflation = 30
  73.       @character_name = ""
  74.       @character_hue = 0
  75.       @battler_name = ""
  76.       @battler_hue = 0
  77.       @parameters = Table.new(6,100)
  78.       for i in 1..99
  79.         @parameters[0,i] = 500+i*50
  80.         @parameters[1,i] = 500+i*50
  81.         @parameters[2,i] = 50+i*5
  82.         @parameters[3,i] = 50+i*5
  83.         @parameters[4,i] = 50+i*5
  84.         @parameters[5,i] = 50+i*5
  85.       end
  86.       @weapon_id = 0
  87.       @armor1_id = 0
  88.       @armor2_id = 0
  89.       @armor3_id = 0
  90.       @armor4_id = 0
  91.       @weapon_fix = false
  92.       @armor1_fix = false
  93.       @armor2_fix = false
  94.       @armor3_fix = false
  95.       @armor4_fix = false
  96.     end
  97.   end
  98. #-------------------------------------------------------------------------------------
  99. # RPG::Animation
  100. #-------------------------------------------------------------------------------------
  101.   class Animation
  102.     attr_accessor :id
  103.     attr_accessor :name
  104.     attr_accessor :animation_name
  105.     attr_accessor :animation_hue
  106.     attr_accessor :position
  107.     attr_accessor :frame_max
  108.     attr_accessor :frames
  109.     attr_accessor :timings
  110.     def initialize
  111.       @id = 0
  112.       @name = ""
  113.       @animation_name = ""
  114.       @animation_hue = 0
  115.       @position = 1
  116.       @frame_max = 1
  117.       @frames = [RPG::Animation::Frame.new]
  118.       @timings = []
  119.     end
  120. #-------------------------------------------------------------------------------------
  121. # RPG::Animation::Frame
  122. #-------------------------------------------------------------------------------------
  123.     class Frame
  124.       attr_accessor :cell_max
  125.       attr_accessor :cell_data
  126.       def initialize
  127.         @cell_max = 0
  128.         @cell_data = Table.new(0, 0)
  129.       end
  130.     end
  131. #-------------------------------------------------------------------------------------
  132. # RPG::Animation::Timing
  133. #-------------------------------------------------------------------------------------
  134.     class Timing
  135.       attr_accessor :frame
  136.       attr_accessor :se
  137.       attr_accessor :flash_scope
  138.       attr_accessor :flash_color
  139.       attr_accessor :flash_duration
  140.       attr_accessor :condition
  141.       def initialize
  142.         @frame = 0
  143.         @se = RPG::AudioFile.new("", 80)
  144.         @flash_scope = 0
  145.         @flash_color = Color.new(255,255,255,255)
  146.         @flash_duration = 5
  147.         @condition = 0
  148.       end
  149.     end
  150.   end
  151. #-------------------------------------------------------------------------------------
  152. # RPG::Armor
  153. #-------------------------------------------------------------------------------------
  154.   class Armor
  155.     attr_accessor :id
  156.     attr_accessor :name
  157.     attr_accessor :icon_name
  158.     attr_accessor :description
  159.     attr_accessor :kind
  160.     attr_accessor :auto_state_id
  161.     attr_accessor :price
  162.     attr_accessor :pdef
  163.     attr_accessor :mdef
  164.     attr_accessor :eva
  165.     attr_accessor :str_plus
  166.     attr_accessor :dex_plus
  167.     attr_accessor :agi_plus
  168.     attr_accessor :int_plus
  169.     attr_accessor :guard_element_set
  170.     attr_accessor :guard_state_set
  171.     def initialize
  172.       @id = 0
  173.       @name = ""
  174.       @icon_name = ""
  175.       @description = ""
  176.       @kind = 0
  177.       @auto_state_id = 0
  178.       @price = 0
  179.       @pdef = 0
  180.       @mdef = 0
  181.       @eva = 0
  182.       @str_plus = 0
  183.       @dex_plus = 0
  184.       @agi_plus = 0
  185.       @int_plus = 0
  186.       @guard_element_set = []
  187.       @guard_state_set = []
  188.     end  
  189.   end
  190. #-------------------------------------------------------------------------------------
  191. # RPG::AudioFile
  192. #-------------------------------------------------------------------------------------
  193.   class AudioFile
  194.     attr_accessor :name
  195.     attr_accessor :volume
  196.     attr_accessor :pitch
  197.     def initialize(name = "", volume = 100, pitch = 100)
  198.       @name = name
  199.       @volume = volume
  200.       @pitch = pitch
  201.     end
  202.   end
  203. #-------------------------------------------------------------------------------------
  204. # RPG::Cache
  205. #-------------------------------------------------------------------------------------
  206.   module Cache
  207.     @cache = {}
  208.     def self.load_bitmap(folder_name, filename, hue = 0)
  209.       path = folder_name + filename
  210.       if not @cache.include?(path) or @cache[path].disposed?
  211.         if filename != ""
  212.           @cache[path] = Bitmap.new(path)
  213.         else
  214.           @cache[path] = Bitmap.new(32, 32)
  215.         end
  216.       end
  217.       if hue == 0
  218.         @cache[path]
  219.       else
  220.         key = [path, hue]
  221.         if not @cache.include?(key) or @cache[key].disposed?
  222.           @cache[key] = @cache[path].clone
  223.           @cache[key].hue_change(hue)
  224.         end
  225.         @cache[key]
  226.       end
  227.     end
  228.     def self.animation(filename, hue)
  229.       self.load_bitmap("Graphics/Animations/", filename, hue)
  230.     end
  231.     def self.autotile(filename)
  232.       self.load_bitmap("Graphics/Autotiles/", filename)
  233.     end
  234.     def self.battleback(filename)
  235.       self.load_bitmap("Graphics/Battlebacks/", filename)
  236.     end
  237.     def self.battler(filename, hue)
  238.       self.load_bitmap("Graphics/Battlers/", filename, hue)
  239.     end
  240.     def self.character(filename, hue)
  241.       self.load_bitmap("Graphics/Characters/", filename, hue)
  242.     end
  243.     def self.fog(filename, hue)
  244.       self.load_bitmap("Graphics/Fogs/", filename, hue)
  245.     end
  246.     def self.gameover(filename)
  247.       self.load_bitmap("Graphics/Gameovers/", filename)
  248.     end
  249.     def self.icon(filename)
  250.       self.load_bitmap("Graphics/Icons/", filename)
  251.     end
  252.     def self.panorama(filename, hue)
  253.       self.load_bitmap("Graphics/Panoramas/", filename, hue)
  254.     end
  255.     def self.picture(filename)
  256.       self.load_bitmap("Graphics/Pictures/", filename)
  257.     end
  258.     def self.tileset(filename)
  259.       self.load_bitmap("Graphics/Tilesets/", filename)
  260.     end
  261.     def self.title(filename)
  262.       self.load_bitmap("Graphics/Titles/", filename)
  263.     end
  264.     def self.windowskin(filename)
  265.       self.load_bitmap("Graphics/Windowskins/", filename)
  266.     end
  267.     def self.tile(filename, tile_id, hue)
  268.       key = [filename, tile_id, hue]
  269.       if not @cache.include?(key) or @cache[key].disposed?
  270.         @cache[key] = Bitmap.new(32, 32)
  271.         x = (tile_id - 384) % 8 * 32
  272.         y = (tile_id - 384) / 8 * 32
  273.         rect = Rect.new(x, y, 32, 32)
  274.         @cache[key].blt(0, 0, self.tileset(filename), rect)
  275.         @cache[key].hue_change(hue)
  276.       end
  277.       @cache[key]
  278.     end
  279.     def self.clear
  280.       @cache = {}
  281.       GC.start
  282.     end
  283.   end
  284. #-------------------------------------------------------------------------------------
  285. # RPG::Class
  286. #-------------------------------------------------------------------------------------
  287.   class Class
  288.     attr_accessor :id
  289.     attr_accessor :name
  290.     attr_accessor :position
  291.     attr_accessor :weapon_set
  292.     attr_accessor :armor_set
  293.     attr_accessor :element_ranks
  294.     attr_accessor :state_ranks
  295.     attr_accessor :learnings
  296.     def initialize
  297.       @id = 0
  298.       @name = ""
  299.       @position = 0
  300.       @weapon_set = []
  301.       @armor_set = []
  302.       @element_ranks = Table.new(1)
  303.       @state_ranks = Table.new(1)
  304.       @learnings = []
  305.     end
  306. #-------------------------------------------------------------------------------------
  307. # RPG::Class::Learning
  308. #-------------------------------------------------------------------------------------
  309.     class Learning
  310.       attr_accessor :level
  311.       attr_accessor :skill_id
  312.       def initialize
  313.         @level = 1
  314.         @skill_id = 1
  315.       end
  316.     end
  317.   end
  318. #-------------------------------------------------------------------------------------
  319. # RPG::CommonEvent
  320. #-------------------------------------------------------------------------------------
  321.   class CommonEvent
  322.     attr_accessor :id
  323.     attr_accessor :name
  324.     attr_accessor :trigger
  325.     attr_accessor :switch_id
  326.     attr_accessor :list
  327.     def initialize
  328.       @id = 0
  329.       @name = ""
  330.       @trigger = 0
  331.       @switch_id = 1
  332.       @list = [RPG::EventCommand.new]
  333.     end
  334.   end
  335. #-------------------------------------------------------------------------------------
  336. # RPG::Enemy
  337. #-------------------------------------------------------------------------------------
  338.   class Enemy
  339.     attr_accessor :id
  340.     attr_accessor :name
  341.     attr_accessor :battler_name
  342.     attr_accessor :battler_hue
  343.     attr_accessor :maxhp
  344.     attr_accessor :maxsp
  345.     attr_accessor :str
  346.     attr_accessor :dex
  347.     attr_accessor :agi
  348.     attr_accessor :int
  349.     attr_accessor :atk
  350.     attr_accessor :pdef
  351.     attr_accessor :mdef
  352.     attr_accessor :eva
  353.     attr_accessor :animation1_id
  354.     attr_accessor :animation2_id
  355.     attr_accessor :element_ranks
  356.     attr_accessor :state_ranks
  357.     attr_accessor :actions
  358.     attr_accessor :exp
  359.     attr_accessor :gold
  360.     attr_accessor :item_id
  361.     attr_accessor :weapon_id
  362.     attr_accessor :armor_id
  363.     attr_accessor :treasure_prob
  364.     def initialize
  365.       @id = 0
  366.       @name = ""
  367.       @battler_name = ""
  368.       @battler_hue = 0
  369.       @maxhp = 500
  370.       @maxsp = 500
  371.       @str = 50
  372.       @dex = 50
  373.       @agi = 50
  374.       @int = 50
  375.       @atk = 100
  376.       @pdef = 100
  377.       @mdef = 100
  378.       @eva = 0
  379.       @animation1_id = 0
  380.       @animation2_id = 0
  381.       @element_ranks = Table.new(1)
  382.       @state_ranks = Table.new(1)
  383.       @actions = [RPG::Enemy::Action.new]
  384.       @exp = 0
  385.       @gold = 0
  386.       @item_id = 0
  387.       @weapon_id = 0
  388.       @armor_id = 0
  389.       @treasure_prob = 100
  390.     end
  391. #-------------------------------------------------------------------------------------
  392. # RPG::Enemy::Action
  393. #-------------------------------------------------------------------------------------
  394.     class Action
  395.       attr_accessor :kind
  396.       attr_accessor :basic
  397.       attr_accessor :skill_id
  398.       attr_accessor :condition_turn_a
  399.       attr_accessor :condition_turn_b
  400.       attr_accessor :condition_hp
  401.       attr_accessor :condition_level
  402.       attr_accessor :condition_switch_id
  403.       attr_accessor :rating
  404.       def initialize
  405.         @kind = 0
  406.         @basic = 0
  407.         @skill_id = 1
  408.         @condition_turn_a = 0
  409.         @condition_turn_b = 1
  410.         @condition_hp = 100
  411.         @condition_level = 1
  412.         @condition_switch_id = 0
  413.         @rating = 5
  414.       end
  415.     end
  416.   end
  417. #-------------------------------------------------------------------------------------
  418. # RPG::Event
  419. #-------------------------------------------------------------------------------------
  420.   class Event
  421.     attr_accessor :id
  422.     attr_accessor :name
  423.     attr_accessor :x
  424.     attr_accessor :y
  425.     attr_accessor :pages
  426.     def initialize(x, y)
  427.       @id = 0
  428.       @name = ""
  429.       @x = x
  430.       @y = y
  431.       @pages = [RPG::Event::Page.new]
  432.     end
  433. #-------------------------------------------------------------------------------------
  434. # RPG::Event::Page
  435. #-------------------------------------------------------------------------------------
  436.     class Page
  437.       attr_accessor :condition
  438.       attr_accessor :graphic
  439.       attr_accessor :move_type
  440.       attr_accessor :move_speed
  441.       attr_accessor :move_frequency
  442.       attr_accessor :move_route
  443.       attr_accessor :walk_anime
  444.       attr_accessor :step_anime
  445.       attr_accessor :direction_fix
  446.       attr_accessor :through
  447.       attr_accessor :always_on_top
  448.       attr_accessor :trigger
  449.       attr_accessor :list
  450.       def initialize
  451.         @condition = RPG::Event::Page::Condition.new
  452.         @graphic = RPG::Event::Page::Graphic.new
  453.         @move_type = 0
  454.         @move_speed = 3
  455.         @move_frequency = 3
  456.         @move_route = RPG::MoveRoute.new
  457.         @walk_anime = true
  458.         @step_anime = false
  459.         @direction_fix = false
  460.         @through = false
  461.         @always_on_top = false
  462.         @trigger = 0
  463.         @list = [RPG::EventCommand.new]
  464.       end
  465. #-------------------------------------------------------------------------------------
  466. # RPG::Event::Page::Condition
  467. #-------------------------------------------------------------------------------------
  468.       class Condition
  469.         attr_accessor :switch1_valid
  470.         attr_accessor :switch2_valid
  471.         attr_accessor :variable_valid
  472.         attr_accessor :self_switch_valid
  473.         attr_accessor :switch1_id
  474.         attr_accessor :switch2_id
  475.         attr_accessor :variable_id
  476.         attr_accessor :variable_value
  477.         attr_accessor :self_switch_ch
  478.         def initialize
  479.           @switch1_valid = false
  480.           @switch2_valid = false
  481.           @variable_valid = false
  482.           @self_switch_valid = false
  483.           @switch1_id = 1
  484.           @switch2_id = 1
  485.           @variable_id = 1
  486.           @variable_value = 0
  487.           @self_switch_ch = "A"
  488.         end
  489.       end
  490. #-------------------------------------------------------------------------------------
  491. # RPG::Event::Page:Graphic
  492. #-------------------------------------------------------------------------------------
  493.       class Graphic
  494.         attr_accessor :tile_id
  495.         attr_accessor :character_name
  496.         attr_accessor :character_hue
  497.         attr_accessor :direction
  498.         attr_accessor :pattern
  499.         attr_accessor :opacity
  500.         attr_accessor :blend_type
  501.         def initialize
  502.           @tile_id = 0
  503.           @character_name = ""
  504.           @character_hue = 0
  505.           @direction = 2
  506.           @pattern = 0
  507.           @opacity = 255
  508.           @blend_type = 0
  509.         end
  510.       end
  511.     end
  512.   end
  513. #-------------------------------------------------------------------------------------
  514. # RPG::EventCommand
  515. #-------------------------------------------------------------------------------------
  516.   class EventCommand
  517.     attr_accessor :code
  518.     attr_accessor :indent
  519.     attr_accessor :parameters
  520.     def initialize(code = 0, indent = 0, parameters = [])
  521.       @code = code
  522.       @indent = indent
  523.       @parameters = parameters
  524.     end
  525.   end
  526. #-------------------------------------------------------------------------------------
  527. # RPG::Item
  528. #-------------------------------------------------------------------------------------
  529.   class Item
  530.     attr_accessor :id
  531.     attr_accessor :name
  532.     attr_accessor :icon_name
  533.     attr_accessor :description
  534.     attr_accessor :scope
  535.     attr_accessor :occasion
  536.     attr_accessor :animation1_id
  537.     attr_accessor :animation2_id
  538.     attr_accessor :menu_se
  539.     attr_accessor :common_event_id
  540.     attr_accessor :price
  541.     attr_accessor :consumable
  542.     attr_accessor :parameter_type
  543.     attr_accessor :parameter_points
  544.     attr_accessor :recover_hp_rate
  545.     attr_accessor :recover_hp
  546.     attr_accessor :recover_sp_rate
  547.     attr_accessor :recover_sp
  548.     attr_accessor :hit
  549.     attr_accessor :pdef_f
  550.     attr_accessor :mdef_f
  551.     attr_accessor :variance
  552.     attr_accessor :element_set
  553.     attr_accessor :plus_state_set
  554.     attr_accessor :minus_state_set
  555.     def initialize
  556.       @id = 0
  557.       @name = ""
  558.       @icon_name = ""
  559.       @description = ""
  560.       @scope = 0
  561.       @occasion = 0
  562.       @animation1_id = 0
  563.       @animation2_id = 0
  564.       @menu_se = RPG::AudioFile.new("", 80)
  565.       @common_event_id = 0
  566.       @price = 0
  567.       @consumable = true
  568.       @parameter_type = 0
  569.       @parameter_points = 0
  570.       @recover_hp_rate = 0
  571.       @recover_hp = 0
  572.       @recover_sp_rate = 0
  573.       @recover_sp = 0
  574.       @hit = 100
  575.       @pdef_f = 0
  576.       @mdef_f = 0
  577.       @variance = 0
  578.       @element_set = []
  579.       @plus_state_set = []
  580.       @minus_state_set = []
  581.     end
  582.   end
  583. #-------------------------------------------------------------------------------------
  584. # RPG::Map
  585. #-------------------------------------------------------------------------------------
  586.   class Map
  587.     attr_accessor :tileset_id
  588.     attr_accessor :width
  589.     attr_accessor :height
  590.     attr_accessor :autoplay_bgm
  591.     attr_accessor :bgm
  592.     attr_accessor :autoplay_bgs
  593.     attr_accessor :bgs
  594.     attr_accessor :encounter_list
  595.     attr_accessor :encounter_step
  596.     attr_accessor :data
  597.     attr_accessor :events
  598.     def initialize(width, height)
  599.       @tileset_id = 1
  600.       @width = width
  601.       @height = height
  602.       @autoplay_bgm = false
  603.       @bgm = RPG::AudioFile.new
  604.       @autoplay_bgs = false
  605.       @bgs = RPG::AudioFile.new("", 80)
  606.       @encounter_list = []
  607.       @encounter_step = 30
  608.       @data = Table.new(width, height, 3)
  609.       @events = {}
  610.     end
  611.   end
  612. #-------------------------------------------------------------------------------------
  613. # RPG::MapInfo
  614. #-------------------------------------------------------------------------------------
  615.   class MapInfo
  616.     attr_accessor :name
  617.     attr_accessor :parent_id
  618.     attr_accessor :order
  619.     attr_accessor :expanded
  620.     attr_accessor :scroll_x
  621.     attr_accessor :scroll_y
  622.     def initialize
  623.       @name = ""
  624.       @parent_id = 0
  625.       @order = 0
  626.       @expanded = false
  627.       @scroll_x = 0
  628.       @scroll_y = 0
  629.     end
  630.   end
  631. #-------------------------------------------------------------------------------------
  632. # RPG::MoveCommand
  633. #-------------------------------------------------------------------------------------
  634.   class MoveCommand
  635.     attr_accessor :code
  636.     attr_accessor :parameters
  637.     def initialize(code = 0, parameters = [nil] )
  638.       @code = code
  639.       @parameters = parameters
  640.     end
  641.   end
  642. #-------------------------------------------------------------------------------------
  643. # RPG::MoveRoute
  644. #-------------------------------------------------------------------------------------
  645.   class MoveRoute
  646.     attr_accessor :repeat
  647.     attr_accessor :skippable
  648.     attr_accessor :list
  649.     def initialize
  650.       @repeat = true
  651.       @skippable = false
  652.       @list = [RPG::MoveCommand.new]
  653.     end
  654.   end
  655. #-------------------------------------------------------------------------------------
  656. # RPG::Skill
  657. #-------------------------------------------------------------------------------------
  658.   class Skill
  659.     attr_accessor :id
  660.     attr_accessor :name
  661.     attr_accessor :icon_name
  662.     attr_accessor :description
  663.     attr_accessor :scope
  664.     attr_accessor :occasion
  665.     attr_accessor :animation1_id
  666.     attr_accessor :animation2_id
  667.     attr_accessor :menu_se
  668.     attr_accessor :common_event_id
  669.     attr_accessor :sp_cost
  670.     attr_accessor :power
  671.     attr_accessor :atk_f
  672.     attr_accessor :eva_f
  673.     attr_accessor :str_f
  674.     attr_accessor :dex_f
  675.     attr_accessor :agi_f
  676.     attr_accessor :int_f
  677.     attr_accessor :hit
  678.     attr_accessor :pdef_f
  679.     attr_accessor :mdef_f
  680.     attr_accessor :variance
  681.     attr_accessor :element_set
  682.     attr_accessor :plus_state_set
  683.     attr_accessor :minus_state_set
  684.     def initialize
  685.       @id = 0
  686.       @name = ""
  687.       @icon_name = ""
  688.       @description = ""
  689.       @scope = 0
  690.       @occasion = 1
  691.       @animation1_id = 0
  692.       @animation2_id = 0
  693.       @menu_se = RPG::AudioFile.new("", 80)
  694.       @common_event_id = 0
  695.       @sp_cost = 0
  696.       @power = 0
  697.       @atk_f = 0
  698.       @eva_f = 0
  699.       @str_f = 0
  700.       @dex_f = 0
  701.       @agi_f = 0
  702.       @int_f = 100
  703.       @hit = 100
  704.       @pdef_f = 0
  705.       @mdef_f = 100
  706.       @variance = 15
  707.       @element_set = []
  708.       @plus_state_set = []
  709.       @minus_state_set = []
  710.     end
  711.   end
  712. #-------------------------------------------------------------------------------------
  713. # RPG::Sprite
  714. #-------------------------------------------------------------------------------------
  715.  class Sprite < ::Sprite
  716.     @@_animations = []
  717.     @@_reference_count = {}
  718.     def initialize(viewport = nil)
  719.       super(viewport)
  720.       @_whiten_duration = 0
  721.       @_appear_duration = 0
  722.       @_escape_duration = 0
  723.       @_collapse_duration = 0
  724.       @_damage_duration = 0
  725.       @_animation_duration = 0
  726.       @_blink = false
  727.     end
  728.     def dispose
  729.       dispose_damage
  730.       dispose_animation
  731.       dispose_loop_animation
  732.       super
  733.     end
  734.     def whiten
  735.       self.blend_type = 0
  736.       self.color.set(255, 255, 255, 128)
  737.       self.opacity = 255
  738.       @_whiten_duration = 16
  739.       @_appear_duration = 0
  740.       @_escape_duration = 0
  741.       @_collapse_duration = 0
  742.     end
  743.     def appear
  744.       self.blend_type = 0
  745.       self.color.set(0, 0, 0, 0)
  746.       self.opacity = 0
  747.       @_appear_duration = 16
  748.       @_whiten_duration = 0
  749.       @_escape_duration = 0
  750.       @_collapse_duration = 0
  751.     end
  752.     def escape
  753.       self.blend_type = 0
  754.       self.color.set(0, 0, 0, 0)
  755.       self.opacity = 255
  756.       @_escape_duration = 32
  757.       @_whiten_duration = 0
  758.       @_appear_duration = 0
  759.       @_collapse_duration = 0
  760.     end
  761.     def collapse
  762.       self.blend_type = 1
  763.       self.color.set(255, 64, 64, 255)
  764.       self.opacity = 255
  765.       @_collapse_duration = 48
  766.       @_whiten_duration = 0
  767.       @_appear_duration = 0
  768.       @_escape_duration = 0
  769.     end
  770.     def damage(value, critical)
  771.       dispose_damage
  772.       if value.is_a?(Numeric)
  773.         damage_string = value.abs.to_s
  774.       else
  775.         damage_string = value.to_s
  776.       end
  777.       bitmap = Bitmap.new(160, 48)
  778.       bitmap.font.name = "Arial Black"
  779.       bitmap.font.size = 32
  780.       bitmap.font.color.set(0, 0, 0)
  781.       bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
  782.       bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
  783.       bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
  784.       bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
  785.       if value.is_a?(Numeric) and value < 0
  786.         bitmap.font.color.set(176, 255, 144)
  787.       else
  788.         bitmap.font.color.set(255, 255, 255)
  789.       end
  790.       bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
  791.       if critical
  792.         bitmap.font.size = 20
  793.         bitmap.font.color.set(0, 0, 0)
  794.         bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1)
  795.         bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1)
  796.         bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1)
  797.         bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1)
  798.         bitmap.font.color.set(255, 255, 255)
  799.         bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1)
  800.       end
  801.       @_damage_sprite = ::Sprite.new(self.viewport)
  802.       @_damage_sprite.bitmap = bitmap
  803.       @_damage_sprite.ox = 80
  804.       @_damage_sprite.oy = 20
  805.       @_damage_sprite.x = self.x
  806.       @_damage_sprite.y = self.y - self.oy / 2
  807.       @_damage_sprite.z = 3000
  808.       @_damage_duration = 40
  809.     end
  810.     def animation(animation, hit)
  811.       dispose_animation
  812.       @_animation = animation
  813.       return if @_animation == nil
  814.       @_animation_hit = hit
  815.       @_animation_duration = @_animation.frame_max
  816.       animation_name = @_animation.animation_name
  817.       animation_hue = @_animation.animation_hue
  818.       bitmap = RPG::Cache.animation(animation_name, animation_hue)
  819.       if @@_reference_count.include?(bitmap)
  820.         @@_reference_count[bitmap] += 1
  821.       else
  822.         @@_reference_count[bitmap] = 1
  823.       end
  824.       @_animation_sprites = []
  825.       if @_animation.position != 3 or not @@_animations.include?(animation)
  826.         for i in 0..15
  827.           sprite = ::Sprite.new(self.viewport)
  828.           sprite.bitmap = bitmap
  829.           sprite.visible = false
  830.           @_animation_sprites.push(sprite)
  831.         end
  832.         unless @@_animations.include?(animation)
  833.           @@_animations.push(animation)
  834.         end
  835.       end
  836.       update_animation
  837.     end
  838.     def loop_animation(animation)
  839.       return if animation == @_loop_animation
  840.       dispose_loop_animation
  841.       @_loop_animation = animation
  842.       return if @_loop_animation == nil
  843.       @_loop_animation_index = 0
  844.       animation_name = @_loop_animation.animation_name
  845.       animation_hue = @_loop_animation.animation_hue
  846.       bitmap = RPG::Cache.animation(animation_name, animation_hue)
  847.       if @@_reference_count.include?(bitmap)
  848.         @@_reference_count[bitmap] += 1
  849.       else
  850.         @@_reference_count[bitmap] = 1
  851.       end
  852.       @_loop_animation_sprites = []
  853.       for i in 0..15
  854.         sprite = ::Sprite.new(self.viewport)
  855.         sprite.bitmap = bitmap
  856.         sprite.visible = false
  857.         @_loop_animation_sprites.push(sprite)
  858.       end
  859.       update_loop_animation
  860.     end
  861.     def dispose_damage
  862.       if @_damage_sprite != nil
  863.         @_damage_sprite.bitmap.dispose
  864.         @_damage_sprite.dispose
  865.         @_damage_sprite = nil
  866.         @_damage_duration = 0
  867.       end
  868.     end
  869.     def dispose_animation
  870.       if @_animation_sprites != nil
  871.         sprite = @_animation_sprites[0]
  872.         if sprite != nil
  873.           @@_reference_count[sprite.bitmap] -= 1
  874.           if @@_reference_count[sprite.bitmap] == 0
  875.             sprite.bitmap.dispose
  876.           end
  877.         end
  878.         for sprite in @_animation_sprites
  879.           sprite.dispose
  880.         end
  881.         @_animation_sprites = nil
  882.         @_animation = nil
  883.       end
  884.     end
  885.     def dispose_loop_animation
  886.       if @_loop_animation_sprites != nil
  887.         sprite = @_loop_animation_sprites[0]
  888.         if sprite != nil
  889.           @@_reference_count[sprite.bitmap] -= 1
  890.           if @@_reference_count[sprite.bitmap] == 0
  891.             sprite.bitmap.dispose
  892.           end
  893.         end
  894.         for sprite in @_loop_animation_sprites
  895.           sprite.dispose
  896.         end
  897.         @_loop_animation_sprites = nil
  898.         @_loop_animation = nil
  899.       end
  900.     end
  901.     def blink_on
  902.       unless @_blink
  903.         @_blink = true
  904.         @_blink_count = 0
  905.       end
  906.     end
  907.     def blink_off
  908.       if @_blink
  909.         @_blink = false
  910.         self.color.set(0, 0, 0, 0)
  911.       end
  912.     end
  913.     def blink?
  914.       @_blink
  915.     end
  916.     def effect?
  917.       @_whiten_duration > 0 or
  918.       @_appear_duration > 0 or
  919.       @_escape_duration > 0 or
  920.       @_collapse_duration > 0 or
  921.       @_damage_duration > 0 or
  922.       @_animation_duration > 0
  923.     end
  924.     def update
  925.       super
  926.       if @_whiten_duration > 0
  927.         @_whiten_duration -= 1
  928.         self.color.alpha = 128 - (16 - @_whiten_duration) * 10
  929.       end
  930.       if @_appear_duration > 0
  931.         @_appear_duration -= 1
  932.         self.opacity = (16 - @_appear_duration) * 16
  933.       end
  934.       if @_escape_duration > 0
  935.         @_escape_duration -= 1
  936.         self.opacity = 256 - (32 - @_escape_duration) * 10
  937.       end
  938.       if @_collapse_duration > 0
  939.         @_collapse_duration -= 1
  940.         self.opacity = 256 - (48 - @_collapse_duration) * 6
  941.       end
  942.       if @_damage_duration > 0
  943.         @_damage_duration -= 1
  944.         case @_damage_duration
  945.         when 38..39
  946.           @_damage_sprite.y -= 4
  947.         when 36..37
  948.           @_damage_sprite.y -= 2
  949.         when 34..35
  950.           @_damage_sprite.y += 2
  951.         when 28..33
  952.           @_damage_sprite.y += 4
  953.         end
  954.         @_damage_sprite.opacity = 256 - (12 - @_damage_duration) * 32
  955.         if @_damage_duration == 0
  956.           dispose_damage
  957.         end
  958.       end
  959.       if @_animation != nil and (Graphics.frame_count % 2 == 0)
  960.         @_animation_duration -= 1
  961.         update_animation
  962.       end
  963.       if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
  964.         update_loop_animation
  965.         @_loop_animation_index += 1
  966.         @_loop_animation_index %= @_loop_animation.frame_max
  967.       end
  968.       if @_blink
  969.         @_blink_count = (@_blink_count + 1) % 32
  970.         if @_blink_count < 16
  971.           alpha = (16 - @_blink_count) * 6
  972.         else
  973.           alpha = (@_blink_count - 16) * 6
  974.         end
  975.         self.color.set(255, 255, 255, alpha)
  976.       end
  977.       @@_animations.clear
  978.     end
  979.     def update_animation
  980.       if @_animation_duration > 0
  981.         frame_index = @_animation.frame_max - @_animation_duration
  982.         cell_data = @_animation.frames[frame_index].cell_data
  983.         position = @_animation.position
  984.         animation_set_sprites(@_animation_sprites, cell_data, position)
  985.         for timing in @_animation.timings
  986.           if timing.frame == frame_index
  987.             animation_process_timing(timing, @_animation_hit)
  988.           end
  989.         end
  990.       else
  991.         dispose_animation
  992.       end
  993.     end
  994.     def update_loop_animation
  995.       frame_index = @_loop_animation_index
  996.       cell_data = @_loop_animation.frames[frame_index].cell_data
  997.       position = @_loop_animation.position
  998.       animation_set_sprites(@_loop_animation_sprites, cell_data, position)
  999.       for timing in @_loop_animation.timings
  1000.         if timing.frame == frame_index
  1001.           animation_process_timing(timing, true)
  1002.         end
  1003.       end
  1004.     end
  1005.     def animation_set_sprites(sprites, cell_data, position)
  1006.       for i in 0..15
  1007.         sprite = sprites[i]
  1008.         pattern = cell_data[i, 0]
  1009.         if sprite == nil or pattern == nil or pattern == -1
  1010.           sprite.visible = false if sprite != nil
  1011.           next
  1012.         end
  1013.         sprite.visible = true
  1014.         sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
  1015.         if position == 3
  1016.           if self.viewport != nil
  1017.             sprite.x = self.viewport.rect.width / 2
  1018.             sprite.y = self.viewport.rect.height - 160
  1019.           else
  1020.             sprite.x = 320
  1021.             sprite.y = 240
  1022.           end
  1023.         else
  1024.           sprite.x = self.x - self.ox + self.src_rect.width / 2
  1025.           sprite.y = self.y - self.oy + self.src_rect.height / 2
  1026.           sprite.y -= self.src_rect.height / 4 if position == 0
  1027.           sprite.y += self.src_rect.height / 4 if position == 2
  1028.         end
  1029.         sprite.x += cell_data[i, 1]
  1030.         sprite.y += cell_data[i, 2]
  1031.         sprite.z = 2000
  1032.         sprite.ox = 96
  1033.         sprite.oy = 96
  1034.         sprite.zoom_x = cell_data[i, 3] / 100.0
  1035.         sprite.zoom_y = cell_data[i, 3] / 100.0
  1036.         sprite.angle = cell_data[i, 4]
  1037.         sprite.mirror = (cell_data[i, 5] == 1)
  1038.         sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  1039.         sprite.blend_type = cell_data[i, 7]
  1040.       end
  1041.     end
  1042.     def animation_process_timing(timing, hit)
  1043.       if (timing.condition == 0) or
  1044.          (timing.condition == 1 and hit == true) or
  1045.          (timing.condition == 2 and hit == false)
  1046.         if timing.se.name != ""
  1047.           se = timing.se
  1048.           Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch)
  1049.         end
  1050.         case timing.flash_scope
  1051.         when 1
  1052.           self.flash(timing.flash_color, timing.flash_duration * 2)
  1053.         when 2
  1054.           if self.viewport != nil
  1055.             self.viewport.flash(timing.flash_color, timing.flash_duration * 2)
  1056.           end
  1057.         when 3
  1058.           self.flash(nil, timing.flash_duration * 2)
  1059.         end
  1060.       end
  1061.     end
  1062.     def x=(x)
  1063.       sx = x - self.x
  1064.       if sx != 0
  1065.         if @_animation_sprites != nil
  1066.           for i in 0..15
  1067.             @_animation_sprites[i].x += sx
  1068.           end
  1069.         end
  1070.         if @_loop_animation_sprites != nil
  1071.           for i in 0..15
  1072.             @_loop_animation_sprites[i].x += sx
  1073.           end
  1074.         end
  1075.       end
  1076.       super
  1077.     end
  1078.     def y=(y)
  1079.       sy = y - self.y
  1080.       if sy != 0
  1081.         if @_animation_sprites != nil
  1082.           for i in 0..15
  1083.             @_animation_sprites[i].y += sy
  1084.           end
  1085.         end
  1086.         if @_loop_animation_sprites != nil
  1087.           for i in 0..15
  1088.             @_loop_animation_sprites[i].y += sy
  1089.           end
  1090.         end
  1091.       end
  1092.       super
  1093.     end
  1094.   end
  1095. #-------------------------------------------------------------------------------------
  1096. # RPG::State
  1097. #-------------------------------------------------------------------------------------
  1098.   class State
  1099.     attr_accessor :id
  1100.     attr_accessor :name
  1101.     attr_accessor :animation_id
  1102.     attr_accessor :restriction
  1103.     attr_accessor :nonresistance
  1104.     attr_accessor :zero_hp
  1105.     attr_accessor :cant_get_exp
  1106.     attr_accessor :cant_evade
  1107.     attr_accessor :slip_damage
  1108.     attr_accessor :rating
  1109.     attr_accessor :hit_rate
  1110.     attr_accessor :maxhp_rate
  1111.     attr_accessor :maxsp_rate
  1112.     attr_accessor :str_rate
  1113.     attr_accessor :dex_rate
  1114.     attr_accessor :agi_rate
  1115.     attr_accessor :int_rate
  1116.     attr_accessor :atk_rate
  1117.     attr_accessor :pdef_rate
  1118.     attr_accessor :mdef_rate
  1119.     attr_accessor :eva
  1120.     attr_accessor :battle_only
  1121.     attr_accessor :hold_turn
  1122.     attr_accessor :auto_release_prob
  1123.     attr_accessor :shock_release_prob
  1124.     attr_accessor :guard_element_set
  1125.     attr_accessor :plus_state_set
  1126.     attr_accessor :minus_state_set
  1127.     def initialize
  1128.       @id = 0
  1129.       @name = ""
  1130.       @animation_id = 0
  1131.       @restriction = 0
  1132.       @nonresistance = false
  1133.       @zero_hp = false
  1134.       @cant_get_exp = false
  1135.       @cant_evade = false
  1136.       @slip_damage = false
  1137.       @rating = 5
  1138.       @hit_rate = 100
  1139.       @maxhp_rate = 100
  1140.       @maxsp_rate = 100
  1141.       @str_rate = 100
  1142.       @dex_rate = 100
  1143.       @agi_rate = 100
  1144.       @int_rate = 100
  1145.       @atk_rate = 100
  1146.       @pdef_rate = 100
  1147.       @mdef_rate = 100
  1148.       @eva = 0
  1149.       @battle_only = true
  1150.       @hold_turn = 0
  1151.       @auto_release_prob = 0
  1152.       @shock_release_prob = 0
  1153.       @guard_element_set = []
  1154.       @plus_state_set = []
  1155.       @minus_state_set = []
  1156.     end
  1157.   end
  1158. #-------------------------------------------------------------------------------------
  1159. # RPG::System
  1160. #-------------------------------------------------------------------------------------
  1161.   class System
  1162.     attr_accessor :magic_number
  1163.     attr_accessor :party_members
  1164.     attr_accessor :elements
  1165.     attr_accessor :switches
  1166.     attr_accessor :variables
  1167.     attr_accessor :windowskin_name
  1168.     attr_accessor :title_name
  1169.     attr_accessor :gameover_name
  1170.     attr_accessor :battle_transition
  1171.     attr_accessor :title_bgm
  1172.     attr_accessor :battle_bgm
  1173.     attr_accessor :battle_end_me
  1174.     attr_accessor :gameover_me
  1175.     attr_accessor :cursor_se
  1176.     attr_accessor :decision_se
  1177.     attr_accessor :cancel_se
  1178.     attr_accessor :buzzer_se
  1179.     attr_accessor :equip_se
  1180.     attr_accessor :shop_se
  1181.     attr_accessor :save_se
  1182.     attr_accessor :load_se
  1183.     attr_accessor :battle_start_se
  1184.     attr_accessor :escape_se
  1185.     attr_accessor :actor_collapse_se
  1186.     attr_accessor :enemy_collapse_se
  1187.     attr_accessor :words
  1188.     attr_accessor :test_battlers
  1189.     attr_accessor :test_troop_id
  1190.     attr_accessor :start_map_id
  1191.     attr_accessor :start_x
  1192.     attr_accessor :start_y
  1193.     attr_accessor :battleback_name
  1194.     attr_accessor :battler_name
  1195.     attr_accessor :battler_hue
  1196.     attr_accessor :edit_map_id
  1197.     def initialize
  1198.       @magic_number = 0
  1199.       @party_members = [1]
  1200.       @elements = [nil, ""]
  1201.       @switches = [nil, ""]
  1202.       @variables = [nil, ""]
  1203.       @windowskin_name = ""
  1204.       @title_name = ""
  1205.       @gameover_name = ""
  1206.       @battle_transition = ""
  1207.       @title_bgm = RPG::AudioFile.new
  1208.       @battle_bgm = RPG::AudioFile.new
  1209.       @battle_end_me = RPG::AudioFile.new
  1210.       @gameover_me = RPG::AudioFile.new
  1211.       @cursor_se = RPG::AudioFile.new("", 80)
  1212.       @decision_se = RPG::AudioFile.new("", 80)
  1213.       @cancel_se = RPG::AudioFile.new("", 80)
  1214.       @buzzer_se = RPG::AudioFile.new("", 80)
  1215.       @equip_se = RPG::AudioFile.new("", 80)
  1216.       @shop_se = RPG::AudioFile.new("", 80)
  1217.       @save_se = RPG::AudioFile.new("", 80)
  1218.       @load_se = RPG::AudioFile.new("", 80)
  1219.       @battle_start_se = RPG::AudioFile.new("", 80)
  1220.       @escape_se = RPG::AudioFile.new("", 80)
  1221.       @actor_collapse_se = RPG::AudioFile.new("", 80)
  1222.       @enemy_collapse_se = RPG::AudioFile.new("", 80)
  1223.       @words = RPG::System::Words.new
  1224.       @test_battlers = []
  1225.       @test_troop_id = 1
  1226.       @start_map_id = 1
  1227.       @start_x = 0
  1228.       @start_y = 0
  1229.       @battleback_name = ""
  1230.       @battler_name = ""
  1231.       @battler_hue = 0
  1232.       @edit_map_id = 1
  1233.     end
  1234. #-------------------------------------------------------------------------------------
  1235. # RPG::System::TestBattler
  1236. #-------------------------------------------------------------------------------------
  1237.     class TestBattler
  1238.       attr_accessor :actor_id
  1239.       attr_accessor :level
  1240.       attr_accessor :weapon_id
  1241.       attr_accessor :armor1_id
  1242.       attr_accessor :armor2_id
  1243.       attr_accessor :armor3_id
  1244.       attr_accessor :armor4_id
  1245.       def initialize
  1246.         @actor_id = 1
  1247.         @level = 1
  1248.         @weapon_id = 0
  1249.         @armor1_id = 0
  1250.         @armor2_id = 0
  1251.         @armor3_id = 0
  1252.         @armor4_id = 0
  1253.       end
  1254.     end
  1255. #-------------------------------------------------------------------------------------
  1256. # RPG::System::Words
  1257. #-------------------------------------------------------------------------------------
  1258.     class Words
  1259.       attr_accessor :gold
  1260.       attr_accessor :hp
  1261.       attr_accessor :sp
  1262.       attr_accessor :str
  1263.       attr_accessor :dex
  1264.       attr_accessor :agi
  1265.       attr_accessor :int
  1266.       attr_accessor :atk
  1267.       attr_accessor :pdef
  1268.       attr_accessor :mdef
  1269.       attr_accessor :weapon
  1270.       attr_accessor :armor1
  1271.       attr_accessor :armor2
  1272.       attr_accessor :armor3
  1273.       attr_accessor :armor4
  1274.       attr_accessor :attack
  1275.       attr_accessor :skill
  1276.       attr_accessor :guard
  1277.       attr_accessor :item
  1278.       attr_accessor :equip
  1279.       def initialize
  1280.         @gold = ""
  1281.         @hp = ""
  1282.         @sp = ""
  1283.         @str = ""
  1284.         @dex = ""
  1285.         @agi = ""
  1286.         @int = ""
  1287.         @atk = ""
  1288.         @pdef = ""
  1289.         @mdef = ""
  1290.         @weapon = ""
  1291.         @armor1 = ""
  1292.         @armor2 = ""
  1293.         @armor3 = ""
  1294.         @armor4 = ""
  1295.         @attack = ""
  1296.         @skill = ""
  1297.         @guard = ""
  1298.         @item = ""
  1299.         @equip = ""
  1300.       end
  1301.     end
  1302.   end
  1303. #-------------------------------------------------------------------------------------
  1304. # RPG::Tileset
  1305. #-------------------------------------------------------------------------------------
  1306.   class Tileset
  1307.     attr_accessor :id
  1308.     attr_accessor :name
  1309.     attr_accessor :tileset_name
  1310.     attr_accessor :autotile_names
  1311.     attr_accessor :panorama_name
  1312.     attr_accessor :panorama_hue
  1313.     attr_accessor :fog_name
  1314.     attr_accessor :fog_hue
  1315.     attr_accessor :fog_opacity
  1316.     attr_accessor :fog_blend_type
  1317.     attr_accessor :fog_zoom
  1318.     attr_accessor :fog_sx
  1319.     attr_accessor :fog_sy
  1320.     attr_accessor :battleback_name
  1321.     attr_accessor :passages
  1322.     attr_accessor :priorities
  1323.     attr_accessor :terrain_tags
  1324.     def initialize
  1325.       @id = 0
  1326.       @name = ""
  1327.       @tileset_name = ""
  1328.       @autotile_names = [""]*7
  1329.       @panorama_name = ""
  1330.       @panorama_hue = 0
  1331.       @fog_name = ""
  1332.       @fog_hue = 0
  1333.       @fog_opacity = 64
  1334.       @fog_blend_type = 0
  1335.       @fog_zoom = 200
  1336.       @fog_sx = 0
  1337.       @fog_sy = 0
  1338.       @battleback_name = ""
  1339.       @passages = Table.new(384)
  1340.       @priorities = Table.new(384)
  1341.       @priorities[0] = 5
  1342.       @terrain_tags = Table.new(384)
  1343.     end
  1344.   end
  1345. #-------------------------------------------------------------------------------------
  1346. # RPG::Troop
  1347. #-------------------------------------------------------------------------------------
  1348.   class Troop
  1349.     attr_accessor :id
  1350.     attr_accessor :name
  1351.     attr_accessor :members
  1352.     attr_accessor :pages
  1353.     def initialize
  1354.       @id = 0
  1355.       @name = ""
  1356.       @members = []
  1357.       @pages = [RPG::Troop::Page.new]
  1358.     end
  1359. #-------------------------------------------------------------------------------------
  1360. # RPG::Troop::Member
  1361. #-------------------------------------------------------------------------------------
  1362.     class Member
  1363.       attr_accessor :enemy_id
  1364.       attr_accessor :x
  1365.       attr_accessor :y
  1366.       attr_accessor :hidden
  1367.       attr_accessor :immortal
  1368.       def initialize
  1369.         @enemy_id = 1
  1370.         @x = 0
  1371.         @y = 0
  1372.         @hidden = false
  1373.         @immortal = false
  1374.       end
  1375.     end
  1376. #-------------------------------------------------------------------------------------
  1377. # RPG::Troop::Page
  1378. #-------------------------------------------------------------------------------------
  1379.     class Page
  1380.       attr_accessor :condition
  1381.       attr_accessor :span
  1382.       attr_accessor :list
  1383.       def initialize
  1384.         @condition = RPG::Troop::Page::Condition.new
  1385.         @span = 0
  1386.         @list = [RPG::EventCommand.new]
  1387.       end
  1388. #-------------------------------------------------------------------------------------
  1389. # RPG::Troop::Condition
  1390. #-------------------------------------------------------------------------------------
  1391.       class Condition
  1392.         attr_accessor :turn_valid
  1393.         attr_accessor :enemy_valid
  1394.         attr_accessor :actor_valid
  1395.         attr_accessor :switch_valid
  1396.         attr_accessor :turn_a
  1397.         attr_accessor :turn_b
  1398.         attr_accessor :enemy_index
  1399.         attr_accessor :enemy_hp
  1400.         attr_accessor :actor_id
  1401.         attr_accessor :actor_hp
  1402.         attr_accessor :switch_id
  1403.         def initialize
  1404.           @turn_valid = false
  1405.           @enemy_valid = false
  1406.           @actor_valid = false
  1407.           @switch_valid = false
  1408.           @turn_a = 0
  1409.           @turn_b = 0
  1410.           @enemy_index = 0
  1411.           @enemy_hp = 50
  1412.           @actor_id = 1
  1413.           @actor_hp = 50
  1414.           @switch_id = 1
  1415.         end
  1416.       end
  1417.     end
  1418.   end
  1419. #-------------------------------------------------------------------------------------
  1420. # RPG::Weapon
  1421. #-------------------------------------------------------------------------------------
  1422.   class Weapon
  1423.     attr_accessor :id
  1424.     attr_accessor :name
  1425.     attr_accessor :icon_name
  1426.     attr_accessor :description
  1427.     attr_accessor :animation1_id
  1428.     attr_accessor :animation2_id
  1429.     attr_accessor :price
  1430.     attr_accessor :atk
  1431.     attr_accessor :pdef
  1432.     attr_accessor :mdef
  1433.     attr_accessor :str_plus
  1434.     attr_accessor :dex_plus
  1435.     attr_accessor :agi_plus
  1436.     attr_accessor :int_plus
  1437.     attr_accessor :element_set
  1438.     attr_accessor :plus_state_set
  1439.     attr_accessor :minus_state_set
  1440.     def initialize
  1441.       @id = 0
  1442.       @name = ""
  1443.       @icon_name = ""
  1444.       @description = ""
  1445.       @animation1_id = 0
  1446.       @animation2_id = 0
  1447.       @price = 0
  1448.       @atk = 0
  1449.       @pdef = 0
  1450.       @mdef = 0
  1451.       @str_plus = 0
  1452.       @dex_plus = 0
  1453.       @agi_plus = 0
  1454.       @int_plus = 0
  1455.       @element_set = []
  1456.       @plus_state_set = []
  1457.       @minus_state_set = []
  1458.     end
  1459.   end
  1460. #-------------------------------------------------------------------------------------
  1461. # RPG::Weather
  1462. #-------------------------------------------------------------------------------------
  1463.   class Weather
  1464.     def initialize(viewport = nil)
  1465.       @type = 0
  1466.       @max = 0
  1467.       @ox = 0
  1468.       @oy = 0
  1469.       color1 = Color.new(255, 255, 255, 255)
  1470.       color2 = Color.new(255, 255, 255, 128)
  1471.       @rain_bitmap = Bitmap.new(7, 56)
  1472.       for i in 0..6
  1473.         @rain_bitmap.fill_rect(6-i, i*8, 1, 8, color1)
  1474.       end
  1475.       @storm_bitmap = Bitmap.new(34, 64)
  1476.       for i in 0..31
  1477.         @storm_bitmap.fill_rect(33-i, i*2, 1, 2, color2)
  1478.         @storm_bitmap.fill_rect(32-i, i*2, 1, 2, color1)
  1479.         @storm_bitmap.fill_rect(31-i, i*2, 1, 2, color2)
  1480.       end
  1481.       @snow_bitmap = Bitmap.new(6, 6)
  1482.       @snow_bitmap.fill_rect(0, 1, 6, 4, color2)
  1483.       @snow_bitmap.fill_rect(1, 0, 4, 6, color2)
  1484.       @snow_bitmap.fill_rect(1, 2, 4, 2, color1)
  1485.       @snow_bitmap.fill_rect(2, 1, 2, 4, color1)
  1486.       @sprites = []
  1487.       for i in 1..40
  1488.         sprite = Sprite.new(viewport)
  1489.         sprite.z = 1000
  1490.         sprite.visible = false
  1491.         sprite.opacity = 0
  1492.         @sprites.push(sprite)
  1493.       end
  1494.     end
  1495.     def dispose
  1496.       for sprite in @sprites
  1497.         sprite.dispose
  1498.       end
  1499.       @rain_bitmap.dispose
  1500.       @storm_bitmap.dispose
  1501.       @snow_bitmap.dispose
  1502.     end
  1503.     def type=(type)
  1504.       return if @type == type
  1505.       @type = type
  1506.       case @type
  1507.       when 1
  1508.         bitmap = @rain_bitmap
  1509.       when 2
  1510.         bitmap = @storm_bitmap
  1511.       when 3
  1512.         bitmap = @snow_bitmap
  1513.       else
  1514.         bitmap = nil
  1515.       end
  1516.       for i in 1..40
  1517.         sprite = @sprites[i]
  1518.         if sprite != nil
  1519.           sprite.visible = (i <= @max)
  1520.           sprite.bitmap = bitmap
  1521.         end
  1522.       end
  1523.     end
  1524.     def ox=(ox)
  1525.       return if @ox == ox;
  1526.       @ox = ox
  1527.       for sprite in @sprites
  1528.         sprite.ox = @ox
  1529.       end
  1530.     end
  1531.     def oy=(oy)
  1532.       return if @oy == oy;
  1533.       @oy = oy
  1534.       for sprite in @sprites
  1535.         sprite.oy = @oy
  1536.       end
  1537.     end
  1538.     def max=(max)
  1539.       return if @max == max;
  1540.       @max = [[max, 0].max, 40].min
  1541.       for i in 1..40
  1542.         sprite = @sprites[i]
  1543.         if sprite != nil
  1544.           sprite.visible = (i <= @max)
  1545.         end
  1546.       end
  1547.     end
  1548.     def update
  1549.       return if @type == 0
  1550.       for i in 1..@max
  1551.         sprite = @sprites[i]
  1552.         if sprite == nil
  1553.           break
  1554.         end
  1555.         if @type == 1
  1556.           sprite.x -= 2
  1557.           sprite.y += 16
  1558.           sprite.opacity -= 8
  1559.         end
  1560.         if @type == 2
  1561.           sprite.x -= 8
  1562.           sprite.y += 16
  1563.           sprite.opacity -= 12
  1564.         end
  1565.         if @type == 3
  1566.           sprite.x -= 2
  1567.           sprite.y += 8
  1568.           sprite.opacity -= 8
  1569.         end
  1570.         x = sprite.x - @ox
  1571.         y = sprite.y - @oy
  1572.         if sprite.opacity < 64 or x < -50 or x > 750 or y < -300 or y > 500
  1573.           sprite.x = rand(800) - 50 + @ox
  1574.           sprite.y = rand(800) - 200 + @oy
  1575.           sprite.opacity = 255
  1576.         end
  1577.       end
  1578.     end
  1579.     attr_reader :type
  1580.     attr_reader :max
  1581.     attr_reader :ox
  1582.     attr_reader :oy
  1583.   end
  1584. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement