Advertisement
Guest User

RPG module

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