1. #==============================================================================#
  2. # ** Yggdrasil 1x6 - Engine (Full)
  3. #------------------------------------------------------------------------------#
  4. # ** Created by    : IceDragon (http://www.rpgmakervx.net/)
  5. # ** Script-Status : CBS (Custom Battle System)
  6. # ** Script Type   : Engine (ABS Base)
  7. # ** Date Created  : 10/11/2010
  8. # ** Date Modified : 12/02/2011
  9. # ** Version       : 1.6b
  10. #------------------------------------------------------------------------------#
  11. #==============================================================================#
  12. # ** INTRODUCTION
  13. #------------------------------------------------------------------------------#
  14. # So hello there, thank you for looking at Yggdrasil 1.6 (or 1x6)
  15. # This is NOT an update for the 1.x series really.
  16. # This was meant to be Yggdrasil 2, but I scrapped that.
  17. # Anyway 1.6 removes the "Attack" system that was present in the older versions.
  18. # Also the Action system as been directly implemented into it.
  19. # All nessecary scripts are included (Such as Hud, Item, Skills etc..etc)
  20. # In addition, the engine has a built in Stat Cache (!!!)
  21. # Overall this version was meant to be a performance update/ungrade.
  22. #
  23. #------------------------------------------------------------------------------#
  24. #==============================================================================#
  25. # ** FEATURES
  26. #------------------------------------------------------------------------------#
  27. #  *I'll fill this when I feel like it*
  28. #------------------------------------------------------------------------------#
  29. #==============================================================================#
  30. # ** RECOMMENDED
  31. #------------------------------------------------------------------------------#
  32. #
  33. # IRME - Icy Random Map Encounters
  34. #
  35. # YEM Keyboard Input (Has been merged with the current Yggdrasil Version)
  36. #
  37. #------------------------------------------------------------------------------#
  38. #==============================================================================#
  39. # ** CHANGE LOG
  40. #------------------------------------------------------------------------------#
  41. #
  42. # (MM/DD/YYYY)
  43. #  10/11/2010 - BETA  Started Script
  44. #  11/09/2010 - V1.0  Finished Script
  45. #  11/15/2010 - V1.1  A whole lot of stuff happened
  46. #                     Several bug fixes, new features (Too many to list)
  47. #  ??/??/???? - V1.2  Several Improvements and BugFixes
  48. #  12/17/2010 - V1.3  AI improvements, AI can now use skills
  49. #  02/19/2011 - V1.4  So many changes, I tottaly forgot,
  50. #                     Main things though, Targetting has been changed slightly
  51. #                     Some fixes (Which I don't remember) have been done.
  52. #  07/01/2011 - V1.59 Started Revamping entire code.
  53. #  10/14/2011 - V1.6  Finished 1.6
  54. #  11/30/2011 - V1.6a Fixed 3 bugs, added 5 new feature:
  55. #                     BUGS:
  56. #                       Stats didn't change when equipment was changed.
  57. #                       Disabling the Shift System would cause an error.
  58. #                       Disabling the level up window would cause an error
  59. #                     NEW:
  60. #                       Added pickup sounds:
  61. #                         <pksfx: filename, vol, pit>
  62. #                       Added popup enabling and disabling (For event comments)
  63. #                         <enable pop>
  64. #                         <disable pop> or <no pop>
  65. #                       Added Bar Hiding (For event comments)
  66. #                         <hide hp bar> ; <show hp bar>
  67. #                         <hide mp bar> ; <show mp bar>
  68. #                       Added changable attack animation for enemies:
  69. #                         <atk animation id: n>
  70. #                       Added extended drops for enemies:
  71. #                         <drop item n>
  72. #                         item_id: n
  73. #                         weapon_id: n
  74. #                         armor_id: n
  75. #                         prob: n
  76. #                         </drop item>
  77. # 12/02/2011 - V1.6b  Added 4 new features, fixed 1 bug, housekeeping
  78. #                     BUGS:
  79. #                       Event Bars would hang in top right hand corner
  80. #                     NEW:  
  81. #                       Wrote Hud Wrapper, added hud position procs
  82. #                       Added Random class (for whatever reason)
  83. #                       Added gold randomization for enemies. (BAM)
  84. #                         <gold variation: n>
  85. #                       Added Guarding: (How long will the guard action take)
  86. #                         action_guard
  87. #                         ["GUARD", [frames]]
  88. #                         guard: frames
  89. #                         While Guarding all other actions are blocked.
  90. #
  91. #                     CLEAN:
  92. #                       Rewrote Introduction
  93. #                       Removed unused constants
  94. #                      
  95. #------------------------------------------------------------------------------#
  96. #==============================================================================#
  97. # ** KNOWN ISSUES
  98. #------------------------------------------------------------------------------#
  99. #  Becareful when using:
  100. #  <action n>
  101. #  </action>
  102. #  It is very sensitive (even whitespace can destroy your action) D:
  103. #  If you aren't confident stick to the <action n= string> method
  104. #
  105. #  Due to the size of the script, any error that occurs in the script MAY
  106. #  not be located on the correct line.
  107. #  I will split the script (AGAIN) later, to fix this problem.
  108. #
  109. #------------------------------------------------------------------------------#
  110. #==============================================================================#  
  111. # ** YGG
  112. #==============================================================================#
  113. module YGG
  114. #==============================================================================#
  115. #                           Start Customization
  116. #------------------------------------------------------------------------------#
  117. #==============================================================================#
  118.   #--------------------------------------------------------------------------#
  119.   # * ABS_SYSTEM_SWITCH
  120.   #--------------------------------------------------------------------------#
  121.   # This is the switch which controls Yggdrasil
  122.   # If you set this constant to nil, Yggdrasil will always be active.
  123.   #--------------------------------------------------------------------------#
  124.     ABS_SYSTEM_SWITCH = 2
  125.  
  126.   #--------------------------------------------------------------------------#
  127.   # * ITEM_MAP
  128.   #--------------------------------------------------------------------------#
  129.   # Currently this is not used for 1.6, but its still nice to have it
  130.   # just in case XD
  131.   #--------------------------------------------------------------------------#
  132.     ITEM_MAP = 2
  133.        
  134.   #--------------------------------------------------------------------------#
  135.   # * DONT_SCAN_EVENTS
  136.   #--------------------------------------------------------------------------#
  137.   # Because events can either be allies or enemies, this tends to be a
  138.   # bit slow for each event, you can disable event scanning,
  139.   # so the events can only target the player.
  140.   #--------------------------------------------------------------------------#  
  141.     DONT_SCAN_EVENTS = true
  142.  
  143.   #--------------------------------------------------------------------------#
  144.   # * FULL_FIELD_SCAN
  145.   #--------------------------------------------------------------------------#
  146.   # *Warning this may cause Lag*
  147.   # Events will scan all around them for targets
  148.   # That means infront, behind, and beside
  149.   #--------------------------------------------------------------------------#  
  150.     FULL_FIELD_SCAN = true
  151.    
  152.   #--------------------------------------------------------------------------#
  153.   # * DIE_WAIT_TIME
  154.   #--------------------------------------------------------------------------#
  155.   # Time in frames for events to die.
  156.   # Default is 30
  157.   #--------------------------------------------------------------------------#  
  158.     DIE_WAIT_TIME = 30
  159.  
  160.   #--------------------------------------------------------------------------#
  161.   # * DRAW_RANGES
  162.   #--------------------------------------------------------------------------#
  163.   # Should the ranges for attacks/skills/etc be drawn?
  164.   #--------------------------------------------------------------------------#  
  165.     DRAW_RANGES = false
  166.    
  167.   #--------------------------------------------------------------------------#
  168.   # * ALL_DEAD_GAMEOVER
  169.   #--------------------------------------------------------------------------#
  170.   # >.> Quite Obviously you will set this to true..
  171.   # I don't even know why I made a constant for it anyway...
  172.   # When this is true, if all party members are dead, the Gameover will
  173.   # be triggered.
  174.   #--------------------------------------------------------------------------#  
  175.     ALL_DEAD_GAMEOVER = true  
  176.            
  177.   #--------------------------------------------------------------------------#
  178.   # * TOTAL_WILD_ANIMS
  179.   #--------------------------------------------------------------------------#
  180.   # In addition to each characters own animations, Yggdrasil has a wild anim
  181.   # set, where these animations are stand alone and can be triggered from
  182.   # anywhere on the map.
  183.   # Note greater numbers means more anims that can be shown at a time
  184.   # This will increase the number of updates and may result in Lagging.
  185.   # I reccomend keeping it around 8 to 16
  186.   #--------------------------------------------------------------------------#  
  187.     TOTAL_WILD_ANIMS = 16
  188.  
  189.   #--------------------------------------------------------------------------#
  190.   # * STATE_TURN_COUNTER
  191.   #--------------------------------------------------------------------------#
  192.   # This is used for state turns, in other words how many frames make a turn
  193.   # Default is 240
  194.   #--------------------------------------------------------------------------#
  195.     STATE_TURN_COUNTER = 480 #240
  196.  
  197.   #--------------------------------------------------------------------------#
  198.   # * SLIP_DAMAGE_FREQUENCY
  199.   #--------------------------------------------------------------------------#
  200.   # How often should slip damage occur
  201.   #--------------------------------------------------------------------------#
  202.     SLIP_DAMAGE_FREQUENCY = 5
  203.    
  204.   #--------------------------------------------------------------------------#
  205.   # * ACTION_BUTTONS
  206.   #--------------------------------------------------------------------------#
  207.   # Yggdrasil 1x6 uses unlimited buttons instead of 3 ( 1.0..1.5 series )
  208.   #--------------------------------------------------------------------------#
  209.     # // Jump to (YGG_PlayerInputConfig)
  210.    
  211.   #--------------------------------------------------------------------------#
  212.   # * TEXT_POP
  213.   #--------------------------------------------------------------------------#
  214.   # As of 1.6 TEXT POP is now built into the main script.
  215.   #--------------------------------------------------------------------------#  
  216.     USE_TEXT_POP = true
  217.     # Copied from BEM So you can recycle
  218.     POPUP_SETTINGS = {
  219.       :hp_dmg     => "%s",        # SprintF for HP damage.
  220.       :hp_heal    => "+%s",       # SprintF for HP healing.
  221.       :mp_dmg     => "%s SP",     # SprintF for MP damage.
  222.       :mp_heal    => "+%s SP",    # SprintF for MP healing.
  223.       :critical   => "CRITICAL!", # Text display for critical hit.
  224.       :missed     => "MISS",      # Text display for missed attack.
  225.       :evaded     => "EVADE!",    # Text display for evaded attack.
  226.       :nulled     => "NULLED",    # Text display for nulled attack.
  227.       :add_state  => "+%s",       # SprintF for added states.
  228.       :rem_state  => "-%s",       # SprintF for removed states.
  229.      
  230.       :exp_pop    => "Exp: %s",   # SprintF for Exp Pops.
  231.       :lvl_pop    => "Level %s",  # SprintF for Level Pops.
  232.       :guard      => "Guard!!!",
  233.     } # Do Not Remove
  234.    
  235.   #--------------------------------------------------------------------------#
  236.   # * POPUP_RULES
  237.   #--------------------------------------------------------------------------#
  238.   # Text Properties
  239.   # "Bold"      = Pop will be drawn Bold
  240.   # "Italic"    = Pop will be drawn with Italics
  241.   # "Shadow"    = Pop will be drawn with Shadows
  242.   # "No Bold"   = Pop will not be drawn Bold
  243.   # "No Italic" = Pop will not be drawn with Italics
  244.   # "No Shadow" = Pop will not be drawn with Shadow
  245.   #
  246.   # Font names is an array of font names (If the first one isn't present on
  247.   # the system, the next one is used, if non are present from the array
  248.   # the default is used)
  249.   #--------------------------------------------------------------------------#
  250.     COLOR_SETS = {#Ally                      Damage
  251.       :hp_no_dmg => [Color.new(180, 205, 180), Color.new(180, 205, 180)],
  252.       :hp_dmg    => [Color.new(128, 128, 240), Color.new(240, 128, 128)],
  253.       :hp_heal   => [Color.new(144, 238, 144), Color.new(198, 238, 144)],
  254.    
  255.       :mp_no_dmg => [Color.new(180, 180, 205), Color.new(180, 180, 205)],
  256.       :mp_dmg    => [Color.new(199, 21 , 112), Color.new(199, 21 , 112)],
  257.       :mp_heal   => [Color.new(173, 216, 230), Color.new(173, 216, 230)],
  258.     }
  259.    
  260.     POPUP_RULES = {
  261.     #                        
  262.    #"something"=> [fontsize, [color, color], [text_properties], [font_names]]
  263.       "HP_NO_DMG"=> [16, COLOR_SETS[:hp_no_dmg]  , [           ], [          ]],
  264.       "HP_DMG"   => [21, COLOR_SETS[:hp_dmg]     , [           ], [          ]],
  265.       "HP_HEAL"  => [21, COLOR_SETS[:hp_heal]    , ["Italic"   ], [          ]],
  266.    
  267.       "MP_NO_DMG"=> [16, COLOR_SETS[:mp_no_dmg]  , [           ], [          ]],
  268.       "MP_DMG"   => [21, COLOR_SETS[:mp_dmg]     , [           ], [          ]],
  269.       "MP_HEAL"  => [21, COLOR_SETS[:mp_heal]    , ["Italic"   ], [          ]],
  270.    
  271.       "MISSED"   => [19, Color.new(176, 196, 222), ["Italic"   ], [          ]],
  272.       "EVADED"   => [19, Color.new(198, 198, 198), ["Italic"   ], [          ]],
  273.       "NULLED"   => [19, Color.new(255, 160, 122), ["Bold"     ], [          ]],
  274.    
  275.       "ADD_STATE"=> [26, Color.new(255, 255, 224), ["No Shadow"], [          ]],
  276.       "REM_STATE"=> [26, Color.new(250, 250, 210), ["No Shadow"], [          ]],
  277.    
  278.       "EXP_POP"  => [18, Color.new(255, 215, 0  ), [           ], [          ]],
  279.       "LVL_POP"  => [21, Color.new(180, 215, 255), [           ], [          ]],
  280.    
  281.       "CRITICAL" => [24, Color.new(220, 20 , 60 ), ["Bold"     ], [          ]],
  282.      
  283.       "GUARD"    => [21, Color.new(198, 198, 202), ["Bold"     ], [          ]],
  284.     } # Do Not Remove
  285.    
  286.   #--------------------------------------------------------------------------#
  287.   # * CRITICAL_FONTSIZE_ADD
  288.   #--------------------------------------------------------------------------#
  289.   # When a critcial is done how much should be added to the Damage pop's
  290.   # font size
  291.   #--------------------------------------------------------------------------#
  292.     CRITICAL_FONTSIZE_ADD = 4
  293.    
  294.   #--------------------------------------------------------------------------#
  295.   # * SHOW_CRITICAL
  296.   #--------------------------------------------------------------------------#
  297.   # Should the "Critical" text be drawn when it is done?
  298.   #--------------------------------------------------------------------------#  
  299.     SHOW_CRITICAL = true
  300.  
  301.   #--------------------------------------------------------------------------#
  302.   # * SHOW_GUARD
  303.   #--------------------------------------------------------------------------#
  304.   # Should the "Guard" text be drawn when it is done?
  305.   #--------------------------------------------------------------------------#  
  306.     SHOW_GUARD = true
  307.    
  308.   #--------------------------------------------------------------------------#
  309.   # * LEVEL_UP_ALERT
  310.   #--------------------------------------------------------------------------#
  311.   # Should something happen on level up?
  312.   #--------------------------------------------------------------------------#
  313.     LEVEL_UP_ALERT = false
  314.    
  315.   #--------------------------------------------------------------------------#
  316.   # * ANIM_ON_LEVEL
  317.   #--------------------------------------------------------------------------#
  318.   # Animation used for level up. If set to 0, no anim is played
  319.   # This is disabled if LEVEL_UP_ALERT = false
  320.   #--------------------------------------------------------------------------#  
  321.     ANIM_ON_LEVEL = 0 # 257
  322.    
  323.   #--------------------------------------------------------------------------#
  324.   # * POP_LEVEL_UP
  325.   #--------------------------------------------------------------------------#
  326.   # Should a text pop with Level Up be used?
  327.   # This is disabled if LEVEL_UP_ALERT = false
  328.   #--------------------------------------------------------------------------#  
  329.     POP_LEVEL_UP = false
  330.  
  331.   #--------------------------------------------------------------------------#
  332.   # * POP_EXP
  333.   #--------------------------------------------------------------------------#
  334.   # Should a text pop be used for EXP?
  335.   #--------------------------------------------------------------------------#  
  336.     POP_EXP = true
  337.  
  338.   #--------------------------------------------------------------------------#
  339.   # * EXP_GAINING_METHOD
  340.   #--------------------------------------------------------------------------#
  341.   # 0 Dead   - When the target is defeated the character gains EXP
  342.   # 1 Per Hit- On every successful hit, exp is gained
  343.   #--------------------------------------------------------------------------#  
  344.     EXP_GAINING_METHOD = 0
  345.    
  346.   #--------------------------------------------------------------------------#
  347.   # * EXP_PER_HIT_FORMULA
  348.   #--------------------------------------------------------------------------#
  349.   # If you have no idea about scripting, don't touch this.
  350.   #--------------------------------------------------------------------------#  
  351.     EXP_PER_HIT_FORMULA = Proc.new { |damage, atker, defer| defer.exp * damage / defer.maxhp}
  352.    
  353.   #--------------------------------------------------------------------------#
  354.   # * EXP_SAHRE_METHOD
  355.   #--------------------------------------------------------------------------#
  356.   # 0 Active Member Only - Only the active member gains EXP
  357.   # 1 All Members Equal  - All members gain EXP
  358.   # 2 All Members Split  - The EXP is split amongst all Members
  359.   #--------------------------------------------------------------------------#  
  360.     # 0 Only Active Member, 1 All Members Equal, 2 All Members Spilt
  361.     EXP_SAHRE_METHOD = 1
  362.  
  363.   #--------------------------------------------------------------------------#
  364.   # * GOLD_DROP_ICON
  365.   #--------------------------------------------------------------------------#
  366.   # This is the icon that is used for gold drops
  367.   #--------------------------------------------------------------------------#
  368.     GOLD_DROP_ICON = 147
  369.    
  370.   #--------------------------------------------------------------------------#
  371.   # * DROP_SCATTER_DISTANCE
  372.   #--------------------------------------------------------------------------#
  373.   # This is how far a drop can be placed from its origin
  374.   #--------------------------------------------------------------------------#    
  375.     DROP_SCATTER_DISTANCE = 3
  376.    
  377.   #--------------------------------------------------------------------------#
  378.   # * ITEM_FADE_TIME
  379.   #--------------------------------------------------------------------------#
  380.   # How long, in frames until an item drop fades out
  381.   #--------------------------------------------------------------------------#    
  382.     ITEM_FADE_TIME = 480
  383.    
  384.   #--------------------------------------------------------------------------#
  385.   # * GOLD_FADE_TIME
  386.   #--------------------------------------------------------------------------#
  387.   # How long, in frames until an gold drop fades out
  388.   #--------------------------------------------------------------------------#    
  389.     GOLD_FADE_TIME = 640
  390.    
  391.   #--------------------------------------------------------------------------#
  392.   # * DROP_FADE_THRESHOLD
  393.   #--------------------------------------------------------------------------#
  394.   # When this frame is reached the drop will begin to fade out
  395.   #--------------------------------------------------------------------------#  
  396.     DROP_FADE_THRESHOLD = 60
  397.   #--------------------------------------------------------------------------#
  398.   # * USE_SHIFT_SYSTEM (YGG_ShiftSystem)
  399.   #--------------------------------------------------------------------------#
  400.   # Unlike its predecessors, 1.6 has a built-in Shift System
  401.   # This simply allows the quick changing between characters
  402.   #--------------------------------------------------------------------------#
  403.     USE_SHIFT_SYSTEM = false
  404.  
  405.   #--------------------------------------------------------------------------#
  406.   # * HUD
  407.   #--------------------------------------------------------------------------#
  408.   # Options for HUD
  409.   #--------------------------------------------------------------------------#
  410.     USE_HUD = true
  411.     HUD_SWITCH = 1
  412.    
  413.     HUD_POSITION_PROCS = {
  414.     # :symbol     => Proc.new { [   x,   y,   z] },
  415.       :main       => Proc.new { [ -12, Graphics.height-48, 1000] },
  416.       :back       => Proc.new { [   0,   0,   0] },
  417.       :hp_bar     => Proc.new { [ 232,  12,   3] },
  418.       :mp_bar     => Proc.new { [ 232,  28,   3] },
  419.       :exp_bar    => Proc.new { [  40,   9,   3] },
  420.       :shift_bar  => Proc.new { [ 384,   9,   3] },
  421.       :charge_bar => Proc.new { [ 472,   9,   3] },
  422.       :sprite     => Proc.new { [ 196,   8,   3] },
  423.       :skill_icon => Proc.new { |i| [  36 + i * 32,  16,   3] },
  424.       :item_icon  => Proc.new { |i| [ 376 + i * 32,  16,   3] }
  425.     }
  426.  
  427.   #--------------------------------------------------------------------------#
  428.   # * HP/MP Bars
  429.   #--------------------------------------------------------------------------#
  430.   # Options for HP/MP Bars
  431.   #--------------------------------------------------------------------------#
  432.     USE_STAT_BARS = true # // Use Bars?
  433.     USE_HPBAR     = true  
  434.     USE_MPBAR     = false
  435.  
  436.   #--------------------------------------------------------------------------#
  437.   # * DROPS_WINDOW (YGG_DropsWindow)
  438.   #--------------------------------------------------------------------------#
  439.   # Options for drops window
  440.   #--------------------------------------------------------------------------#
  441.     USE_DROPS_WINDOW    = true
  442.     # //                  [ x, y, z, width ]
  443.     DROPS_WINDOW_SIZE   = [ 544-164, 416-72, 200, 160 ]
  444.     DROPS_WINDOW_SWITCH = 1 # // Currently Linked with Hud
  445.    
  446.   #--------------------------------------------------------------------------#
  447.   # * DROPS_SFX (Special Thanks to Nicke (Niclas) for the idea)
  448.   #--------------------------------------------------------------------------#
  449.   # Options for SFX when a drop is taken up
  450.   # (You can override this using: <pickup sfx: filename, vol, pitch>)
  451.   #--------------------------------------------------------------------------#
  452.   # // Set any of these to nil to disable it                              // #
  453.     SOUND_MONEY = RPG::SE.new( "SYS-Shop002", 60, 100 )    # // Sound effect for acquiring money.
  454.     SOUND_ITEM  = RPG::SE.new( "XINFX-Pickup02", 50, 100 ) # // Sound effect for acquiring items.
  455.    
  456.   #--------------------------------------------------------------------------#
  457.   # * USE_LEVEL_UP_WINDOW (YGG_LevelUpWindow)
  458.   #--------------------------------------------------------------------------#
  459.   # 0 - No Window (OFF), 1 - Small Strip, 2 - Stop Frame Full Info
  460.   #--------------------------------------------------------------------------#
  461.     USE_LEVEL_UP_WINDOW = 0
  462.    
  463.   #--------------------------------------------------------------------------#
  464.   # * FULL_INTEGRATION
  465.   #--------------------------------------------------------------------------#
  466.   # Allow Yggdrasil to overwrite many core methods, to optimize is performance
  467.   #--------------------------------------------------------------------------#
  468.   # // Enabling this may cause normal battle operations to malfunction
  469.   # // This option is reccommend for a strict YGG game
  470.   #--------------------------------------------------------------------------#
  471.     FULL_INTEGRATION = true
  472.    
  473. # oo========================================================================oo #    
  474. # // Actions \\                                                             // #
  475. # oo========================================================================oo #
  476.   ACTION_LIST = {}
  477. # oo========================================================================oo #    
  478. # // Default Actions \\ DO NOT MESS WITH THESE                              // #
  479. # oo========================================================================oo #
  480.  
  481. # oo========================================================================oo #    
  482. # // Normal Attack # For Default
  483.   ACTION_LIST["NULL_ACTION"] = []
  484.  
  485.   ACTION_LIST["NORMAL_ATTACK"] = [
  486.     ["RANGE"        , ["ADD", 0, 1]                   ],
  487.     ["TARGET"       , ["RANGE"]                       ],
  488.     ["SUBTARGET"    , ["ALLIES"]                      ],
  489.     ["ANIMATION"    , ["ATTACK", "POS", "WILD", 0, 1] ],
  490.     ["ATTACK EFFECT", ["USER", "TARGETS"]             ]
  491.   ]
  492.  
  493.   ACTION_LIST["GUARD_ACTION"] = [
  494.     ["ANIMATION"    , [85, "USER", "WILD"]            ],
  495.     ["GUARD"    , [3]                                 ], # // Set Guard for 3 frames
  496.   ]
  497.  
  498.   ACTION_LIST["ESCAPE_ACTION"] = [
  499.   ]
  500.  
  501.   ACTION_LIST["WAIT_ACTION"] = [
  502.     ["PARENT WAIT"  , [20]                            ]
  503.   ]
  504.  
  505. # oo========================================================================oo #    
  506. # // Normal Attack # For Enemies  
  507.   ACTION_LIST["NULL_ACTION_EN"] = [] # // Unused D:
  508.  
  509.   ACTION_LIST["NORMAL_ATTACK_EN"] = [
  510.     ["RANGE"        , ["ADD", 0, 1]                   ],
  511.     ["TARGET"       , ["RANGE"]                       ],
  512.     ["SUBTARGET"    , ["ALLIES"]                      ],
  513.     ["ANIMATION"    , ["ATTACK", "POS", "WILD", 0, 1] ],
  514.     ["ATTACK EFFECT", ["USER", "TARGETS"]             ]
  515.   ]
  516.  
  517.   ACTION_LIST["GUARD_ACTION_EN"] = [
  518.     ["GUARD"    , [3]                                 ], # // Set Guard for 3 frames
  519.   ]
  520.  
  521.   ACTION_LIST["ESCAPE_ACTION_EN"] = [
  522.   ]
  523.  
  524.   ACTION_LIST["WAIT_ACTION_EN"] = [
  525.     ["PARENT WAIT"  , [20]                            ]
  526.   ]
  527. # oo========================================================================oo #    
  528. # // Skill Scopes                                                           // #
  529.   # // None Scope Skill
  530.   ACTION_LIST["NORMAL_OBJ0"] = [
  531.     ["TARGET"      , ["USER"]                      ],
  532.     ["ANIMATION"   , ["OBJ", "POS", "WILD", 0, 0]  ],
  533.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  534.   ]
  535.  
  536.   # // User Skill
  537.   ACTION_LIST["NORMAL_OBJ1"] = [
  538.     ["TARGET"      , ["USER"]                      ],
  539.     ["ANIMATION"   , ["OBJ", "POS", "WILD", 0, 0]  ],
  540.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  541.   ]
  542.  
  543.   # // Enemy Skill Single
  544.   ACTION_LIST["NORMAL_OBJ2_1"] = [
  545.     ["RANGE"       , ["ADD", 0, 1]                 ],
  546.     ["TARGET"      , ["RANGE"]                     ],
  547.     ["SUBTARGET"   , ["ALLIES"]                    ],
  548.     ["ANIMATION"   , ["OBJ", "POS", "WILD", 0, 1]  ],
  549.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  550.   ]
  551.  
  552.   # // Enemy Skill Dual
  553.   ACTION_LIST["NORMAL_OBJ2_2"] = [
  554.     ["RANGE"       , ["ADD", 0, 1]                 ],
  555.     ["TARGET"      , ["RANGE"]                     ],
  556.     ["SUBTARGET"   , ["ALLIES"]                    ],
  557.     ["ANIMATION"   , ["OBJ", "POS", "WILD", 0, 1]  ],
  558.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  559.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  560.   ]
  561.  
  562.   # // Enemy Skill Triple
  563.   ACTION_LIST["NORMAL_OBJ2_3"] = [
  564.     ["RANGE"       , ["ADD", 0, 1]                 ],
  565.     ["TARGET"      , ["RANGE"]                     ],
  566.     ["SUBTARGET"   , ["ALLIES"]                    ],
  567.     ["ANIMATION"   , ["OBJ", "POS", "WILD", 0, 1]  ],
  568.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  569.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  570.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  571.   ]
  572.  
  573.   # // Enemy Skill Random 1
  574.   ACTION_LIST["NORMAL_OBJ2_R1"] = [
  575.     ["TARGET"      , ["SCREEN"]                    ],
  576.     ["SUBTARGET"   , ["ALLIES"]                    ],
  577.     ["TARGET"      , ["RANDTARGET"]                ],
  578.     ["ANIMATION"   , ["OBJ", "TARGET", "WILD"]     ],
  579.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  580.   ]
  581.  
  582.   # // Enemy Skill Random 2
  583.   ACTION_LIST["NORMAL_OBJ2_R2"] = [
  584.     ["ACTION", ["NORMAL_OBJ2_R1"] ],
  585.     ["ACTION", ["NORMAL_OBJ2_R1"] ]
  586.   ]
  587.  
  588.   # // Enemy Skill Random 3
  589.   ACTION_LIST["NORMAL_OBJ2_R3"] = [
  590.     ["ACTION", ["NORMAL_OBJ2_R1"] ],
  591.     ["ACTION", ["NORMAL_OBJ2_R1"] ],
  592.     ["ACTION", ["NORMAL_OBJ2_R1"] ]
  593.   ]
  594.  
  595.   # // Ally Skill
  596.   ACTION_LIST["NORMAL_OBJ3_1"] = [
  597.     ["RANGE"       , ["ADD", 0, 1]                 ],
  598.     ["TARGET"      , ["RANGE"]                     ],
  599.     ["SUBTARGET"   , ["ENEMIES"]                   ],
  600.     ["ANIMATION"   , ["OBJ", "POS", "WILD", 0, 1]  ],
  601.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  602.   ]
  603.  
  604.   # // Ally Skill Dual
  605.   ACTION_LIST["NORMAL_OBJ3_2"] = [
  606.     ["RANGE"       , ["ADD", 0, 1]                 ],
  607.     ["TARGET"      , ["RANGE"]                     ],
  608.     ["SUBTARGET"   , ["ENEMIES"]                   ],
  609.     ["ANIMATION"   , ["OBJ", "POS", "WILD", 0, 1]  ],
  610.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  611.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  612.   ]
  613.  
  614.   # // Ally Skill Triple
  615.   ACTION_LIST["NORMAL_OBJ3_3"] = [
  616.     ["RANGE"       , ["ADD", 0, 1]                 ],
  617.     ["TARGET"      , ["RANGE"]                     ],
  618.     ["SUBTARGET"   , ["ENEMIES"]                   ],
  619.     ["ANIMATION"   , ["OBJ", "POS", "WILD", 0, 1]  ],
  620.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  621.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  622.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  623.   ]
  624.  
  625.   # // Ally Skill Random 1
  626.   ACTION_LIST["NORMAL_OBJ3_R1"] = [
  627.     ["TARGET"      , ["SCREEN"]                    ],
  628.     ["SUBTARGET"   , ["ENEMIES"]                   ],
  629.     ["TARGET"      , ["RANDTARGET"]                ],
  630.     ["ANIMATION"   , ["OBJ", "TARGET", "WILD"]     ],
  631.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  632.   ]
  633.  
  634.   # // Ally Obj Random 2
  635.   ACTION_LIST["NORMAL_OBJ3_R2"] = [
  636.     ["ACTION", ["NORMAL_OBJ3_R1"] ],
  637.     ["ACTION", ["NORMAL_OBJ3_R1"] ],
  638.   ]
  639.  
  640.   # // Enemy Obj Random 3
  641.   ACTION_LIST["NORMAL_OBJ3_R3"] = [
  642.     ["ACTION", ["NORMAL_OBJ3_R1"] ],
  643.     ["ACTION", ["NORMAL_OBJ3_R1"] ],
  644.     ["ACTION", ["NORMAL_OBJ3_R1"] ],
  645.   ]
  646.  
  647.   # // All Enemies
  648.   ACTION_LIST["NORMAL_OBJ4"] = [
  649.     ["TARGET"      , ["SCREEN"]                    ],
  650.     ["SUBTARGET"   , ["ALLIES"]                    ],
  651.     ["ANIMATION"   , ["OBJ", "TARGETS", "WILD"]    ],
  652.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  653.   ]
  654.  
  655.   # // All Allies
  656.   ACTION_LIST["NORMAL_OBJ5"] = [
  657.     ["TARGET"      , ["SCREEN"]                    ],
  658.     ["SUBTARGET"   , ["ENEMIES"]                   ],
  659.     ["ANIMATION"   , ["OBJ", "TARGETS", "WILD"]    ],
  660.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  661.   ]
  662.  
  663.   # // Target Enemy Skill Single
  664.   ACTION_LIST["NORMAL_OBJ2_T1"] = [
  665.     ["TARGET"      , ["SCREEN"]                    ],
  666.     ["SUBTARGET"   , ["ALLIES"]                    ],
  667.     ["TARGET SELECT",[1, "TARGETS"]                ],
  668.     ["ANIMATION"   , ["OBJ", "TARGETS", "WILD"]    ],
  669.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  670.   ]
  671.  
  672.   # // Target Enemy Skill Dual
  673.   ACTION_LIST["NORMAL_OBJ2_T2"] = [
  674.     ["TARGET"      , ["SCREEN"]                    ],
  675.     ["SUBTARGET"   , ["ALLIES"]                    ],
  676.     ["TARGET SELECT",[1, "TARGETS"]                ],
  677.     ["ANIMATION"   , ["OBJ", "TARGETS", "WILD"]    ],
  678.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  679.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  680.   ]
  681.  
  682.   # // Target Enemy Skill Triple
  683.   ACTION_LIST["NORMAL_OBJ2_T3"] = [
  684.     ["TARGET"      , ["SCREEN"]                    ],
  685.     ["SUBTARGET"   , ["ALLIES"]                    ],
  686.     ["TARGET SELECT",[1, "TARGETS"]                ],
  687.     ["ANIMATION"   , ["OBJ", "TARGETS", "WILD"]    ],
  688.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  689.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  690.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  691.   ]
  692.  
  693.   # // Target Ally Skill
  694.   ACTION_LIST["NORMAL_OBJ3_T1"] = [
  695.     ["TARGET"      , ["SCREEN"]                    ],
  696.     ["SUBTARGET"   , ["ENEMIES"]                   ],
  697.     ["TARGET SELECT",[1, "TARGETS"]                ],
  698.     ["ANIMATION"   , ["OBJ", "TARGETS", "WILD"]    ],
  699.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  700.   ]
  701.  
  702.   # // Target Ally Skill Dual
  703.   ACTION_LIST["NORMAL_OBJ3_T2"] = [
  704.     ["TARGET"      , ["SCREEN"]                    ],
  705.     ["SUBTARGET"   , ["ENEMIES"]                   ],
  706.     ["TARGET SELECT",[1, "TARGETS"]                ],
  707.     ["ANIMATION"   , ["OBJ", "TARGETS", "WILD"]    ],
  708.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  709.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  710.   ]
  711.  
  712.   # // Target Ally Skill Triple
  713.   ACTION_LIST["NORMAL_OBJ3_T3"] = [
  714.     ["TARGET"      , ["SCREEN"]                    ],
  715.     ["SUBTARGET"   , ["ENEMIES"]                   ],
  716.     ["TARGET SELECT",[1, "TARGETS"]                ],
  717.     ["ANIMATION"   , ["OBJ", "TARGETS", "WILD"]    ],
  718.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  719.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  720.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  721.   ]
  722.  
  723.   # // Breath all targets in range
  724.   ACTION_LIST["BREATH_ATTACK1"] = [
  725.     ["RANGE"       , ["CREATE", 3, 0, 3, 2]        ], # // Point Range downward
  726.     ["TARGET"      , ["RANGE"]                     ], # // Get all targets within range
  727.     ["ANIMATION"   , ["OBJ", "POS", 0, 1]          ], # // Show animation infront
  728.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ], # // Object Damage
  729.   ]
  730.  
  731. # oo========================================================================oo #    
  732. # \\ End Default Actions //                                                 // #
  733. # oo========================================================================oo #
  734. #==============================================================================#
  735. #                           End Customization
  736. #------------------------------------------------------------------------------#
  737. #==============================================================================#  
  738. end
  739. #==============================================================================#
  740. # ** YGG # // Forward Declarations
  741. #==============================================================================#
  742. module YGG
  743. #==============================================================================#
  744. # ** Handlers
  745. #==============================================================================#
  746.   module Handlers   ; end
  747. #==============================================================================#
  748. # ** Containers
  749. #==============================================================================#    
  750.   module Containers ; end
  751. #==============================================================================#
  752. # ** MixIns
  753. #==============================================================================#    
  754.   module MixIns     ; end
  755. #==============================================================================#
  756. # ** Objects
  757. #==============================================================================#        
  758.   module Objects    ; end      
  759. #==============================================================================#
  760. # ** Scenes
  761. #==============================================================================#            
  762.   module Scenes     ; end  
  763. #==============================================================================#
  764. # ** Sprites
  765. #==============================================================================#        
  766.   module Sprites    ; end  
  767. #==============================================================================#
  768. # ** REGEXP
  769. #==============================================================================#            
  770.   module REGEXP     ; end
  771. #==============================================================================#
  772. # ** Windows
  773. #==============================================================================#                
  774.   module Windows    ; end  
  775. #==============================================================================#
  776. # ** Pos
  777. #==============================================================================#                
  778.   class Pos ; end
  779. #==============================================================================#
  780. # ** Handlers::Screen
  781. #==============================================================================#    
  782.   class Handlers::Screen < Pos ; end
  783. #==============================================================================#
  784. # ** Objects::Projectiles
  785. #==============================================================================#      
  786.   module Objects::Projectiles ; end
  787. #==============================================================================#
  788. # ** Random
  789. #==============================================================================#
  790.   module Random
  791.    
  792.   #--------------------------------------------------------------------------#
  793.   # * new-method :min_max
  794.   #--------------------------------------------------------------------------#      
  795.     def self.min_max( min, max )
  796.       return min + rand( max - min )
  797.     end
  798.    
  799.   #--------------------------------------------------------------------------#
  800.   # * new-method :variation
  801.   #--------------------------------------------------------------------------#        
  802.     def self.variation( value, percent )
  803.       new_value = rand(Integer(value * percent / 100.0))
  804.       new_value = value + (rand(2) == 0 ? new_value : -new_value)
  805.       return new_value
  806.     end
  807.    
  808.   end
  809. end    
  810.  
  811. #==============================================================================#  
  812. # ** Input # // DONT MESS WITH THIS
  813. #==============================================================================#
  814. module Input
  815.   #--------------------------------------------------------------------------#
  816.   # * Constants - Created by OriginalWij and Yanfly
  817.   #--------------------------------------------------------------------------#
  818.   LETTERS = {}        
  819.   LETTERS['A'] = 65; LETTERS['B'] = 66; LETTERS['C'] = 67; LETTERS['D'] = 68
  820.   LETTERS['E'] = 69; LETTERS['F'] = 70; LETTERS['G'] = 71; LETTERS['H'] = 72
  821.   LETTERS['I'] = 73; LETTERS['J'] = 74; LETTERS['K'] = 75; LETTERS['L'] = 76
  822.   LETTERS['M'] = 77; LETTERS['N'] = 78; LETTERS['O'] = 79; LETTERS['P'] = 80
  823.   LETTERS['Q'] = 81; LETTERS['R'] = 82; LETTERS['S'] = 83; LETTERS['T'] = 84
  824.   LETTERS['U'] = 85; LETTERS['V'] = 86; LETTERS['W'] = 87; LETTERS['X'] = 88
  825.   LETTERS['Y'] = 89; LETTERS['Z'] = 90
  826.   NUMBERS = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57]
  827.   NUMPAD = [96, 97, 98, 99, 100, 101, 102, 103, 104, 105]
  828.   BACK   = 138; ENTER  = 143; SPACE  = 32;  SCOLON = 186; ESC    = 157
  829.   QUOTE  = 222; EQUALS = 187; COMMA  = 188; USCORE = 189; PERIOD = 190
  830.   SLASH  = 191; LBRACE = 219; RBRACE = 221; BSLASH = 220; TILDE  = 192
  831.   F10    = 121; F11    = 122; CAPS   = 20;  NMUL   = 106; NPLUS  = 107
  832.   NSEP   = 108; NMINUS = 109; NDECI  = 110; NDIV   = 111; Extras =
  833.   [USCORE, EQUALS, LBRACE, RBRACE, BSLASH, SCOLON, QUOTE, COMMA, PERIOD, SLASH,
  834.    NMUL, NPLUS, NSEP, NMINUS, NDECI, NDIV]
  835. end
  836.  
  837. #==============================================================================#
  838. # ** YGG::MixIns::Player (YGG_PlayerInputConfig)
  839. #==============================================================================#
  840. module YGG::MixIns::Player
  841.  
  842.   #--------------------------------------------------------------------------#
  843.   # * new-method :get_obj_actions
  844.   #--------------------------------------------------------------------------#  
  845.   def get_obj_actions( obj, id )
  846.     return [],[] if obj.nil?()
  847.     return obj.ygg_actions[id].to_a(), obj.ygg_pre_actions[id].to_a()
  848.   end
  849.  
  850.   #--------------------------------------------------------------------------#
  851.   # * new-method :ygg_attack_input
  852.   #--------------------------------------------------------------------------#
  853.   def ygg_attack_input()
  854.     #return unless ygg_can_attack?()
  855.     return if $game_map.interpreter.running?()
  856.     return if ygg_battler.nil?()
  857.     if @guard_time > 0
  858.       @guard_time += 1 if Input.press?( Input::LETTERS["D"] )
  859.       return
  860.     end  
  861.     return if @action_handle.busy?()
  862.     acthand_ret = ygg_attack_input1()              # // ASD Input
  863.     acthand_ret = ygg_attack_input2( acthand_ret ) # // Skill Input 1..5
  864.     ygg_attack_input3( acthand_ret )               # // Item Input 6..9 and 0
  865.   end
  866.  
  867.   #--------------------------------------------------------------------------#
  868.   # * new-method :ygg_attack_input1
  869.   #--------------------------------------------------------------------------#
  870.   def ygg_attack_input1()
  871.     act, pact = nil, nil
  872.     obj = nil
  873.     if Input.trigger?( Input::LETTERS["A"] )
  874.       return 0 unless ygg_battler.ygg_can_attack?()
  875.       obj = ygg_battler.weapons[0]
  876.       act, pact = *get_obj_actions( obj, 1 )
  877.     elsif Input.trigger?( Input::LETTERS["S"] ) && ygg_battler.two_swords_style  
  878.       return 0 unless ygg_battler.ygg_can_attack?()
  879.       obj = ygg_battler.weapons[1]
  880.       act, pact = *get_obj_actions( obj, 1 )
  881.     elsif Input.press?( Input::LETTERS["D"] ) && !ygg_battler.two_swords_style  
  882.       return 0 unless ygg_battler.ygg_can_attack?()
  883.       obj = ygg_battler.armors[0]
  884.       act, pact = *get_obj_actions( obj, 0 )
  885.     end  
  886.     return 0 if act.nil?() || pact.nil?()
  887.     return 0 if act.empty?() && pact.empty?()
  888.     if pact.empty?()
  889.       @action_handle.setup( act )
  890.     else  
  891.       @action_handle.list_stack << act
  892.       @action_handle.setup( pact )
  893.     end  
  894.     @action_handle.execute( self )
  895.     ygg_battler.cooldown += obj.user_charge_cap
  896.     return 1
  897.   end
  898.  
  899.   #--------------------------------------------------------------------------#
  900.   # * new-method :ygg_attack_input2
  901.   #--------------------------------------------------------------------------#
  902.   def ygg_attack_input2( acthand_ret )
  903.     for i in 1..5
  904.       act, pact, obj = nil, nil, nil
  905.       if Input.trigger?( Input::NUMBERS[i] )
  906.         slot_id = i-1
  907.         obj = ygg_battler.skill_slot( slot_id )
  908.         next unless ygg_battler.ygg_skill_can_use?( obj )
  909.         act, pact = *get_obj_actions( obj, 0 )
  910.       end
  911.       next if act.nil?() || pact.nil?() || obj.nil?()
  912.       next if act.empty?() && pact.empty?()
  913.       next unless skill_can_use?( obj )
  914.       if pact.empty?()
  915.         hnd = ::YGG::Handlers::Action.new( self, [] ) ; hnd.setup( act )
  916.         hnd.execute( self, [], { :skill_id => obj.id } )
  917.         @free_act_handles << hnd
  918.       else  
  919.         next if acthand_ret == 1
  920.         @action_handle.list_stack << act
  921.         @action_handle.setup( pact )
  922.         @action_handle.execute( self, [], { :skill_id => obj.id } )
  923.         acthand_ret = 1
  924.       end  
  925.       ygg_battler.get_skill_handle( obj.id ).reset_time()
  926.       ygg_battler.cooldown += obj.user_charge_cap
  927.       ygg_battler.ygg_use_skill( obj )
  928.     end  
  929.     return acthand_ret
  930.   end
  931.  
  932.   #--------------------------------------------------------------------------#
  933.   # * new-method :ygg_attack_input3
  934.   #--------------------------------------------------------------------------#
  935.   def ygg_attack_input3( acthand_ret )
  936.     for i in (6..9).to_a+[0]
  937.       act, pact, obj = nil, nil, nil
  938.       if Input.trigger?( Input::NUMBERS[i] )
  939.         slot_id = i==0 ? 10-6 : i-6
  940.         obj = ygg_battler.item_slot( slot_id )
  941.         next unless ygg_battler.ygg_item_can_use?( obj )
  942.         act, pact = *get_obj_actions( obj, 0 )
  943.       end
  944.       next if act.nil?() || pact.nil?() || obj.nil?()
  945.       next if act.empty?() && pact.empty?()
  946.       next unless item_can_use?( obj )
  947.       if pact.empty?()
  948.         hnd = ::YGG::Handlers::Action.new( self, [] ) ; hnd.setup( act )
  949.         hnd.execute( self, [], { :item_id => obj.id } )
  950.         @free_act_handles << hnd
  951.       else  
  952.         next if acthand_ret == 1
  953.         @action_handle.list_stack << act
  954.         @action_handle.setup( pact )
  955.         @action_handle.execute( self, [], { :item_id => obj.id } )
  956.         acthand_ret = 1
  957.       end  
  958.       ygg_battler.get_item_handle( obj.id ).reset_time()
  959.       ygg_battler.cooldown += obj.user_charge_cap
  960.       ygg_battler.ygg_use_item( obj )
  961.     end  
  962.     return acthand_ret
  963.   end
  964.  
  965.   #--------------------------------------------------------------------------#
  966.   # * new-method :skill_can_use?
  967.   #--------------------------------------------------------------------------#  
  968.   def skill_can_use?( obj )
  969.     return false if obj.nil?()
  970.     return false if ygg_battler.nil?()
  971.     return ygg_battler.skill_can_use?( obj )
  972.   end
  973.  
  974.   #--------------------------------------------------------------------------#
  975.   # * new-method :item_can_use?
  976.   #--------------------------------------------------------------------------#  
  977.   def item_can_use?( obj )
  978.     return false if obj.nil?()
  979.     return false if ygg_battler.nil?()
  980.     return $game_party.item_can_use?( obj )
  981.   end
  982.  
  983. end  
  984.  
  985. # // (YGG_AIEngine_Setup)
  986. #==============================================================================#
  987. # ** YGG::Handlers::AIEngines
  988. #==============================================================================#
  989. module YGG::Handlers::AIEngines
  990. #==============================================================================#
  991. # ** Base (Forward Declaration)
  992. #==============================================================================#  
  993.   class Base           ; end
  994. #==============================================================================#
  995. # ** Default (Forward Declaration)
  996. #==============================================================================#      
  997.   class Default < Base ; end
  998. #==============================================================================#
  999. # ** Guard (Forward Declaration)
  1000. #==============================================================================#      
  1001.   class Guard < Base   ; end
  1002. #==============================================================================#
  1003. # ** Wall (Forward Declaration)
  1004. #==============================================================================#      
  1005.   class Wall < Base    ; end  
  1006. #==============================================================================#
  1007. # ** ImmortalVarBoss (Forward Declaration)
  1008. #==============================================================================#          
  1009.   class ImmortalVarBoss < Base  ; end
  1010.    
  1011.   #--------------------------------------------------------------------------#
  1012.   # * ENGINES
  1013.   #--------------------------------------------------------------------------#
  1014.   # This hash contains references to the Engine's Class, NOT AN INSTANCE
  1015.   # of the class.
  1016.   #--------------------------------------------------------------------------#  
  1017.   ENGINES = {
  1018.     # // Default AI that uses the Game_Battler's make_action
  1019.     # // to attack
  1020.     "default" => Default,         # // Default (Make Action) AI
  1021.     # // An AI that only attacks/moves/acts when an enemy enters its field
  1022.     "guard"   => Guard,           # // Specialized AI
  1023.     # // An AI that does nothing, but its HP slowly depletes
  1024.     "wall"    => Wall,            
  1025.     # // An invincible boss, thats hp is controlled by a variable
  1026.     # // This is a 2nd level subclass
  1027.     "ivboss"  => ImmortalVarBoss,
  1028.   }
  1029.  
  1030. end
  1031.  
  1032. #==============================================================================#
  1033. # ** YGG::AI_ENGINES
  1034. #==============================================================================#
  1035. YGG::AI_ENGINES = YGG::Handlers::AIEngines::ENGINES
  1036.  
  1037. #==============================================================================#
  1038. # ** YGG::Handlers::AIEngines::Base
  1039. #==============================================================================#
  1040. class YGG::Handlers::AIEngines::Base
  1041.  
  1042.   #--------------------------------------------------------------------------#
  1043.   # * Public Instance Variables
  1044.   #--------------------------------------------------------------------------#  
  1045.   attr_accessor :parent
  1046.  
  1047.   #--------------------------------------------------------------------------#
  1048.   # * new-method :initialize
  1049.   #--------------------------------------------------------------------------#  
  1050.   def initialize( parent, setup_data={} )
  1051.     @parent = parent
  1052.     @update_time = 0
  1053.   end
  1054.  
  1055.   #--------------------------------------------------------------------------#
  1056.   # * new-method :pause
  1057.   #--------------------------------------------------------------------------#  
  1058.   def pause()
  1059.     @paused = true
  1060.   end
  1061.  
  1062.   #--------------------------------------------------------------------------#
  1063.   # * new-method :unpause
  1064.   #--------------------------------------------------------------------------#  
  1065.   def unpause()
  1066.     @paused = false
  1067.   end
  1068.  
  1069.   #--------------------------------------------------------------------------#
  1070.   # * new-method :update
  1071.   #--------------------------------------------------------------------------#  
  1072.   def update()
  1073.     return if @paused
  1074.     return if @parent.guard_time > 0
  1075.     @update_time = [@update_time - 1, 0].max
  1076.     ai_update() if @update_time == 0
  1077.   end
  1078.  
  1079. end  
  1080.  
  1081. #==============================================================================#
  1082. # ** YGG::Handlers::AIEngines::Default
  1083. #==============================================================================#
  1084. class YGG::Handlers::AIEngines::Default
  1085.  
  1086.   #--------------------------------------------------------------------------#
  1087.   # * super-method :initialize
  1088.   #--------------------------------------------------------------------------#
  1089.   def initialize( parent, setup_data={} )
  1090.     super( parent, setup_data )
  1091.     @update_time_cap = (setup_data["update_time"] || 90).to_i
  1092.   end
  1093.  
  1094.   #--------------------------------------------------------------------------#
  1095.   # * new-method :ai_update
  1096.   #--------------------------------------------------------------------------#  
  1097.   def ai_update()
  1098.     #return # // Remove this later
  1099.     return if @parent.ygg_battler.cooldown > 0
  1100.     return if @parent.ygg_battler.nil?()  
  1101.     @parent.ygg_battler.make_action()
  1102.     case @parent.ygg_battler.action.kind
  1103.     when 0 # // Basic
  1104.       case @parent.ygg_battler.action.basic
  1105.       when 0 # // Attack      
  1106.         @update_time = @update_time_cap / 3
  1107.         t = @parent.get_targets_nearby( 1, @parent.ygg_correct_target( "ENEMY" ) )
  1108.         return @update_time = @update_time_cap / 4 if t[0].nil?()
  1109.         @parent.turn_to_coord( t[0].x, t[0].y )
  1110.         @parent.action_handle.setup( @parent.ygg_battler.get_action_by_id( 0 ) )
  1111.         @parent.action_handle.execute( @parent )
  1112.       when 1 # // Guard
  1113.         @parent.action_handle.setup( @parent.ygg_battler.get_action_by_id( 1 ) )
  1114.         @parent.action_handle.execute( @parent )
  1115.       when 2 # // Escape
  1116.         @parent.action_handle.setup( @parent.ygg_battler.get_action_by_id( 2 ) )
  1117.         @parent.action_handle.execute( @parent )
  1118.       when 3 # // Wait  
  1119.         @parent.action_handle.setup( @parent.ygg_battler.get_action_by_id( 3 ) )
  1120.         @parent.action_handle.execute( @parent )
  1121.       end  
  1122.     when 1 # // Skill
  1123.       obj = $data_skills[@parent.ygg_battler.action.skill_id]
  1124.       next unless @parent.ygg_battler.ygg_skill_can_use?( obj )
  1125.       if obj.for_opponent?()
  1126.         t = @parent.get_targets_nearby( 1, @parent.ygg_correct_target( "ENEMY" ) )
  1127.       elsif obj.for_friend?()  
  1128.         t = @parent.get_targets_nearby( 1, @parent.ygg_correct_target( "ALLY" ) )
  1129.       else  
  1130.         t = @parent.get_targets_nearby( 1, "ALL" )
  1131.       end  
  1132.       return @update_time = @update_time_cap / 4 if t[0].nil?()
  1133.       @parent.ygg_battler.ygg_use_skill( obj )
  1134.       @parent.turn_to_coord( t[0].x, t[0].y )
  1135.       @parent.action_handle.setup( obj.ygg_actions[0] )
  1136.       @parent.action_handle.execute( @parent, [],
  1137.         { :skill_id=> @parent.ygg_battler.action.skill_id } )
  1138.     when 2 # // Item Enemies cant use items
  1139.     end  
  1140.     @update_time = @update_time_cap
  1141.   end
  1142.  
  1143. end  
  1144.  
  1145. #==============================================================================#
  1146. # ** YGG::Handlers::AIEngines::Guard
  1147. #==============================================================================#
  1148. class YGG::Handlers::AIEngines::Guard
  1149.  
  1150.   #--------------------------------------------------------------------------#
  1151.   # * super-method :initialize
  1152.   #--------------------------------------------------------------------------#  
  1153.   def initialize( parent, setup_data={} )
  1154.     sd = setup_data
  1155.     super( parent, sd )
  1156.     setup_area( sd )
  1157.     @update_time_cap = (sd["update_time"] || 90).to_i
  1158.     @__temprect = []
  1159.   end
  1160.  
  1161.   #--------------------------------------------------------------------------#
  1162.   # * new-method :setup_area
  1163.   #--------------------------------------------------------------------------#  
  1164.   def setup_area( setup_data={} )
  1165.     # // area_id (id)
  1166.     @prox = setup_data["proxy_area"].to_i == 1
  1167.     if !setup_data["area_id"].nil?()
  1168.       @guard_area = Rect.new( *$data_areas[setup_data["area_id"].to_i].rect.to_a )
  1169.     # // area_x (center), area_y (center), area_range (center, relative side)
  1170.     elsif !setup_data["area_range"].nil?()
  1171.       ax  = (!setup_data["area_x"].nil?()) ? setup_data["area_x"].to_i : 0
  1172.       ay  = (!setup_data["area_y"].nil?()) ? setup_data["area_y"].to_i : 0
  1173.       rng = (!setup_data["area_range"].nil?()) ? setup_data["area_range"].to_i : 0
  1174.       @guard_area = Rect.new( ax-rng, ay-rng, rng*2, rng*2 )
  1175.     # // area_x (left), area_y (left), area_width (left), area_height (left)    
  1176.     else  
  1177.       @guard_area = Rect.new(
  1178.         (!setup_data["area_x"].nil?()) ? setup_data["area_x"].to_i : 0,
  1179.         (!setup_data["area_y"].nil?()) ? setup_data["area_y"].to_i : 0,
  1180.         (!setup_data["area_width"].nil?()) ? setup_data["area_width"].to_i : 0,
  1181.         (!setup_data["area_height"].nil?()) ? setup_data["area_height"].to_i : 0
  1182.       )
  1183.     end
  1184.     @__guardarea_data ||= {} ; @__guardarea_data.clear()
  1185.     @__guardarea_data["proxy_area"]  = setup_data["proxy_area"]
  1186.     @__guardarea_data["area_id"]     = setup_data["area_id"]
  1187.     @__guardarea_data["area_range"]  = setup_data["area_range"]
  1188.     @__guardarea_data["area_x"]      = setup_data["area_x"]
  1189.     @__guardarea_data["area_y"]      = setup_data["area_y"]
  1190.     @__guardarea_data["area_width"]  = setup_data["area_width"]
  1191.     @__guardarea_data["area_height"] = setup_data["area_height"]
  1192.   end
  1193.  
  1194.   #--------------------------------------------------------------------------#
  1195.   # * new-method :reset_area
  1196.   #--------------------------------------------------------------------------#  
  1197.   def reset_area()
  1198.     setup_area( @__guardarea_data )
  1199.   end
  1200.  
  1201.   #--------------------------------------------------------------------------#
  1202.   # * new-method :ai_update
  1203.   #--------------------------------------------------------------------------#  
  1204.   def ai_update()
  1205.     return if @parent.ygg_battler.nil?()
  1206.     @__temprect = @guard_area.to_vector4_a()
  1207.     @__temprect[0] += @prox ? @parent.x : 0
  1208.     @__temprect[1] += @prox ? @parent.y : 0
  1209.     @__temprect[2] += @prox ? @parent.x : 0
  1210.     @__temprect[3] += @prox ? @parent.y : 0
  1211.     bats = $game_yggdrasil.battlers_range( *@__temprect )  
  1212.     unless bats.empty?()
  1213.       bats -= [@parent]
  1214.       unless bats.empty?()
  1215.         @parent.balloon_id = 1
  1216.         pro = Projectiles::Homing.new( @parent,
  1217.           ::YGG::PROJETILE_SETUP["ProjectileTest"].merge(
  1218.             { :target => bats[rand(bats.size)] } )
  1219.         )    
  1220.         pro.moveto( @parent.x, @parent.y ) ; pro.set_direction( @parent.direction )
  1221.         $game_yggdrasil.add_projectile( pro )
  1222.       end  
  1223.     end  
  1224.     @update_time = @update_time_cap
  1225.   end
  1226.  
  1227. end  
  1228.  
  1229. #==============================================================================#
  1230. # ** YGG::Handlers::AIEngines::Wall
  1231. #==============================================================================#
  1232. class YGG::Handlers::AIEngines::Wall
  1233.  
  1234.   #--------------------------------------------------------------------------#
  1235.   # * super-method :initialize
  1236.   #--------------------------------------------------------------------------#
  1237.   def initialize( parent, setup_data={} )
  1238.     super( parent, setup_data )
  1239.     @burn_time = @burn_cap = setup_data["burn_cap"].to_i
  1240.     @death_anim = (setup_data["death_anim"] || 0).to_i
  1241.   end
  1242.  
  1243.   #--------------------------------------------------------------------------#
  1244.   # * overwrite-method :ai_update
  1245.   #--------------------------------------------------------------------------#
  1246.   def ai_update()
  1247.     return if @parent.ygg_battler.nil?()
  1248.     @burn_time = [@burn_time - 1, 0].max
  1249.     @parent.ygg_battler.hp -= [Integer(@parent.ygg_battler.maxhp / @burn_cap.to_f), 1].max + [@burn_time, 0].min.abs
  1250.     @parent.ygg_engage.engage( 300 )
  1251.     if @parent.ygg_battler.dead?()
  1252.       @parent.ygg_anims << @death_anim if @death_anim > 0
  1253.       $game_map.remove_event( @parent.id )
  1254.     end  
  1255.   end
  1256.  
  1257. end  
  1258.  
  1259. #==============================================================================#
  1260. # ** YGG::Handlers::AIEngines::Wall
  1261. #==============================================================================#
  1262. class YGG::Handlers::AIEngines::ImmortalVarBoss
  1263.  
  1264.   #--------------------------------------------------------------------------#
  1265.   # * super-method :initialize
  1266.   #--------------------------------------------------------------------------#  
  1267.   def initialize( parent, setup_data )
  1268.     super( parent, setup_data )
  1269.     @hp_var    = setup_data["hp_var"].to_i
  1270.     @maxhp_var = setup_data["maxhp_var"].to_i
  1271.     @mp_var    = setup_data["mp_var"].nil?() ? nil : setup_data["mp_var"].to_i
  1272.     @maxmp_var = setup_data["maxmp_var"].nil?() ? nil : setup_data["maxmp_var"].to_i
  1273.     @parent.ygg_invincible = true
  1274.     set_variables()
  1275.   end
  1276.  
  1277.   #--------------------------------------------------------------------------#
  1278.   # * new-method :set_variables
  1279.   #--------------------------------------------------------------------------#  
  1280.   def set_variables()
  1281.     return if @parent.ygg_battler.nil?()
  1282.     $game_variables[@hp_var] = @parent.ygg_battler.hp
  1283.     $game_variables[@maxhp_var] = @parent.ygg_battler.maxhp
  1284.     $game_variables[@mp_var] = @parent.ygg_battler.mp unless @mp_var.nil?()
  1285.     $game_variables[@maxmp_var] = @parent.ygg_battler.maxmp unless @maxmp_var.nil?()
  1286.   end
  1287.  
  1288.   #--------------------------------------------------------------------------#
  1289.   # * overwrite-method :ai_update
  1290.   #--------------------------------------------------------------------------#  
  1291.   def ai_update()
  1292.     return if @parent.ygg_battler.nil?()
  1293.     @parent.ygg_battler.hp = $game_variables[@hp_var]
  1294.     $game_variables[@maxhp_var] = @parent.ygg_battler.maxhp
  1295.     $game_variables[@mp_var] = @parent.ygg_battler.mp unless @mp_var.nil?()
  1296.     $game_variables[@maxmp_var] = @parent.ygg_battler.maxmp unless @maxmp_var.nil?()
  1297.   end
  1298.  
  1299. end  
  1300.  
  1301. # // (YGG_Projectiles)
  1302. Projectiles = YGG::Objects::Projectiles
  1303. #==============================================================================#
  1304. # ** YGG::Objects::Projectiles::Base
  1305. #==============================================================================#
  1306. class YGG::Objects::Projectiles::Base < ::Game_Character
  1307.  
  1308.   #--------------------------------------------------------------------------#
  1309.   # * Public Instance Variables
  1310.   #--------------------------------------------------------------------------#  
  1311.   attr_accessor :character_name
  1312.   attr_accessor :character_index
  1313.  
  1314.   attr_accessor :through
  1315.   attr_accessor :action_name
  1316.   attr_accessor :direction
  1317.   attr_accessor :detonate_cap
  1318.   attr_accessor :move_cap
  1319.   attr_accessor :target_type
  1320.  
  1321.   attr_accessor :registered
  1322.   attr_accessor :action
  1323.  
  1324.   #--------------------------------------------------------------------------#
  1325.   # * new-method :initialize
  1326.   #--------------------------------------------------------------------------#  
  1327.   def initialize( parent, assignments )
  1328.     @parent          = parent
  1329.     super()
  1330.     # // Main Properties
  1331.     @character_name  = assignments[:character_name] || ""
  1332.     @character_index = (assignments[:character_index] || 0).to_i
  1333.     @through         = assignments[:through].nil?() ? true : assignments[:through]
  1334.     @move_speed      = (assignments[:move_speed] || 5).to_i
  1335.    
  1336.     # // Projectile Properties
  1337.     @detonate_cap    = (assignments[:detonate_cap] || -1).to_i
  1338.     @move_cap        = (assignments[:move_cap] || 5).to_i
  1339.     @target_type     = assignments[:target_type] || ""
  1340.    
  1341.     @terminated      = false
  1342.     @detonate_count  = 0
  1343.     @move_count      = 0
  1344.    
  1345.     @action_name     = assignments[:action_name] || ""
  1346.     @action          = assignments[:action] || ::YGG.get_action_list( @action_name )
  1347.    
  1348.     @affect_passage  = assignments[:affect_passage].nil?() ? false : assignments[:affect_passage]
  1349.    
  1350.     @registered      = false
  1351.    
  1352.     #assignments.keys.each { |key| self.send( key.to_s+"=", assignments[key] ) }
  1353.   end
  1354.  
  1355.   #--------------------------------------------------------------------------#
  1356.   # * new-method :hp_visible?
  1357.   #--------------------------------------------------------------------------#
  1358.   def hp_visible?() ; return false ; end
  1359.    
  1360.   #--------------------------------------------------------------------------#
  1361.   # * new-method :mp_visible?
  1362.   #--------------------------------------------------------------------------#
  1363.   def mp_visible?() ; return false ; end
  1364.  
  1365.   #--------------------------------------------------------------------------#
  1366.   # * new-method :registered?
  1367.   #--------------------------------------------------------------------------#
  1368.   def registered?()
  1369.     return @registered
  1370.   end
  1371.  
  1372.   #--------------------------------------------------------------------------#
  1373.   # * new-method :pro_register
  1374.   #--------------------------------------------------------------------------#
  1375.   def pro_register()
  1376.     @registered = true ; $game_yggdrasil.add_passage_obj( self ) if @affect_passage
  1377.   end
  1378.  
  1379.   #--------------------------------------------------------------------------#
  1380.   # * new-method :pro_unregister
  1381.   #--------------------------------------------------------------------------#
  1382.   def pro_unregister()
  1383.     @registered = false ; $game_yggdrasil.remove_passage_obj( self )
  1384.   end
  1385.  
  1386.   #--------------------------------------------------------------------------#
  1387.   # * new-method :ygg_register
  1388.   #--------------------------------------------------------------------------#
  1389.   def ygg_register()
  1390.     @ygg_registered = true
  1391.   end  
  1392.  
  1393.   #--------------------------------------------------------------------------#
  1394.   # * new-method :ygg_unregister
  1395.   #--------------------------------------------------------------------------#
  1396.   def ygg_unregister()
  1397.     $game_yggdrasil.remove_battler( self )
  1398.     @ygg_registered = false
  1399.   end
  1400.  
  1401.   #--------------------------------------------------------------------------#
  1402.   # * new-method :ygg_attacker
  1403.   #--------------------------------------------------------------------------#  
  1404.   def ygg_attacker()
  1405.     return @parent.ygg_attacker
  1406.   end
  1407.  
  1408.   #--------------------------------------------------------------------------#
  1409.   # * new-method :ygg_boss
  1410.   #--------------------------------------------------------------------------#  
  1411.   def ygg_boss?() ; return false ; end
  1412.  
  1413.   #--------------------------------------------------------------------------#
  1414.   # * new-method :ygg_ally?
  1415.   #--------------------------------------------------------------------------#  
  1416.   def ygg_ally?()
  1417.     return @parent.ygg_ally?()
  1418.   end
  1419.  
  1420.   #--------------------------------------------------------------------------#
  1421.   # * new-method :ygg_enemy?
  1422.   #--------------------------------------------------------------------------#  
  1423.   def ygg_enemy?()
  1424.     return @parent.ygg_enemy?()
  1425.   end
  1426.  
  1427.   #--------------------------------------------------------------------------#
  1428.   # * new-method :passable?
  1429.   #--------------------------------------------------------------------------#  
  1430.   def passable?( x, y )
  1431.     x = $game_map.round_x(x)                        
  1432.     y = $game_map.round_y(y)                        
  1433.     return false unless $game_map.valid?(x, y)      
  1434.     return true if @through or debug_through?      
  1435.     return false unless map_passable?( x, y )          
  1436.     return true                                    
  1437.   end
  1438.  
  1439.   #--------------------------------------------------------------------------#
  1440.   # * overwrite-method :check_event_trigger_touch
  1441.   #--------------------------------------------------------------------------#  
  1442.   def check_event_trigger_touch( *args, &block ) ; end
  1443.  
  1444.   #--------------------------------------------------------------------------#
  1445.   # * super-method :update
  1446.   #--------------------------------------------------------------------------#  
  1447.   def update()
  1448.     update_projectile() unless @wait_count > 0
  1449.     super()
  1450.   end
  1451.  
  1452.   #--------------------------------------------------------------------------#
  1453.   # * overwrite-method :update_states
  1454.   #--------------------------------------------------------------------------#  
  1455.   def update_states() ; end
  1456.  
  1457.   #--------------------------------------------------------------------------#
  1458.   # * overwrite-method :move_speed
  1459.   #--------------------------------------------------------------------------#  
  1460.   def move_speed() ; return @move_speed ; end
  1461.    
  1462.   #--------------------------------------------------------------------------#
  1463.   # * new-method :update_projectile
  1464.   #--------------------------------------------------------------------------#  
  1465.   def update_projectile()
  1466.     process_move() if can_move?()
  1467.     process_detonate() if can_detonate?()
  1468.     process_terminate() if can_terminate?()
  1469.   end
  1470.  
  1471.   #--------------------------------------------------------------------------#
  1472.   # * new-method :actual_*x/y
  1473.   #--------------------------------------------------------------------------#  
  1474.   def actual_x() ; return @real_x / 256 ; end
  1475.   def actual_y() ; return @real_y / 256 ; end
  1476.  
  1477.   #--------------------------------------------------------------------------#
  1478.   # * new-method :pos?
  1479.   #--------------------------------------------------------------------------#  
  1480.   def pos?( x, y )  
  1481.     return (actual_x == x && actual_y == y)
  1482.   end
  1483.  
  1484.   #--------------------------------------------------------------------------#
  1485.   # * new-method :target_xy?
  1486.   #--------------------------------------------------------------------------#  
  1487.   def target_xy?( x, y )
  1488.     return !ygg_get_targets( x, y, ygg_correct_target( @target_type ), true ).empty?()
  1489.   end
  1490.  
  1491.   #--------------------------------------------------------------------------#
  1492.   # * new-method :terminated?
  1493.   #--------------------------------------------------------------------------#  
  1494.   def terminated?()
  1495.     return @terminated
  1496.   end
  1497.  
  1498.   #--------------------------------------------------------------------------#
  1499.   # * new-method :can_move?
  1500.   #--------------------------------------------------------------------------#  
  1501.   def can_move?()
  1502.     return false if self.terminated?()
  1503.     return false if jumping?()
  1504.     return false if moving?()
  1505.     return false if (@move_cap > 0 && @move_count >= @move_cap)
  1506.     return true
  1507.   end
  1508.  
  1509.   #--------------------------------------------------------------------------#
  1510.   # * new-method :can_detonate?
  1511.   #--------------------------------------------------------------------------#  
  1512.   def can_detonate?()
  1513.     return false if self.terminated?()
  1514.     return false if (@detonate_cap > 0 && @detonate_count >= @detonate_cap)
  1515.     return target_xy?( self.actual_x, self.actual_y )
  1516.   end
  1517.  
  1518.   #--------------------------------------------------------------------------#
  1519.   # * new-method :can_terminate?
  1520.   #--------------------------------------------------------------------------#  
  1521.   def can_terminate?()
  1522.     return false if self.terminated?()
  1523.     return true if (@detonate_cap > 0 && @detonate_count >= @detonate_cap )
  1524.     return (@move_cap > 0 && @move_count >= @move_cap && !moving?())  
  1525.   end
  1526.  
  1527.   #--------------------------------------------------------------------------#
  1528.   # * new-method :process_move
  1529.   #--------------------------------------------------------------------------#  
  1530.   def process_move()
  1531.     @move_count += 1
  1532.   end
  1533.  
  1534.   #--------------------------------------------------------------------------#
  1535.   # * new-method :process_detonate
  1536.   #--------------------------------------------------------------------------#  
  1537.   def process_detonate()
  1538.     @detonate_count += 1
  1539.     @action_handle.setup( @action )
  1540.     @action_handle.execute( self )
  1541.   end
  1542.  
  1543.   #--------------------------------------------------------------------------#
  1544.   # * new-method :process_terminate
  1545.   #--------------------------------------------------------------------------#  
  1546.   def process_terminate()
  1547.     @terminated = true ; ygg_unregister()
  1548.   end
  1549.  
  1550.   #--------------------------------------------------------------------------#
  1551.   # * new-method :force_terminate
  1552.   #--------------------------------------------------------------------------#  
  1553.   def force_terminate()
  1554.     @terminated = true
  1555.   end
  1556.  
  1557. end
  1558.  
  1559. #==============================================================================#
  1560. # ** YGG::Objects::Projectiles::Linear
  1561. #==============================================================================#
  1562. class YGG::Objects::Projectiles::Linear < ::YGG::Objects::Projectiles::Base
  1563.  
  1564.   #--------------------------------------------------------------------------#
  1565.   # * super-method :initialize
  1566.   #--------------------------------------------------------------------------#  
  1567.   def initialize( parent, assignments )
  1568.     super( parent, assignments )
  1569.   end
  1570.  
  1571.   #--------------------------------------------------------------------------#
  1572.   # * super-method :process_move
  1573.   #--------------------------------------------------------------------------#  
  1574.   def process_move()
  1575.     move_forward()
  1576.     super()
  1577.   end
  1578.  
  1579. end
  1580.  
  1581. #==============================================================================#
  1582. # ** YGG::Objects::Projectiles::Hopping
  1583. #==============================================================================#
  1584. class YGG::Objects::Projectiles::Hopping < ::YGG::Objects::Projectiles::Base
  1585.  
  1586.   #--------------------------------------------------------------------------#
  1587.   # * Public Instance Variables
  1588.   #--------------------------------------------------------------------------#
  1589.   attr_accessor :jump_amount
  1590.  
  1591.   #--------------------------------------------------------------------------#
  1592.   # * super-method :initialize
  1593.   #--------------------------------------------------------------------------#  
  1594.   def initialize( parent, assignments )
  1595.     @jump_amount = (assignments[:jump_amount] || 1).to_i
  1596.     super( parent, assignments )
  1597.   end
  1598.  
  1599.   #--------------------------------------------------------------------------#
  1600.   # * super-method :process_move
  1601.   #--------------------------------------------------------------------------#  
  1602.   def process_move()
  1603.     jump_forward( @jump_amount, 0 )
  1604.     super()
  1605.   end
  1606.  
  1607. end
  1608.  
  1609. #==============================================================================#
  1610. # ** YGG::Objects::Projectiles::Homing
  1611. #==============================================================================#
  1612. class YGG::Objects::Projectiles::Homing < ::YGG::Objects::Projectiles::Base
  1613.  
  1614.   #--------------------------------------------------------------------------#
  1615.   # * Public Instance Variables
  1616.   #--------------------------------------------------------------------------#
  1617.   attr_accessor :target
  1618.   attr_accessor :homing_range
  1619.  
  1620.   #--------------------------------------------------------------------------#
  1621.   # * super-method :initialize
  1622.   #--------------------------------------------------------------------------#  
  1623.   def initialize( parent, assignments )
  1624.     @homing_range = (assignments[:homing_range] || 5).to_i
  1625.     @target = assignments[:target]
  1626.     super( parent, assignments )
  1627.     set_target() if @target.nil?()
  1628.   end
  1629.  
  1630.   #--------------------------------------------------------------------------#
  1631.   # * new-method :target_xy?
  1632.   #--------------------------------------------------------------------------#  
  1633.   def target_xy?( x, y )
  1634.     self.pos?( @target.x, @target.y )
  1635.   end
  1636.  
  1637.   #--------------------------------------------------------------------------#
  1638.   # * new-method :set_target
  1639.   #--------------------------------------------------------------------------#  
  1640.   def set_target()
  1641.     @target = get_targets_nearby( @homing_range, ygg_correct_target( @target_type ) )[0]
  1642.   end
  1643.  
  1644.   #--------------------------------------------------------------------------#
  1645.   # * new-method :target_oor? # // target_out_of_range?
  1646.   #--------------------------------------------------------------------------#  
  1647.   def target_oor?()
  1648.     return @homing_range == -1 ? false : (@target.distance_from( self ) > @homing_range)
  1649.   end
  1650.  
  1651.   #--------------------------------------------------------------------------#
  1652.   # * super-method :process_move
  1653.   #--------------------------------------------------------------------------#  
  1654.   def process_move()
  1655.     move_toward_char( @target )
  1656.     super()
  1657.   end
  1658.  
  1659.   #--------------------------------------------------------------------------#
  1660.   # * super-method :can_terminate?
  1661.   #--------------------------------------------------------------------------#
  1662.   def can_terminate?()
  1663.     return true if target_oor?()
  1664.     super()
  1665.   end
  1666.    
  1667. end
  1668.  
  1669. #==============================================================================#
  1670. # ** YGG::Objects::Projectiles::Bomb
  1671. #==============================================================================#
  1672. class YGG::Objects::Projectiles::Bomb < ::YGG::Objects::Projectiles::Base
  1673.  
  1674.   #--------------------------------------------------------------------------#
  1675.   # * Public Instance Variables
  1676.   #--------------------------------------------------------------------------#  
  1677.   attr_accessor :time
  1678.  
  1679.   #--------------------------------------------------------------------------#
  1680.   # * super-method :initialize
  1681.   #--------------------------------------------------------------------------#  
  1682.   def initialize( parent, assignments )
  1683.     @time = (assignments[:time] || 60).to_i
  1684.     super( parent, assignments )
  1685.   end
  1686.  
  1687.   #--------------------------------------------------------------------------#
  1688.   # * overwrite-method :target_xy?
  1689.   #--------------------------------------------------------------------------#  
  1690.   def target_xy?( x, y )
  1691.     return true
  1692.   end
  1693.  
  1694.   #--------------------------------------------------------------------------#
  1695.   # * super-method :update_projectile
  1696.   #--------------------------------------------------------------------------#  
  1697.   def update_projectile()
  1698.     @time = [@time-1, 0].max
  1699.     super()
  1700.   end
  1701.  
  1702.   #--------------------------------------------------------------------------#
  1703.   # * super-method :can_detonate?
  1704.   #--------------------------------------------------------------------------#  
  1705.   def can_detonate?()
  1706.     return false unless super()
  1707.     return true if @time == 0
  1708.     return false
  1709.   end
  1710.  
  1711. end
  1712.  
  1713. #==============================================================================#
  1714. # ** YGG::Objects::Projectiles::GhostBullet
  1715. #==============================================================================#
  1716. class YGG::Objects::Projectiles::GhostBullet < ::YGG::Objects::Projectiles::Base
  1717.  
  1718.   #--------------------------------------------------------------------------#
  1719.   # * super-method :initialize
  1720.   #--------------------------------------------------------------------------#  
  1721.   def initialize( parent, assignments )
  1722.     super( parent, assignments )
  1723.   end
  1724.  
  1725. end
  1726.  
  1727. #==============================================================================#
  1728. # ** YGG::Objects::Projectiles::ActionPilot
  1729. #==============================================================================#
  1730. class YGG::Objects::Projectiles::ActionPilot < ::YGG::Objects::Projectiles::Base
  1731.  
  1732.   #--------------------------------------------------------------------------#
  1733.   # * Public Instance Variables
  1734.   #--------------------------------------------------------------------------#  
  1735.   attr_accessor :pilot_list
  1736.  
  1737.   #--------------------------------------------------------------------------#
  1738.   # * super-method :update_projectile
  1739.   #--------------------------------------------------------------------------#  
  1740.   def initialize( parent, assignments )
  1741.     @pilot_list = assignments[:pilot_list] || []
  1742.     super( parent, assignments )
  1743.     @pilot_index = 0
  1744.   end
  1745.  
  1746.   #--------------------------------------------------------------------------#
  1747.   # * new-method :update_projectile
  1748.   #--------------------------------------------------------------------------#  
  1749.   def update_projectile()
  1750.     @sleep_count = [@sleep_count - 1, 0].max
  1751.     return unless @sleep_count == 0
  1752.     while @pilot_index < @pilot_list.size
  1753.       act_set     = @pilot_list[@pilot_index]
  1754.       @action     = act_set[0]
  1755.       @parameters = act_set[1]
  1756.       for i in 0...@parameters.size() ; @parameters[i] = @parameters[i].to_s() ; end
  1757.       act_result = -1
  1758.       case @action.upcase()
  1759.       when "MOVE"
  1760.         act_result = pilot_move( @action, @parameters )
  1761.       when "DETONATE"  
  1762.         act_result = pilot_detonate( @action, @parameters )
  1763.       when "TERMINATE"  
  1764.         act_result = pilot_terminate( @action, @parameters )
  1765.       when "SEND"  
  1766.         act_result = pilot_send( @action, @parameters )
  1767.       when "SLEEP"  
  1768.         act_result = pilot_sleep( @action, @parameters )
  1769.       when "SCRIPT"  
  1770.         act_result = pilot_script( @action, @parameters )
  1771.       when "WAIT"  
  1772.         act_result = pilot_wait( @action, @parameters )
  1773.       end
  1774.       if act_result == -1
  1775.         puts "ERROR: -1 returned for pilot action #{self}"
  1776.       else
  1777.         puts "BING: #{act_result} returned for pilot action #{self}"
  1778.       end if YGG.debug_mode?
  1779.       @pilot_index += 1
  1780.       break if act_result == 1
  1781.     end  
  1782.     return
  1783.   end
  1784.  
  1785.   #--------------------------------------------------------------------------#
  1786.   # * new-method :pilot_move
  1787.   #--------------------------------------------------------------------------#  
  1788.   def pilot_move( action, parameters )
  1789.     character = self
  1790.     case parameters[0].upcase
  1791.     when "FORWARD"
  1792.       character.move_forward()
  1793.     when "BACKWARD"
  1794.       character.move_backward()  
  1795.     when "UP"
  1796.       character.move_up()
  1797.     when "DOWN"
  1798.       character.move_down()
  1799.     when "LEFT"
  1800.       character.move_left()
  1801.     when "RIGHT"
  1802.       character.move_right()
  1803.     when "TURNUP", "TURN_UP", "TURN UP"
  1804.       character.turn_up()
  1805.     when "TURNDOWN", "TURN_DOWN", "TURN DOWN"
  1806.       character.turn_down()
  1807.     when "TURNLEFT", "TURN_LEFT", "TURN LEFT"
  1808.       character.turn_left()
  1809.     when "TURNRIGHT", "TURN_RIGHT", "TURN RIGHT"
  1810.       character.turn_right()
  1811.     when "TURNRIGHT90", "TURN_RIGHT_90", "TURN RIGHT 90"
  1812.       character.turn_right_90()
  1813.     when "TURNLEFT90", "TURN_LEFT_90", "TURN LEFT 90"
  1814.       character.turn_left_90()  
  1815.     when "TURN180", "TURN_180", "TURN 180"
  1816.       character.turn_180()
  1817.     when "TURNTO", "TURN_TO", "TURN TO"
  1818.       target = nil
  1819.       character.turn_to_coord( target.x, target.y ) unless target.nil?()
  1820.     end
  1821.     return 0
  1822.   end
  1823.  
  1824.   #--------------------------------------------------------------------------#
  1825.   # * new-method :pilot_send
  1826.   #--------------------------------------------------------------------------#  
  1827.   def pilot_send( action, parameters )
  1828.     case parameters[0]
  1829.     when "ONLY"
  1830.       self.send( parameters[1] )
  1831.     when "SET"  
  1832.       self.send( parameters[1], *parameters.slice( 2, parameters.size ) )
  1833.     end  
  1834.     return 0
  1835.   end
  1836.  
  1837.   #--------------------------------------------------------------------------#
  1838.   # * new-method :pilot_detonate
  1839.   #--------------------------------------------------------------------------#  
  1840.   def pilot_detonate( action, parameters )
  1841.     process_detonate()
  1842.     return 0
  1843.   end
  1844.  
  1845.   #--------------------------------------------------------------------------#
  1846.   # * new-method :pilot_terminate
  1847.   #--------------------------------------------------------------------------#  
  1848.   def pilot_terminate( action, parameters )
  1849.     process_terminate()
  1850.     return 0
  1851.   end
  1852.  
  1853.   #--------------------------------------------------------------------------#
  1854.   # * new-method :pilot_terminate
  1855.   #--------------------------------------------------------------------------#  
  1856.   def pilot_script( action, parameters )
  1857.     eval( parameters.to_s )
  1858.     return 0
  1859.   end
  1860.  
  1861.   #--------------------------------------------------------------------------#
  1862.   # * new-method :pilot_sleep
  1863.   #--------------------------------------------------------------------------#  
  1864.   def pilot_sleep( action, parameters )
  1865.     @sleep_count = parameters[0].to_i
  1866.     return 1
  1867.   end
  1868.  
  1869.   #--------------------------------------------------------------------------#
  1870.   # * new-method :pilot_wait
  1871.   #--------------------------------------------------------------------------#  
  1872.   def pilot_wait( action, parameters )
  1873.     @wait_count = parameters[0].to_i
  1874.     return 0
  1875.   end
  1876.  
  1877. end  
  1878.  
  1879. #==============================================================================#
  1880. # ** YGG
  1881. #==============================================================================#
  1882. module YGG
  1883.  
  1884.   PROJECTILE_MAP = {
  1885.     "linear"  => YGG::Objects::Projectiles::Linear,
  1886.     "hopping" => YGG::Objects::Projectiles::Hopping,
  1887.     "homing"  => YGG::Objects::Projectiles::Homing,
  1888.     "bomb"    => YGG::Objects::Projectiles::Bomb,
  1889.     "ghost"   => YGG::Objects::Projectiles::GhostBullet,
  1890.     "action"  => YGG::Objects::Projectiles::ActionPilot,
  1891.   }  
  1892.  
  1893.   PROJETILE_SETUP = {}
  1894.  
  1895. end
  1896.  
  1897. #==============================================================================#
  1898. # ** YGG::Handlers::Equip
  1899. #==============================================================================#
  1900. class YGG::Handlers::Equip < YGG::Pos
  1901.  
  1902.   #--------------------------------------------------------------------------#
  1903.   # * Class Method(s)
  1904.   #--------------------------------------------------------------------------#
  1905.  
  1906.   #--------------------------------------------------------------------------#
  1907.   # * new-method :angle_change_list
  1908.   #--------------------------------------------------------------------------#
  1909.   def self.angle_change_list( start, add_target, wait, maxspeed=1, shorten=0 )
  1910.     result = []
  1911.     target = start + add_target
  1912.     rate = add_target.to_f / wait.to_f ; accel = 0
  1913.     ang = start
  1914.     (wait-shorten).times { |i|
  1915.       accel = maxspeed.to_f * i.to_f / wait.to_f
  1916.       if ang < target
  1917.         ang += rate.abs
  1918.         ang += accel ; ang = [ang, target].min
  1919.       elsif ang > target
  1920.         ang -= rate.abs
  1921.         ang -= accel ; ang = [ang, target].max
  1922.       else ; ang = target  
  1923.       end  
  1924.       result += [["CHANGE ANGLE", (ang)%360], ["WAIT", 1]]
  1925.     }  
  1926.     return result
  1927.   end
  1928.  
  1929.   #--------------------------------------------------------------------------#
  1930.   # * new-method :move_to_list
  1931.   #--------------------------------------------------------------------------#
  1932.   def self.move_to_list( start, add_target, wait, axis, maxspeed=1, shorten=0 )
  1933.     result = []
  1934.     target = start + add_target
  1935.     rate = add_target.to_f / wait.to_f ; accel = 0
  1936.     pos = start
  1937.     (wait-shorten).times { |i|
  1938.       accel = maxspeed.to_f * i.to_f / wait.to_f
  1939.       if pos < target
  1940.         pos += rate.abs
  1941.         pos += accel ; pos = [pos, target].min
  1942.       elsif pos > target
  1943.         pos -= rate.abs
  1944.         pos -= accel ; pos = [pos, target].max
  1945.       else ; pos = target  
  1946.       end  
  1947.       result += [["MOVE", axis.upcase, pos], ["WAIT", 1]]
  1948.     }  
  1949.     return result
  1950.   end
  1951.  
  1952.   #--------------------------------------------------------------------------#
  1953.   # * new-method :alternate_mix
  1954.   #--------------------------------------------------------------------------#  
  1955.   def self.alternate_mix( *args )
  1956.     aresult = [] ; sizes = args.inject([]) { |result, array| result << array.size }
  1957.     sizes.max.times { |i| args.each { |array| aresult << array[i] unless array[i].nil?() } }
  1958.     return aresult
  1959.   end
  1960.  
  1961.   #--------------------------------------------------------------------------#
  1962.   # * Constant(s)
  1963.   #--------------------------------------------------------------------------#
  1964.   ACTIONS = {}
  1965.   # // Swing
  1966.   t  = 0
  1967.   at = 78
  1968.   ACTIONS["Swing1"]  = [["RESET"], ["SHOW"]]
  1969.   ACTIONS["Swing1"] += angle_change_list( t, at, 12 )
  1970.   ACTIONS["Swing1"] += [["HIDE"]]
  1971.   # // Swing + Return Swing
  1972.   ACTIONS["Swing2"]  = [["RESET"], ["SHOW"]]
  1973.   ACTIONS["Swing2"] += angle_change_list( t, at, 11, 24, 2 )
  1974.   ACTIONS["Swing2"] += angle_change_list( t+at, t-at, 11, 24, 2 )
  1975.   ACTIONS["Swing2"] += [["HIDE"]]
  1976.   # // Swing + Pull
  1977.   ACTIONS["Swing3"]  = [["RESET"], ["SHOW"]]
  1978.   ACTIONS["Swing3"] += angle_change_list( t, at, 11, 24, 2 )
  1979.   ACTIONS["Swing3"] += move_to_list( 0, -14, 8, "Y" )
  1980.   ACTIONS["Swing3"] += [["HIDE"]]
  1981.  
  1982.   # // Stab
  1983.   ACTIONS["Stab1"]   = [["RESET"], ["SHOW"]]
  1984.   ACTIONS["Stab1"]  += [["CHANGE ANGLE", 40]]
  1985.   ACTIONS["Stab1"]  += [["MOVE", "X", -5]]
  1986.   ACTIONS["Stab1"]  += move_to_list( 0,  -4, 5, "Y" )
  1987.   ACTIONS["Stab1"]  += move_to_list( -4, 8, 8, "Y" )
  1988.   ACTIONS["Stab1"]  += [["HIDE"]]
  1989.  
  1990.   ACTIONS["GRise1"] = [["RESET"], ["SHOW"]]
  1991.   ACTIONS["GRise1"] += move_to_list( 0, -8, 8, "Y" )
  1992.   ACTIONS["GRise1"] += [["WAIT FOR GUARD"]]
  1993.   ACTIONS["GRise1"] += move_to_list( 0, 8, 8, "Y" )
  1994.   ACTIONS["GRise1"] += [["HIDE"]]
  1995.  
  1996. end  
  1997.  
  1998. #==============================================================================#
  1999. ($imported ||= {})["Yggdrasil_1x6_ABS"] = true
  2000. #==============================================================================#
  2001. # ** YGG
  2002. #==============================================================================#
  2003. module YGG    
  2004.  
  2005.   module_function()
  2006.  
  2007.   #--------------------------------------------------------------------------#
  2008.   # * new-method :silent_error?
  2009.   #--------------------------------------------------------------------------#  
  2010.   def silent_error?() ; return false ; end
  2011.   def debug_mode?()   ; return false ; end
  2012.    
  2013.   #--------------------------------------------------------------------------#
  2014.   # * new-method :get_action_list
  2015.   #--------------------------------------------------------------------------#
  2016.   def get_action_list( action_name )
  2017.     unless YGG::ACTION_LIST.has_key?( action_name )  
  2018.       return [] if silent_error?() # // Silent Error
  2019.       raise "Action List #{action_name} does not exist"
  2020.       exit
  2021.     end  
  2022.     return ACTION_LIST[action_name]
  2023.   end
  2024.  
  2025.   # // User Functions  
  2026.  
  2027.   #--------------------------------------------------------------------------#
  2028.   # * new-method :create_range_data
  2029.   #--------------------------------------------------------------------------#
  2030.   # If the range was done before, it is simply reloaded
  2031.   # rng    - Maximum Range
  2032.   # minrng - Minimum Range
  2033.   # type:
  2034.   #   0 - Diamond   < >
  2035.   #   1 - Cross      +
  2036.   #   2 - X          x
  2037.   #   3 - Breath     <
  2038.   #   4 - SnowFlake  *
  2039.   #   5 - Block     [ ]
  2040.   #   6 - Linear    ->
  2041.   # direction:
  2042.   #   2 - Down
  2043.   #   4 - Left
  2044.   #   6 - Right
  2045.   #   8 - Up
  2046.   #--------------------------------------------------------------------------#
  2047.   def create_range_data( rng, minrng=0, type=0, direction=2 )  
  2048.     return Handlers::Range.createRange( rng, minrng, type, direction )
  2049.   end
  2050.  
  2051.   #--------------------------------------------------------------------------#
  2052.   # * new-method :offset_xy_list
  2053.   #--------------------------------------------------------------------------#  
  2054.   def offset_xy_list( ox, oy, xy_list, direction=2 )
  2055.     return xy_list.inject([]) { |result, coords|
  2056.       result.push( offset_xy( ox, oy, coords, direction ) ) }
  2057.   end
  2058.  
  2059.   #--------------------------------------------------------------------------#
  2060.   # * new-method :offset_xy
  2061.   #--------------------------------------------------------------------------#  
  2062.   def offset_xy( ox, oy, coords, direction=2 )
  2063.     result = []
  2064.     case direction
  2065.     when 2
  2066.       result = [ ox + coords[0], oy + coords[1] ]
  2067.     when 4
  2068.       result = [ ox - coords[1], oy - coords[0] ]
  2069.     when 6
  2070.       result = [ ox + coords[1], oy + coords[0] ]
  2071.     when 8
  2072.       result = [ ox - coords[0], oy - coords[1] ]
  2073.     end
  2074.     return result
  2075.   end
  2076.  
  2077.   #--------------------------------------------------------------------------#
  2078.   # * new-method :parse_event_list
  2079.   #--------------------------------------------------------------------------#  
  2080.   def parse_event_list( list )
  2081.     return list
  2082.     # // Skip Parsing
  2083.     final_list = []
  2084.     list.each { |command|
  2085.       new_command = command.clone
  2086.       if [108, 408].include?( command.code )
  2087.         new_command = RPG::EventCommand.new
  2088.         new_command.indent = command.indent
  2089.         case command.parameters.to_s.upcase
  2090.         when "DETONATE"
  2091.           new_command.code = 1000
  2092.         end
  2093.       end  
  2094.       final_list << new_command
  2095.     }  
  2096.     return final_list
  2097.   end
  2098.  
  2099. #==============================================================================#
  2100. # // Main Classes
  2101. #==============================================================================#
  2102. # ** Pos  
  2103. #==============================================================================#
  2104.   class Pos  
  2105.    
  2106.     #--------------------------------------------------------------------------#
  2107.     # * Public Instance Variable(s)
  2108.     #--------------------------------------------------------------------------#  
  2109.     attr_accessor :x, :y, :z # // X, Y, Z
  2110.    
  2111.     #--------------------------------------------------------------------------#
  2112.     # * new-method :initialize
  2113.     #--------------------------------------------------------------------------#
  2114.     def initialize( x, y, z=0 ) ; set( x, y, z ) end
  2115.      
  2116.     #--------------------------------------------------------------------------#
  2117.     # * new-method :set
  2118.     #--------------------------------------------------------------------------#
  2119.     def set( x, y, z=@z ) ; @x = x ; @y = y ; @z = z ; end
  2120.      
  2121.     #--------------------------------------------------------------------------#
  2122.     # * super-method :==
  2123.     #--------------------------------------------------------------------------#  
  2124.     def ==( obj )
  2125.       return ( @x == obj.x &&
  2126.         @y == obj.y &&
  2127.         @z == obj.z ) if obj.kind_of?( self.class )
  2128.       return super( obj )  
  2129.     end
  2130.    
  2131.   end
  2132.  
  2133. #==============================================================================#
  2134. # ** YGG::Handlers::Screen
  2135. #==============================================================================#
  2136.   class Handlers::Screen < Pos
  2137.    
  2138.     #--------------------------------------------------------------------------#
  2139.     # * Public Instance Variable(s)
  2140.     #--------------------------------------------------------------------------#  
  2141.     attr_accessor :real_x, :real_y
  2142.    
  2143.     #--------------------------------------------------------------------------#
  2144.     # * super-method :initialize
  2145.     #--------------------------------------------------------------------------#
  2146.     def initialize( x, y, z=200 ) ; super( x, y, z ) ; moveto( x, y, z ) ; end
  2147.    
  2148.     #--------------------------------------------------------------------------#
  2149.     # * new-method :moveto
  2150.     #--------------------------------------------------------------------------#
  2151.     def moveto( x, y, z=@z )
  2152.       set( x % $game_map.width, y % $game_map.height, z )
  2153.       @real_x = @x * 256 ; @real_y = @y * 256
  2154.     end
  2155.    
  2156.     #--------------------------------------------------------------------------#
  2157.     # * new-method :screen_x
  2158.     #--------------------------------------------------------------------------#  
  2159.     def screen_x()
  2160.       return ($game_map.adjust_x(@real_x) + 8007) / 8 - 1000 + 16
  2161.     end
  2162.    
  2163.     #--------------------------------------------------------------------------#
  2164.     # * new-method :screen_y
  2165.     #--------------------------------------------------------------------------#  
  2166.     def screen_y()
  2167.       return ($game_map.adjust_y(@real_y) + 8007) / 8 - 1000 + 32
  2168.     end
  2169.    
  2170.     #--------------------------------------------------------------------------#
  2171.     # * new-method :screen_z
  2172.     #--------------------------------------------------------------------------#  
  2173.     def screen_z() ; return @z ; end
  2174.    
  2175.   end
  2176.  
  2177. #==============================================================================#
  2178. # ** Handlers::CharPos
  2179. #==============================================================================#
  2180.   class Handlers::CharPos < Handlers::Screen
  2181.    
  2182.     #--------------------------------------------------------------------------#
  2183.     # * Public Instance Variable(s)
  2184.     #--------------------------------------------------------------------------#
  2185.     attr_accessor :fade_amount
  2186.     attr_accessor :fade_max
  2187.    
  2188.     #--------------------------------------------------------------------------#
  2189.     # * super-method :initialize
  2190.     #--------------------------------------------------------------------------#
  2191.     def initialize( x=0, y=0, z=0, fade_out=0, fade_amt=0 )
  2192.       super( x, y, z )
  2193.       @fade_out    = fade_out
  2194.       @fade_amount = @fade_max = fade_amt
  2195.     end
  2196.    
  2197.     #--------------------------------------------------------------------------#
  2198.     # * new-method :fader_type
  2199.     #--------------------------------------------------------------------------#
  2200.     def fader_type() ; return @fade_out ; end
  2201.    
  2202.     #--------------------------------------------------------------------------#
  2203.     # * new-method :setup_pos
  2204.     #--------------------------------------------------------------------------#
  2205.     def setup_pos( x, y ) ; moveto( @x, @y ) ; end
  2206.    
  2207.   end  
  2208.    
  2209. #==============================================================================#
  2210. # ** Handlers::Range
  2211. #==============================================================================#
  2212.   class Handlers::Range  
  2213.    
  2214.     #--------------------------------------------------------------------------#
  2215.     # * Class Variable
  2216.     #--------------------------------------------------------------------------#
  2217.     @@_recorded_ranges = { }
  2218.    
  2219.     #--------------------------------------------------------------------------#
  2220.     # * class-method :createRange
  2221.     #--------------------------------------------------------------------------#
  2222.     def self.createRange( rng, minrng=0, type=0, direction=2 )
  2223.       datarray = [ rng, minrng, type, direction ]
  2224.       unless @@_recorded_ranges.has_key?( datarray )
  2225.         result   = []
  2226.         case type
  2227.         when 0 # // Normal - Diamond <>
  2228.           for x in 0..rng
  2229.             for y in 0..rng
  2230.               next if x+y > rng
  2231.               next if x+y < minrng
  2232.               result << [ x,  y] ; result << [-x,  y]
  2233.               result << [ x, -y] ; result << [-x, -y]
  2234.             end
  2235.           end
  2236.         when 1 # // Cross +
  2237.           for x in 0..rng
  2238.             for y in 0..rng
  2239.               next if x+y > rng
  2240.               next if x+y < minrng
  2241.               result << [ x,  0] ; result << [-x,  0]
  2242.               result << [ 0, -y] ; result << [ 0,  y]
  2243.             end
  2244.           end
  2245.         when 2 # // X - x
  2246.           for x in 0..rng
  2247.             for y in 0..rng
  2248.               next if x+y > rng
  2249.               next if x+y < minrng
  2250.               result << [ x,  x] ; result << [-x, -x]
  2251.               result << [-y,  y] ; result << [ y, -y]
  2252.             end
  2253.           end
  2254.         when 3 # // Breath <
  2255.           for x in 0..rng
  2256.             for y in 0..rng
  2257.               next if x+y > rng
  2258.               next if x+y < minrng
  2259.               case direction
  2260.               when 2 ; result << [ x,  y] ; result << [-x,  y]
  2261.               when 4 ; result << [-x,  y] ; result << [-x, -y]
  2262.               when 6 ; result << [ x,  y] ; result << [ x, -y]
  2263.               when 8 ; result << [ x, -y] ; result << [-x, -y]
  2264.               end  
  2265.             end
  2266.           end
  2267.         when 4 # // Snow Flake *
  2268.           for x in 0..rng
  2269.             next if x < minrng
  2270.             result << [ 0,  x] ; result << [ x,  0]
  2271.             result << [ 0, -x] ; result << [-x,  0]
  2272.             result << [ x,  x] ; result << [-x,  x]
  2273.             result << [ x, -x] ; result << [-x, -x]
  2274.           end  
  2275.         when 5 # // Block []
  2276.           for x in 0..rng
  2277.             for y in 0..rng
  2278.               next if x < minrng && y < minrng
  2279.               result << [ x,  y] ; result << [-x,  y]
  2280.               result << [ x, -y] ; result << [-x, -y]
  2281.             end
  2282.           end  
  2283.         when 6 # // Linear <-
  2284.           for x in 0..rng
  2285.             for y in 0..rng
  2286.               next if x+y > rng
  2287.               next if x+y < minrng
  2288.               case direction
  2289.               when 2 ; result << [ 0,  y]
  2290.               when 4 ; result << [-x,  0]
  2291.               when 6 ; result << [ x,  0]
  2292.               when 8 ; result << [ 0, -y]
  2293.               end  
  2294.             end
  2295.           end
  2296.         end
  2297.         @@_recorded_ranges[datarray] = result.compact.uniq
  2298.       end  
  2299.       return @@_recorded_ranges[datarray]
  2300.     end
  2301.    
  2302.   end
  2303.  
  2304. #==============================================================================#
  2305. # // YGG Construction
  2306. #==============================================================================#
  2307. # ** REGEXP
  2308. #==============================================================================#  
  2309.   module REGEXP
  2310. #==============================================================================#
  2311. # ** EVENT
  2312. #==============================================================================#
  2313.     module EVENT
  2314.       # Event Tags
  2315.       ABS_ALLY         = /<(?:ABS_ALLY|abs ally):[ ]*(\d+)>/i
  2316.       ABS_ENEMY        = /<(?:ABS_ENEMY|abs enemy):[ ]*(\d+)>/i
  2317.       ABS_SET_AS_ALLY  = /<(?:SET_AS_ALLY|SET AS ALLY)>/i
  2318.       ABS_SET_AS_ENEMY = /<(?:SET_AS_ENEMY|SET AS ENEMY)>/i
  2319.       ABS_BOSS         = /<(?:ABS_BOSS|abs boss)>/i
  2320.       SELF_SWITCH      = /<(?:DEAD_SELF_SWITCH|dead self switch):[ ]*(\w+)>/i
  2321.       SWITCH           = /<(?:DEAD_SWITCH|dead switch):[ ]*(\d+)[ ]*,[ ]*(\w+)>/i
  2322.       NO_FADE_DEATH    = /<(?:NO_FADE_DEATH|no fade death)>/i
  2323.       INSTANT_DEATH    = /<(?:INSTANT_DEATH|instant death)>/i
  2324.       DEATH_ANIM       = /<(?:DEATH_ANIMATION_ID|death animation id|death anim|DEATH_ANIM):[ ]*(\d+)>/i
  2325.       INVINCIBLE       = /<(?:INVINCIBLE|IMMORTAL)>/i
  2326.      
  2327.       AI_ENGINE1       = /<(?:AI_ENGINE|AI ENGINE):[ ](.*)>/i
  2328.       AI_ENGINE2       = /<\/(?:AI_ENGINE|AI ENGINE)>/i
  2329.       ENABLE_POP       = /<(?:ENABLE_POP|ENABLE POP|ENABLEPOP)>/i
  2330.       DISABLE_POP      = /<(?:DISABLE_POP|DISABLE POP|DISABLEPOP|NO POP|NO_POP|NOPOP)>/i
  2331.       SHOW_HP_BAR      = /<(?:SHOW_HP_BAR|SHOW HP BAR|SHOWHPBAR)>/i
  2332.       HIDE_HP_BAR      = /<(?:HIDE_HP_BAR|HIDE HP BAR|HIDEHPBAR)>/i
  2333.       SHOW_MP_BAR      = /<(?:SHOW_MP_BAR|SHOW MP BAR|SHOWMPBAR)>/i
  2334.       HIDE_MP_BAR      = /<(?:HIDE_MP_BAR|HIDE MP BAR|HIDEMPBAR)>/i
  2335.      
  2336.       ONDEATH1         = /<(?:ON_DEATH|ON DEATH|ONDEATH):[ ](.*)>/i
  2337.       ONDEATH2         = /<\/(?:ON_DEATH|ON DEATH|ONDEATH)>/i
  2338.     end # // EVENT
  2339. #==============================================================================#
  2340. # ** BASE_ITEM
  2341. #==============================================================================#
  2342.     module BASE_ITEM
  2343.       # Equipment Tags
  2344.       ACTION_OPEN   = /<ACTION[ ]*(\d+)>/i
  2345.       ACTION_CLOSE  = /<\/ACTION>/i
  2346.       ACTION_ASSIGN = /<ACTION[ ]*(\d+)[ ]*\=[ ]*(.*)>/i
  2347.      
  2348.       PREACTION_OPEN   = /<PREACTION[ ]*(\d+)>/i
  2349.       PREACTION_CLOSE  = /<\/PREACTION>/i
  2350.       PREACTION_ASSIGN = /<PREACTION[ ]*(\d+)[ ]*\=[ ]*(.*)>/i
  2351.      
  2352.       ACTION_6      = /(.*):[ ](.*),[ ](.*),[ ](.*),[ ](.*),[ ](.*),[ ](.*)/i
  2353.       ACTION_5      = /(.*):[ ](.*),[ ](.*),[ ](.*),[ ](.*),[ ](.*)/i
  2354.       ACTION_4      = /(.*):[ ](.*),[ ](.*),[ ](.*),[ ](.*)/i
  2355.       ACTION_3      = /(.*):[ ](.*),[ ](.*),[ ](.*)/i
  2356.       ACTION_2      = /(.*):[ ](.*),[ ](.*)/i
  2357.       ACTION_1      = /(.*):[ ](.*)/i
  2358.      
  2359.       DROPS_ATTRACT = /<(?:ATTRACT_DROP|attract drop)s?>/i
  2360.      
  2361.       CHARGE_CAP    = /<(?:CHARGE_CAP|CHARGE CAP|COOLDOWN):[ ]*(\d+)>/i
  2362.     USER_CHARGE_CAP = /<(?:USER_CHARGE_CAP|USER CHARGE CAP|USER_COOLDOWN|USER COOLDOWN):[ ]*(\d+)>/i
  2363.    
  2364.       CANT_EQUIP    = /<(?:CANT_EQUIP_SLOT|CANT EQUIP SLOT)>/i  
  2365.      
  2366.       PICKUP_SFX    = /<(?:PICKUP_SFX|PICKUP SFX|PKSFX):[ ](.*),[ ](\d+),[ ](\d+)>/i
  2367.     end
  2368. #==============================================================================#
  2369. # ** SKILL
  2370. #==============================================================================#      
  2371.     module SKILL
  2372.       UTARGET_SELECT= /<(?:USE_TARGET_SELECT|USE TARGET SELECT)>/i
  2373.       GUARDABLE     = /<(?:GUARDABLE)>/i
  2374.       NOT_GUARDABLE = /<(?:NOT_GUARDABLE|NOT GUARDABLE|NOTGUARDABLE)>/i
  2375.     end # // BASE_ITEM
  2376. #==============================================================================#
  2377. # ** STATE
  2378. #==============================================================================#    
  2379.     module STATE
  2380.       HOLD_TICKS = /<(?:HOLDTICKS|HOLD_TICKS|HOLD TICKS):[ ](\d+)>/i
  2381.       TONE       = /<TONE:[ ]([\+\-]?\d+),[ ]*([\+\-]?\d+),[ ]*([\+\-]?\d+),[ ]*(\d+)>/i
  2382.       MOVE_MOD   = /<(?:MOVEMOD|MOVE_MOD|MOVE MOD):[ ]([\+\-]\d+)>/i
  2383.       SLIP_FREQ  = /<(?:SLIPFREQ|SLIP_FREQ|SLIP FREQ):[ ](\d+)>/i
  2384.     end # // STATE
  2385. #==============================================================================#
  2386. # ** ENEMY
  2387. #==============================================================================#        
  2388.     module ENEMY
  2389.       ATK_ANIMATION_ID = /<(?:ATK_ANIMATION_ID|ATK ANIMATION ID):[ ](\d+)>/i
  2390.       DROP_ITEM1       = /<(?:DROP_ITEM|DROP ITEM|DROPITEM)[ ](\d+)>/i
  2391.       DROP_ITEM2       = /<\/(?:DROP_ITEM|DROP ITEM|DROPITEM)>/i
  2392.       DROP_CLEAR       = /<(?:DROPS_CLEAR|DROPS CLEAR|DROPSCLEAR)>/i
  2393.       GOLD_VARI        = /<(?:GOLD_VARIATION|GOLD VARIATION):[ ](\d+)>/i
  2394.     end  
  2395.   end # // REGEXP
  2396. end # // YGG
  2397.  
  2398. #==============================================================================#
  2399. #
  2400. # OriginalWij and Yanfly Collaboration - Keyboard Input
  2401. # Last Date Updated: 2010.06.12
  2402. #
  2403. #==============================================================================#
  2404. # Updates
  2405. # -----------------------------------------------------------------------------#
  2406. # o 2010.06.12 - Started and Finished Script.
  2407. #==============================================================================#
  2408. unless $imported["KeyboardInput"]
  2409. ($imported ||= {})["KeyboardInput"] = true
  2410. #==============================================================================#
  2411. # ** Input
  2412. #==============================================================================#
  2413. class << Input  
  2414.   #--------------------------------------------------------------------------#
  2415.   # Aliases (Mods - Linked to Module) - Created by OriginalWij
  2416.   #--------------------------------------------------------------------------#
  2417.   alias ow_dt_i_press press? unless $@
  2418.   alias ow_dt_i_trigger trigger? unless $@
  2419.   alias ow_dt_i_repeat repeat? unless $@
  2420.   alias ow_dt_i_update update unless $@
  2421. end
  2422.  
  2423. module Input
  2424.  
  2425.   #--------------------------------------------------------------------------
  2426.   # * initial module settings - Created by OriginalWij and Yanfly
  2427.   #--------------------------------------------------------------------------
  2428.   GetKeyState = Win32API.new( "user32", "GetAsyncKeyState", "i", "i" )
  2429.   GetCapState = Win32API.new( "user32", "GetKeyState", "i", "i" )
  2430.   KeyRepeatCounter = {}
  2431.  
  2432.   module_function()
  2433.   #--------------------------------------------------------------------------
  2434.   # * alias-method :update - Created by OriginalWij
  2435.   #--------------------------------------------------------------------------
  2436.   def update()
  2437.     ow_dt_i_update()
  2438.     for key in KeyRepeatCounter.keys
  2439.       if (GetKeyState.call(key).abs & 0x8000 == 0x8000)
  2440.         KeyRepeatCounter[key] += 1
  2441.       else
  2442.         KeyRepeatCounter.delete(key)
  2443.       end
  2444.     end
  2445.   end
  2446.  
  2447.   #--------------------------------------------------------------------------
  2448.   # * alias-method :press? - Created by OriginalWij
  2449.   #--------------------------------------------------------------------------
  2450.   def press?( key )
  2451.     return ow_dt_i_press(key) if key < 30
  2452.     adjusted_key = adjust_key(key)
  2453.     return true unless KeyRepeatCounter[adjusted_key].nil?
  2454.     return key_pressed?(adjusted_key)
  2455.   end
  2456.  
  2457.   #--------------------------------------------------------------------------
  2458.   # * alias-method :trigger? - Created by OriginalWij
  2459.   #--------------------------------------------------------------------------
  2460.   def trigger?(key)
  2461.     return ow_dt_i_trigger(key) if key < 30
  2462.     adjusted_key = adjust_key(key)
  2463.     count = KeyRepeatCounter[adjusted_key]
  2464.     return ((count == 0) or (count.nil? ? key_pressed?(adjusted_key) : false))
  2465.   end
  2466.  
  2467.   #--------------------------------------------------------------------------
  2468.   # * alias-method :repeat? - Created by OriginalWij
  2469.   #--------------------------------------------------------------------------
  2470.   def repeat?(key)
  2471.     return ow_dt_i_repeat(key) if key < 30
  2472.     adjusted_key = adjust_key(key)
  2473.     count = KeyRepeatCounter[adjusted_key]
  2474.     return true if count == 0
  2475.     if count.nil?
  2476.       return key_pressed?(adjusted_key)
  2477.     else
  2478.       return (count >= 23 and (count - 23) % 6 == 0)
  2479.     end
  2480.   end
  2481.  
  2482.   #--------------------------------------------------------------------------
  2483.   # * new-method :adjust_key - Created by OriginalWij
  2484.   #--------------------------------------------------------------------------
  2485.   def adjust_key(key)
  2486.     key -= 130 if key.between?(130, 158)
  2487.     return key
  2488.   end
  2489.  
  2490.   #--------------------------------------------------------------------------
  2491.   # * new-method :key_pressed? - Created by OriginalWij
  2492.   #--------------------------------------------------------------------------
  2493.   def key_pressed?(key)
  2494.     if (GetKeyState.call(key).abs & 0x8000 == 0x8000)
  2495.       KeyRepeatCounter[key] = 0
  2496.       return true
  2497.     end
  2498.     return false
  2499.   end
  2500.  
  2501.   #--------------------------------------------------------------------------
  2502.   # * new-method :typing? - Created by Yanfly
  2503.   #--------------------------------------------------------------------------
  2504.   def typing?
  2505.     return true if repeat?(SPACE)
  2506.     for i in 'A'..'Z'
  2507.       return true if repeat?(LETTERS[i])
  2508.     end
  2509.     for i in 0...NUMBERS.size
  2510.       return true if repeat?(NUMBERS[i])
  2511.       return true if repeat?(NUMPAD[i])
  2512.     end
  2513.     for key in Extras
  2514.       return true if repeat?(key)
  2515.     end
  2516.     return false
  2517.   end
  2518.  
  2519.   #--------------------------------------------------------------------------
  2520.   # * new-method :key_type - Created by Yanfly
  2521.   #--------------------------------------------------------------------------
  2522.   def key_type()
  2523.     return " " if repeat?(SPACE)
  2524.     for i in 'A'..'Z'
  2525.       next unless repeat?(LETTERS[i])
  2526.       return upcase? ? i.upcase : i.downcase
  2527.     end
  2528.     for i in 0...NUMBERS.size
  2529.       return i.to_s if repeat?(NUMPAD[i])
  2530.       if !press?(SHIFT)
  2531.         return i.to_s if repeat?(NUMBERS[i])
  2532.       elsif repeat?(NUMBERS[i])
  2533.         case i
  2534.         when 1; return "!"
  2535.         when 2; return "@"
  2536.         when 3; return "#"
  2537.         when 4; return "$"
  2538.         when 5; return "%"
  2539.         when 6; return "^"
  2540.         when 7; return "&"
  2541.         when 8; return "*"
  2542.         when 9; return "("
  2543.         when 0; return ")"
  2544.         end
  2545.       end
  2546.     end
  2547.     for key in Extras
  2548.       next unless repeat?(key)
  2549.       case key
  2550.       when USCORE; return press?(SHIFT) ? "_" : "-"
  2551.       when EQUALS; return press?(SHIFT) ? "+" : "="
  2552.       when LBRACE; return press?(SHIFT) ? "{" : "["
  2553.       when RBRACE; return press?(SHIFT) ? "}" : "]"
  2554.       when BSLASH; return press?(SHIFT) ? "|" : "\\"
  2555.       when SCOLON; return press?(SHIFT) ? ":" : ";"
  2556.       when QUOTE;  return press?(SHIFT) ? '"' : "'"
  2557.       when COMMA;  return press?(SHIFT) ? "<" : ","
  2558.       when PERIOD; return press?(SHIFT) ? ">" : "."
  2559.       when SLASH;  return press?(SHIFT) ? "?" : "/"
  2560.       when NMUL;   return "*"
  2561.       when NPLUS;  return "+"
  2562.       when NSEP;   return ","
  2563.       when NMINUS; return "-"
  2564.       when NDECI;  return "."
  2565.       when NDIV;   return "/"
  2566.       end
  2567.     end
  2568.     return ""
  2569.   end
  2570.  
  2571.   #--------------------------------------------------------------------------
  2572.   # * new-method :upcase? - Created by Yanfly
  2573.   #--------------------------------------------------------------------------
  2574.   def upcase?()
  2575.     return !press?(SHIFT) if GetCapState.call(CAPS) == 1
  2576.     return true if press?(SHIFT)
  2577.     return false
  2578.   end
  2579.  
  2580. end # Input
  2581. end
  2582.  
  2583. #==============================================================================#
  2584. # ** Vocab
  2585. #==============================================================================#
  2586. module Vocab
  2587.  
  2588.   #--------------------------------------------------------------------------#
  2589.   # * new-method :maxhp
  2590.   #--------------------------------------------------------------------------#
  2591.   def self.maxhp ; return self.hp ; end
  2592.    
  2593.   #--------------------------------------------------------------------------#
  2594.   # * new-method :maxmp
  2595.   #--------------------------------------------------------------------------#  
  2596.   def self.maxmp ; return self.mp ; end
  2597.    
  2598. end
  2599.  
  2600. #==============================================================================#
  2601. # ** Array
  2602. #==============================================================================#
  2603. class Array
  2604.  
  2605.   #--------------------------------------------------------------------------#
  2606.   # * new-method :rotate
  2607.   #--------------------------------------------------------------------------#  
  2608.   def rotate( n=1 ) ; dup.rotate!( n ) ; end unless method_defined? :rotate
  2609.  
  2610.   #--------------------------------------------------------------------------#
  2611.   # * new-method :rotate!
  2612.   #--------------------------------------------------------------------------#
  2613.   def rotate!( n=1 )
  2614.     return self if empty?
  2615.     n %= size
  2616.     concat( slice!( 0, n ) )
  2617.   end unless method_defined? :rotate!
  2618.  
  2619. end
  2620.  
  2621. #==============================================================================#
  2622. # ** Rect
  2623. #==============================================================================#
  2624. class Rect
  2625.  
  2626.   #--------------------------------------------------------------------------#
  2627.   # * new-method :to_a
  2628.   #--------------------------------------------------------------------------#  
  2629.   def to_a() ; return self.x, self.y, self.width, self.height ; end
  2630.  
  2631.   #--------------------------------------------------------------------------#
  2632.   # * new-method :to_vector4_a
  2633.   #--------------------------------------------------------------------------#  
  2634.   def to_vector4_a()
  2635.     return self.x, self.y, self.x + self.width, self.y + self.height
  2636.   end
  2637.  
  2638. end
  2639.  
  2640. #==============================================================================#
  2641. # ** YGG
  2642. #==============================================================================#
  2643. module YGG
  2644.  
  2645.   #--------------------------------------------------------------------------#
  2646.   # * new-method :get_action_from_line
  2647.   #--------------------------------------------------------------------------#  
  2648.   def self.get_action_from_line( line )
  2649.     case line
  2650.     # // Exception
  2651.     when /SCRIPT:[ ](.*)/i
  2652.       result = [ "SCRIPT", [$1]               ]
  2653.     # // Regular Actions            
  2654.     when ::YGG::REGEXP::BASE_ITEM::ACTION_6
  2655.       result = [ $1, [$2, $3, $4, $5, $6, $7] ]
  2656.     when ::YGG::REGEXP::BASE_ITEM::ACTION_5
  2657.       result = [ $1, [$2, $3, $4, $5, $6]     ]
  2658.     when ::YGG::REGEXP::BASE_ITEM::ACTION_4
  2659.       result = [ $1, [$2, $3, $4, $5]         ]  
  2660.     when ::YGG::REGEXP::BASE_ITEM::ACTION_3
  2661.       result = [ $1, [$2, $3, $4]             ]
  2662.     when ::YGG::REGEXP::BASE_ITEM::ACTION_2
  2663.       result = [ $1, [$2, $3]                 ]  
  2664.     when ::YGG::REGEXP::BASE_ITEM::ACTION_1
  2665.       result = [ $1, [$2]                     ]  
  2666.     else
  2667.       result = [ line, []                     ]
  2668.     end # // case line
  2669.     return result
  2670.   end
  2671.  
  2672. end
  2673.  
  2674. #==============================================================================#
  2675. # ** YGG::Caches1x6
  2676. #==============================================================================#
  2677. module YGG::Caches1x6
  2678.  
  2679.   #--------------------------------------------------------------------------#
  2680.   # * Public Instance Variable(s)
  2681.   #--------------------------------------------------------------------------#  
  2682.   attr_accessor :ygg_actions, :ygg_pre_actions
  2683.   attr_accessor :ygg_target_range
  2684.   attr_accessor :drops_attraction
  2685.   attr_accessor :atk_act_name, :grd_act_name
  2686.   attr_accessor :charge_cap
  2687.   attr_accessor :user_charge_cap
  2688.   attr_accessor :cant_equip_slot
  2689.  
  2690.   #--------------------------------------------------------------------------#
  2691.   # * new-method :ygg_add_to_cache
  2692.   #--------------------------------------------------------------------------#
  2693.   def ygg_add_to_cache( array )
  2694.     unless @__pre_action
  2695.       @ygg_actions[@__current_action].push( array )
  2696.     else  
  2697.       @ygg_pre_actions[@__current_action].push( array )
  2698.     end  
  2699.   end
  2700.  
  2701.   #--------------------------------------------------------------------------#
  2702.   # * new-method :yggdrasil_1x6_cache
  2703.   #--------------------------------------------------------------------------#
  2704.   def yggdrasil_1x6_cache()
  2705.     yggdrasil_1x6_cache_start()
  2706.     self.note.split(/[\r\n]+/).each { |line| yggdrasil_1x6_cache_check( line ) }
  2707.     yggdrasil_1x6_cache_end()
  2708.   end
  2709.  
  2710.   #--------------------------------------------------------------------------#
  2711.   # * new-method :yggdrasil_1x6_cache_start
  2712.   #--------------------------------------------------------------------------#
  2713.   def yggdrasil_1x6_cache_start()
  2714.     @charge_cap      = 0
  2715.     @user_charge_cap = 0
  2716.     @atk_act_name    = ""
  2717.     @grd_act_name    = ""
  2718.     case self
  2719.     when RPG::Item
  2720.       # // Yeah ....
  2721.     when RPG::Weapon
  2722.       @atk_act_name = "Swing1"
  2723.     when RPG::Armor  
  2724.       @grd_act_name = "GRise1"
  2725.     end  
  2726.     @ygg_actions      = {}
  2727.     @ygg_pre_actions  = {}
  2728.     @ygg_target_range = 0
  2729.     @drops_attraction = false
  2730.     @__current_action = -1
  2731.     @__pre_action     = false
  2732.     @cant_equip_slot  = false
  2733.   end
  2734.  
  2735.   #--------------------------------------------------------------------------#
  2736.   # * new-method :yggdrasil_1x6_cache_check
  2737.   #--------------------------------------------------------------------------#
  2738.   def yggdrasil_1x6_cache_check( line )
  2739.     case line
  2740.     # // Action  
  2741.     when ::YGG::REGEXP::BASE_ITEM::ACTION_OPEN
  2742.       @__current_action = $1.to_i
  2743.       @ygg_actions[@__current_action] = []
  2744.       @__pre_action = false
  2745.     when ::YGG::REGEXP::BASE_ITEM::ACTION_CLOSE  
  2746.       @__pre_action = false
  2747.       @__current_action = -1
  2748.     when ::YGG::REGEXP::BASE_ITEM::ACTION_ASSIGN
  2749.       @ygg_actions[$1.to_i] = ::YGG.get_action_list( $2 )
  2750.     # // Pre Action  
  2751.     when ::YGG::REGEXP::BASE_ITEM::PREACTION_OPEN
  2752.       @__current_action = $1.to_i
  2753.       @ygg_pre_actions[@__current_action] = []
  2754.       @__pre_action = true
  2755.     when ::YGG::REGEXP::BASE_ITEM::PREACTION_CLOSE  
  2756.       @__current_action = -1
  2757.       @__pre_action = false
  2758.     when ::YGG::REGEXP::BASE_ITEM::PREACTION_ASSIGN
  2759.       @ygg_pre_actions[$1.to_i] = ::YGG.get_action_list( $2 )  
  2760.      
  2761.     when ::YGG::REGEXP::BASE_ITEM::DROPS_ATTRACT  
  2762.       @drops_attraction = true
  2763.     when ::YGG::REGEXP::BASE_ITEM::CHARGE_CAP  
  2764.       @charge_cap = $1.to_i
  2765.     when ::YGG::REGEXP::BASE_ITEM::USER_CHARGE_CAP  
  2766.       @user_charge_cap = $1.to_i
  2767.      
  2768.     when ::YGG::REGEXP::BASE_ITEM::CANT_EQUIP
  2769.       @cant_equip_slot = true
  2770.     else
  2771.       if @__current_action > -1
  2772.         ygg_add_to_cache( ::YGG.get_action_from_line( line ) )
  2773.       end # // if current_action > -1
  2774.     end # // case line
  2775.   end
  2776.  
  2777.   #--------------------------------------------------------------------------#
  2778.   # * new-method :yggdrasil_1x6_cache_end
  2779.   #--------------------------------------------------------------------------#
  2780.   def yggdrasil_1x6_cache_end()
  2781.     @__current_action = nil ; @__pre_action = nil
  2782.   end
  2783.  
  2784. end  
  2785.  
  2786. #==============================================================================#
  2787. # ** YGG::Containers::GoldItem  
  2788. #==============================================================================#
  2789. class YGG::Containers::GoldItem
  2790.  
  2791.   #--------------------------------------------------------------------------#
  2792.   # * Public Instance Variable(s)
  2793.   #--------------------------------------------------------------------------#  
  2794.   attr_accessor :name
  2795.   attr_accessor :gold_amount
  2796.   attr_accessor :icon_index
  2797.   attr_accessor :pickup_sfx
  2798.  
  2799.   #--------------------------------------------------------------------------#
  2800.   # * new-method :initialize
  2801.   #--------------------------------------------------------------------------#
  2802.   def initialize( amt )
  2803.     @name        = ::Vocab.gold
  2804.     @gold_amount = amt
  2805.     @icon_index  = ::YGG::GOLD_DROP_ICON
  2806.     @pickup_sfx  = ::YGG::SOUND_MONEY
  2807.   end
  2808.  
  2809. end
  2810.  
  2811. #==============================================================================#
  2812. # ** YGG::Handlers::Engage
  2813. #==============================================================================#
  2814. class YGG::Handlers::Engage
  2815.  
  2816.   #--------------------------------------------------------------------------#
  2817.   # * Public Instance Variable(s)
  2818.   #--------------------------------------------------------------------------#
  2819.   attr_accessor :parent
  2820.   attr_accessor :bar_opacity
  2821.  
  2822.   #--------------------------------------------------------------------------#
  2823.   # * new-method :initialize
  2824.   #--------------------------------------------------------------------------#
  2825.   def initialize( parent )
  2826.     @parent      = parent
  2827.     @cool_down   = 0
  2828.     @bar_opacity = 255
  2829.   end
  2830.  
  2831.   #--------------------------------------------------------------------------#
  2832.   # * new-method :engage
  2833.   #--------------------------------------------------------------------------#
  2834.   def engage( cool_down )
  2835.     @cool_down   = cool_down
  2836.     @bar_opacity = 255
  2837.   end
  2838.  
  2839.   #--------------------------------------------------------------------------#
  2840.   # * new-method :engaged?
  2841.   #--------------------------------------------------------------------------#
  2842.   def engaged? ; return @cool_down > 0 ; end
  2843.  
  2844.   #--------------------------------------------------------------------------#
  2845.   # * new-method :update
  2846.   #--------------------------------------------------------------------------#
  2847.   def update()
  2848.     update_cool_down()
  2849.     update_bar_opacity()
  2850.   end
  2851.  
  2852.   #--------------------------------------------------------------------------#
  2853.   # * new-method :update_cool_down
  2854.   #--------------------------------------------------------------------------#
  2855.   def update_cool_down()
  2856.     @cool_down = [@cool_down-1, 0].max
  2857.   end
  2858.  
  2859.   #--------------------------------------------------------------------------#
  2860.   # * new-method :update_bar_opacity
  2861.   #--------------------------------------------------------------------------#
  2862.   def update_bar_opacity()
  2863.     if engaged?()
  2864.       @bar_opacity = [@bar_opacity+(255/60.0), 255].min
  2865.     else
  2866.       @bar_opacity = [@bar_opacity-(255/60.0), 0].max
  2867.     end  
  2868.   end
  2869.  
  2870. end
  2871.  
  2872. #==============================================================================#
  2873. # ** YGG::Handlers::Equip
  2874. #==============================================================================#
  2875. class YGG::Handlers::Equip < YGG::Pos
  2876.  
  2877.   #--------------------------------------------------------------------------#
  2878.   # * Public Instance Variable(s)
  2879.   #--------------------------------------------------------------------------#
  2880.   attr_accessor :parent
  2881.   attr_accessor :icon_index
  2882.   attr_accessor :eq_id
  2883.   attr_accessor :mirror
  2884.   attr_accessor :opacity, :visible
  2885.   attr_accessor :sox, :soy # // Sprite Offset
  2886.   attr_writer   :angle
  2887.  
  2888.   #--------------------------------------------------------------------------#
  2889.   # * new-method :angle_debug # // DEBUG
  2890.   #--------------------------------------------------------------------------#  
  2891.   def angle_debug()
  2892.     #@angle = (@angle + 1) % 360 if @eq_id == 0
  2893.     if Input.trigger?(Input::NUMBERS[1])
  2894.       @sox += 1
  2895.       puts @sox
  2896.     elsif Input.trigger?(Input::NUMBERS[2])
  2897.       @sox -= 1
  2898.       puts @sox
  2899.     elsif Input.trigger?(Input::NUMBERS[3])  
  2900.       @soy += 1
  2901.       puts @soy
  2902.     elsif Input.trigger?(Input::NUMBERS[4])  
  2903.       @soy -= 1
  2904.       puts @soy
  2905.     elsif Input.trigger?(Input::NUMBERS[5])  
  2906.       @sox = 0
  2907.       puts @sox  
  2908.     elsif Input.trigger?(Input::NUMBERS[6])  
  2909.       @soy = 0
  2910.       puts @soy
  2911.     end if @parent.is_a?(Game_Player) if @eq_id == 0
  2912.   end
  2913.  
  2914.   #--------------------------------------------------------------------------#
  2915.   # * new-method :initialize
  2916.   #--------------------------------------------------------------------------#
  2917.   def initialize( parent, eq_id )
  2918.     super( 0, 0, 0 )
  2919.     @parent       = parent
  2920.     @eq_id        = eq_id
  2921.     @icon_index   = @parent.equip_icon( @eq_id )
  2922.     @list         = []
  2923.     @list_index   = 0
  2924.     @sox, @soy    = 20, 20
  2925.     @visible      = false
  2926.     @mirror       = false
  2927.     @angle_offset = 0
  2928.     @angle_mult   = 1
  2929.     @attack_action= ""
  2930.     @guard_action = ""
  2931.     reset()
  2932.   end
  2933.  
  2934.   #--------------------------------------------------------------------------#
  2935.   # * new-method :angle
  2936.   #--------------------------------------------------------------------------#
  2937.   def angle ; return (@angle*@angle_mult)+@angle_offset ; end
  2938.    
  2939.   #--------------------------------------------------------------------------#
  2940.   # * new-method :reset
  2941.   #--------------------------------------------------------------------------#
  2942.   def reset()
  2943.     @wait_count   = 0
  2944.     @opacity      = 255
  2945.     @ox, @oy, @oz = 0, 0, 0
  2946.     @angle        = 0
  2947.   end
  2948.  
  2949.   #--------------------------------------------------------------------------#
  2950.   # * new-method :ox
  2951.   #--------------------------------------------------------------------------#
  2952.   def ox ; return @x + @ox + @sox ; end
  2953.   #--------------------------------------------------------------------------#
  2954.   # * new-method :oy
  2955.   #--------------------------------------------------------------------------#
  2956.   def oy ; return @y + @oy + @soy ; end
  2957.   #--------------------------------------------------------------------------#
  2958.   # * new-method :oz
  2959.   #--------------------------------------------------------------------------#  
  2960.   def oz ; return @z + @oz ; end
  2961.  
  2962.   #--------------------------------------------------------------------------#
  2963.   # * new-method :update
  2964.   #--------------------------------------------------------------------------#  
  2965.   def update()
  2966.     update_list()
  2967.     update_position()
  2968.   end
  2969.  
  2970.   #--------------------------------------------------------------------------#
  2971.   # * new-method :do_action
  2972.   #--------------------------------------------------------------------------#  
  2973.   def do_action( name )
  2974.     @icon_index    = @parent.equip_icon( @eq_id )    
  2975.     @list = ACTIONS[name].clone ; @list_index = 0
  2976.   end
  2977.  
  2978.   #--------------------------------------------------------------------------#
  2979.   # * new-method :do_attack
  2980.   #--------------------------------------------------------------------------#  
  2981.   def do_attack()
  2982.     @attack_action = @parent.equip_atk_act_name( @eq_id )
  2983.     do_action( @attack_action ) unless @attack_action == ""
  2984.   end
  2985.  
  2986.   #--------------------------------------------------------------------------#
  2987.   # * new-method :do_guard
  2988.   #--------------------------------------------------------------------------#  
  2989.   def do_guard()
  2990.     @guard_action  = @parent.equip_grd_act_name( @eq_id )
  2991.     do_action( @guard_action ) unless @guard_action == ""
  2992.   end
  2993.  
  2994.   #--------------------------------------------------------------------------#
  2995.   # * new-method :update_position
  2996.   #--------------------------------------------------------------------------#  
  2997.   def update_position()
  2998.     #self.angle_debug()
  2999.     case @eq_id
  3000.     when 0 # // Weapon
  3001.       oox, ooy = @ox, @oy
  3002.       case @parent.direction
  3003.       when 1 # // Down-Left
  3004.       when 2 # // Down
  3005.         @x, @y, @z = -28, -28, 20
  3006.         @sox, @soy    = 20, 20
  3007.         @ox, @oy = oox, ooy
  3008.         #@angle_offset = 0
  3009.         @angle_mult   = 1
  3010.         @mirror = false
  3011.       when 3 # // Down-Right  
  3012.       when 4 # // Left
  3013.         @x, @y, @z = -24, -28, -20
  3014.         @sox, @soy    = 20, 20
  3015.         @ox, @oy = -ooy, -oox
  3016.         #@angle_offset = 0
  3017.         @angle_mult   = 1
  3018.         @mirror = false
  3019.       when 6 # // Right
  3020.         @x, @y, @z = -4, -28, 20
  3021.         @sox, @soy    = 5, 20
  3022.         @ox, @oy = ooy, oox
  3023.         #@angle_offset = 0
  3024.         @angle_mult   = -1
  3025.         @mirror = true
  3026.       when 7 # // Up-Left  
  3027.       when 8 # // Up
  3028.         @x, @y, @z = 4, -28, -20
  3029.         @sox, @soy    = 5, 20
  3030.         @ox, @oy = -oox, ooy
  3031.         #@angle_offset = 0
  3032.         @angle_mult   = -1
  3033.         @mirror = true
  3034.       when 9 # // Up-Right
  3035.       end  
  3036.     when 1 # // Shield
  3037.       case @parent.direction
  3038.       when 1 # // Down-Left
  3039.       when 2 # // Down
  3040.         @x, @y, @z = 0, -24, 20
  3041.         @mirror = true
  3042.       when 3 # // Down-Right  
  3043.       when 4 # // Left
  3044.         @x, @y, @z = -16, -24, 20
  3045.         @mirror = false
  3046.       when 6 # // Right
  3047.         @x, @y, @z = -4, -28, -20
  3048.         @mirror = true
  3049.       when 7 # // Up-Left  
  3050.       when 8 # // Up
  3051.         @x, @y, @z = -24, -24, -20
  3052.         @mirror = false
  3053.       when 9 # // Up-Right
  3054.       end  
  3055.     end  
  3056.   end
  3057.  
  3058.   #--------------------------------------------------------------------------#
  3059.   # * new-method :update_list
  3060.   #--------------------------------------------------------------------------#  
  3061.   def update_list()
  3062.     @wait_count = [@wait_count - 1, 0].max
  3063.     return unless @wait_count == 0
  3064.     while @list_index < @list.size
  3065.       ret_value = -1
  3066.       act = @list[@list_index]
  3067.       case act[0].upcase
  3068.       when "MOVE"
  3069.         case act[1].upcase
  3070.         when "X" ; @ox = act[2]
  3071.         when "Y" ; @oy = act[2]
  3072.         when "Z" ; @oz = act[2] # // For whatever reason
  3073.         end  
  3074.         ret_value = 0
  3075.       when "CHANGEANGLE", "CHANGE_ANGLE", "CHANGE ANGLE"
  3076.         @angle = act[1]
  3077.         ret_value = 0
  3078.       when "RESET"
  3079.         reset()
  3080.         ret_value = 0
  3081.       when "CHANGEOPACITY", "CHANGE_OPACITY", "CHANGE OPACITY"  
  3082.         @opacity = act[1]
  3083.         ret_value = 0
  3084.       when "SHOW"  
  3085.         @visible = true
  3086.         ret_value = 0
  3087.       when "HIDE"  
  3088.         @visible = false
  3089.         ret_value = 0
  3090.       when "WAIT FOR GUARD"  
  3091.         return if @parent.guard_time > 0
  3092.         ret_value = 0
  3093.       when "WAIT"  
  3094.         @wait_count = act[1]
  3095.         ret_value = 1
  3096.       end  
  3097.       @list_index += 1
  3098.       return if ret_value == 1
  3099.     end  
  3100.   end
  3101.  
  3102. end
  3103.  
  3104. #==============================================================================#
  3105. # ** YGG::Handlers::BattleObj
  3106. #==============================================================================#
  3107. class YGG::Handlers::BattleObj
  3108.  
  3109.   #--------------------------------------------------------------------------#
  3110.   # * Public Instance Variable(s)
  3111.   #--------------------------------------------------------------------------#  
  3112.   attr_accessor :obj_id
  3113.   attr_accessor :type
  3114.  
  3115.   #--------------------------------------------------------------------------#
  3116.   # * new-method :initialize
  3117.   #--------------------------------------------------------------------------#  
  3118.   def initialize( id, type )
  3119.     @obj_id, @type = id, type ; @charge_time = 0 ;
  3120.     @dummy_obj = RPG::BaseItem.new() ; @dummy_obj.yggdrasil_1x6_cache()
  3121.   end
  3122.  
  3123.   #--------------------------------------------------------------------------#
  3124.   # * new-method :skill
  3125.   #--------------------------------------------------------------------------#  
  3126.   def skill()
  3127.     return @type == :skill ? $data_skills[@obj_id] : nil
  3128.   end
  3129.  
  3130.   #--------------------------------------------------------------------------#
  3131.   # * new-method :item
  3132.   #--------------------------------------------------------------------------#
  3133.   def item()
  3134.     return @type == :item ? $data_items[@obj_id] : nil
  3135.   end
  3136.  
  3137.   #--------------------------------------------------------------------------#
  3138.   # * new-method :obj
  3139.   #--------------------------------------------------------------------------#  
  3140.   def obj()
  3141.     return item() || skill() || @dummy_obj
  3142.   end
  3143.  
  3144.   #--------------------------------------------------------------------------#
  3145.   # * new-method :reset_time
  3146.   #--------------------------------------------------------------------------#  
  3147.   def reset_time()
  3148.     @charge_time = cap
  3149.   end
  3150.  
  3151.   #--------------------------------------------------------------------------#
  3152.   # * new-method :time
  3153.   #--------------------------------------------------------------------------#  
  3154.   def time()
  3155.     return @charge_time
  3156.   end
  3157.  
  3158.   #--------------------------------------------------------------------------#
  3159.   # * new-method :cap
  3160.   #--------------------------------------------------------------------------#  
  3161.   def cap()
  3162.     return obj.charge_cap
  3163.   end
  3164.  
  3165.   #--------------------------------------------------------------------------#
  3166.   # * new-method :can_use?
  3167.   #--------------------------------------------------------------------------#  
  3168.   def can_use?() ; return @charge_time == 0 ; end
  3169.  
  3170.   #--------------------------------------------------------------------------#
  3171.   # * new-method :update
  3172.   #--------------------------------------------------------------------------#  
  3173.   def update()
  3174.     @charge_time = [@charge_time - 1, 0].max
  3175.   end
  3176.  
  3177. end
  3178.  
  3179. #==============================================================================#
  3180. # ** YGG::System (Battle Edits)
  3181. #==============================================================================#
  3182. class YGG::System
  3183.  
  3184.   #--------------------------------------------------------------------------#
  3185.   # * new-method :action_attack
  3186.   #--------------------------------------------------------------------------#  
  3187.   def action_attack( user_ev, targets_ev )
  3188.     user = user_ev.ygg_battler
  3189.     targets_ev.each { |target|
  3190.       next if target.ygg_invincible
  3191.       bat = target.ygg_battler
  3192.       next if bat.nil?()
  3193.       bat.ygg_guard = target.guard_time > 0
  3194.       bat.attack_effect( user )
  3195.       target.ygg_engage.engage( 180 )
  3196.       YGG::PopText.create_pop( { :character => target, :type => :attack_damage } ) if target.pop_enabled?() if YGG::USE_TEXT_POP        
  3197.       action_gain_exp( user, bat, user_ev, YGG::POP_EXP ) unless bat.actor?() if user.actor?()
  3198.       bat.ygg_guard = false
  3199.     }
  3200.   end
  3201.  
  3202.   #--------------------------------------------------------------------------#
  3203.   # * new-method :action_skill
  3204.   #--------------------------------------------------------------------------#  
  3205.   def action_skill( user_ev, targets_ev, obj )
  3206.     targets = targets_ev.inject([]) { |r, e| r << e.ygg_battler }
  3207.     targets.compact!() ; user = user_ev.ygg_battler
  3208.     targets_ev.each { |target|
  3209.       next if target.ygg_invincible
  3210.       bat = target.ygg_battler
  3211.       next if bat.nil?()
  3212.       bat.ygg_guard = target.guard_time > 0 && obj.guardable
  3213.       bat.skill_effect( user, obj )
  3214.       target.ygg_engage.engage( 180 )
  3215.       YGG::PopText.create_pop( { :character => target, :type => :skill_damage } ) if target.pop_enabled?() if YGG::USE_TEXT_POP              
  3216.       action_gain_exp( user, bat, user_ev, YGG::POP_EXP ) unless bat.actor?() if user.actor?()
  3217.       bat.ygg_guard = false
  3218.     }
  3219.   end
  3220.  
  3221.   #--------------------------------------------------------------------------#
  3222.   # * new-method :action_item
  3223.   #--------------------------------------------------------------------------#  
  3224.   def action_item( user_ev, targets_ev, obj )
  3225.     targets = targets_ev.inject([]) { |r, e| r << e.ygg_battler }
  3226.     targets.compact!() ; user = user_ev.ygg_battler
  3227.     targets_ev.each { |target|
  3228.       next if target.ygg_invincible
  3229.       bat = target.ygg_battler
  3230.       next if bat.nil?()
  3231.       bat.ygg_guard = target.guard_time > 0 && obj.guardable
  3232.       bat.item_effect( user, obj )
  3233.       target.ygg_engage.engage( 180 )
  3234.       YGG::PopText.create_pop( { :character => target, :type => :item_damage } ) if target.pop_enabled?() if YGG::USE_TEXT_POP              
  3235.       action_gain_exp( user, bat, user_ev, YGG::POP_EXP ) unless bat.actor?() if user.actor?()
  3236.       bat.ygg_guard = false
  3237.     }
  3238.   end
  3239.  
  3240.   #--------------------------------------------------------------------------#
  3241.   # * new-method :action_gain_exp
  3242.   #--------------------------------------------------------------------------#  
  3243.   def action_gain_exp( receivee, bat, event=nil, show=true )
  3244.     case YGG::EXP_GAINING_METHOD
  3245.     when 0 # // Dead
  3246.       return unless bat.dead?()
  3247.       exp = bat.exp
  3248.     when 1 # // Per Hit
  3249.       exp = YGG::EXP_PER_HIT_FORMULA.call(
  3250.         bat.hp_damage+receivee.mp_damage, receivee, bat )
  3251.     end  
  3252.     old_level = receivee.level
  3253.     case YGG::EXP_SAHRE_METHOD
  3254.     when 0 # Active Member Only
  3255.       receivee.gain_exp( exp, false )
  3256.     when 1 # All Members Equal
  3257.       ($game_party.members-[receivee]).each { |mem| mem.gain_exp( exp, false ) }
  3258.       receivee.gain_exp( exp, false )
  3259.     when 2 # All Members Split
  3260.       mems = ($game_party.members-[receivee])
  3261.       exp /= mems.size+1
  3262.       mems.each { |mem| mem.gain_exp( exp, false ) }
  3263.       receivee.gain_exp( exp, false )
  3264.     end          
  3265.     action_level_up( receivee, old_level, event, YGG::POP_LEVEL_UP ) if old_level != receivee.level
  3266.     unless event.nil?()
  3267.       ::YGG::PopText.create_pop(
  3268.         { :character => event, :type => :gain_exp, :parameters => [exp] }
  3269.       ) if YGG::USE_TEXT_POP                
  3270.     end if show
  3271.   end
  3272.  
  3273.   #--------------------------------------------------------------------------#
  3274.   # * new-method :action_level_up
  3275.   #--------------------------------------------------------------------------#
  3276.   def action_level_up( receivee, old_level, event=nil, show=true )
  3277.     $scene.level_up_window.show_level_up( receivee, old_level ) if YGG::USE_LEVEL_UP_WINDOW > 0
  3278.     unless event.nil?()
  3279.       if ::YGG::LEVEL_UP_ALERT
  3280.         event.ygg_anims << ::YGG::ANIM_ON_LEVEL unless ::YGG::ANIM_ON_LEVEL == 0
  3281.       end  
  3282.       ::YGG::PopText.create_pop(
  3283.         { :character => event, :type => :level_up, :parameters => [old_level] }
  3284.       ) if show if YGG::USE_TEXT_POP              
  3285.     end
  3286.   end
  3287.  
  3288. end
  3289.  
  3290. #==============================================================================#
  3291. # ** YGG::Handlers::Action
  3292. #==============================================================================#
  3293. class YGG::Handlers::Action
  3294.  
  3295.   #--------------------------------------------------------------------------#
  3296.   # * Public Instance Variable(s)
  3297.   #--------------------------------------------------------------------------#  
  3298.   attr_accessor :list
  3299.   attr_accessor :list_stack
  3300.   attr_accessor :skill_id, :item_id
  3301.   attr_accessor :user_event
  3302.   attr_accessor :target_events
  3303.   attr_accessor :parent_event
  3304.  
  3305.   #--------------------------------------------------------------------------#
  3306.   # * new-method :initialize
  3307.   #--------------------------------------------------------------------------#  
  3308.   def initialize( parent, list=[] )
  3309.     @parent_event = parent
  3310.     @interpreter  = ::Game_Interpreter.new()
  3311.     @list_stack   = [] ; setup( list ) ; execute( nil, [], { :skip_first_update=>true } )
  3312.   end
  3313.  
  3314.   #--------------------------------------------------------------------------#
  3315.   # * new-method :setup
  3316.   #--------------------------------------------------------------------------#  
  3317.   def setup( list=[] )
  3318.     @list        = list.clone
  3319.     @active_list = @list.clone
  3320.   end
  3321.  
  3322.   #--------------------------------------------------------------------------#
  3323.   # * new-method :busy?
  3324.   #--------------------------------------------------------------------------#  
  3325.   def busy?()
  3326.     return @list_index < @active_list.size || @interpreter.running?()
  3327.   end
  3328.  
  3329.   #--------------------------------------------------------------------------#
  3330.   # * new-method :execute
  3331.   #--------------------------------------------------------------------------#  
  3332.   def execute( user_event, starting_targets=[], start_values={} )
  3333.     @active_list    = @list.clone
  3334.     @wait_count     = start_values[:wait_count] || 0
  3335.     @skill_id       = start_values[:skill_id] || 0
  3336.     @item_id        = start_values[:item_id] || 0
  3337.     @range          = start_values[:range] || []
  3338.     @target_events  = starting_targets
  3339.     @user_event     = user_event
  3340.     @wait_for_comev = false
  3341.     @list_index     = 0
  3342.     update() unless start_values[:skip_first_update]
  3343.   end
  3344.  
  3345.   #--------------------------------------------------------------------------#
  3346.   # * new-method :update
  3347.   #--------------------------------------------------------------------------#  
  3348.   def update()
  3349.     @interpreter.update()
  3350.     return if @interpreter.running?() && @wait_for_comev
  3351.     @wait_count = [@wait_count-1, 0].max
  3352.     update_action() if @wait_count == 0
  3353.   end
  3354.  
  3355.   #--------------------------------------------------------------------------#
  3356.   # * new-method :update_action
  3357.   #--------------------------------------------------------------------------#  
  3358.   def update_action()
  3359.     unless @list_stack.empty?()
  3360.       setup( @list_stack.shift() )
  3361.       execute( @user_event, @target_events,
  3362.        {
  3363.         :skill_id => @skill_id,
  3364.         :item_id  => @item_id,
  3365.         :range    => @range
  3366.        }
  3367.       )
  3368.     end if @list_index >= @active_list.size
  3369.     while @list_index < @active_list.size
  3370.       #break if act_set.nil?()
  3371.       @action, @parameters = *@active_list[@list_index]
  3372.       #for i in 0...@parameters.size() ; @parameters[i] = @parameters[i].to_s() ; end
  3373.       act_result = -1
  3374.       #puts sprintf("ACTION: %s", @action)
  3375.       #puts sprintf("PARAMETERS: %s", @parameters)
  3376.       case @action.upcase()
  3377.       # // action: action_name
  3378.       when "ACTION", "ACTIONLIST", "ACTION LIST", "ACTION_LIST"
  3379.         act_result = action_actionlist( @action, @parameters )
  3380.       when "ANIMATION"
  3381.         act_result = action_animation( @action, @parameters )
  3382.       when "COMMONEVENT", "COMMON_EVENT", "COMMON EVENT"  
  3383.         act_result = action_common_event( @action, @parameters )
  3384.       when "ATTACKEFFECT", "ATTACK_EFFECT", "ATTACK EFFECT"
  3385.         act_result = action_effect( @action, @parameters )
  3386.       when "SKILLEFFECT", "SKILL_EFFECT", "SKILL EFFECT"
  3387.         act_result = action_effect( @action, @parameters )
  3388.       when "ITEMEFFECT", "ITEM_EFFECT", "ITEM EFFECT"  
  3389.         act_result = action_effect( @action, @parameters )
  3390.       when "OBJEFFECT", "OBJ_EFFECT", "OBJ EFFECT"    
  3391.         eff = @skill_id > 0 ? "SKILL_EFFECT" : nil
  3392.         eff = @item_id > 0 ? "ITEM_EFFECT" : "" if eff.nil?()
  3393.         act_result = action_effect( eff, @parameters+["PRESET"] )
  3394.       when "GUARD"  
  3395.         act_result = action_guard( @action, @parameters )
  3396.       when "CHARGE", "COOLDOWN"  
  3397.         act_result = action_charge( @action, @parameters )
  3398.       when "RANGE"  
  3399.         act_result = action_range( @action, @parameters )
  3400.       when "TARGET"  
  3401.         action_target( @action, @parameters )
  3402.         act_result = 0
  3403.       when "SUBTARGET"
  3404.         act_result = action_subtargets( @action, @parameters )  
  3405.       when "TARGET_SELECT", "TARGET SELECT", "TARGETSELECT"
  3406.         act_result = action_target_select( @action, @parameters )
  3407.       when "SET_ORIGIN", "SET ORIGIN", "SETORIGIN"
  3408.         act_result = action_origin( @action, @parameters )
  3409.       when "MOVE"  
  3410.         act_result = action_move( @action, @parameters )
  3411.       when "JUMP"  
  3412.         act_result = action_jump( @action, @parameters )  
  3413.       when "SETITEM", "SET_ITEM", "SET ITEM"  
  3414.         act_result = action_set_item( @action, @parameters )
  3415.       when "SETSKILL", "SET_SKILL", "SET SKILL"  
  3416.         act_result = action_set_skill( @action, @parameters )
  3417.       when "PROJECTILE"  
  3418.         act_result = action_projectile( @action, @parameters )
  3419.       when "SCRIPT"  
  3420.         act_result = action_script( @action, @parameters )
  3421.       when "THROUGH"  
  3422.         act_result = action_through( @action, @parameters )
  3423.       when "PARENTWAIT", "PARENT_WAIT", "PARENT WAIT"  
  3424.         act_result = action_parent_wait( @action, @parameters )
  3425.       when "WAIT", "WAIT_FOR_EVENT", "WAIT FOR ANIMATION"
  3426.         act_result = action_wait( @action, @parameters )
  3427.       else
  3428.         act_result = extended_actions( @action, @parameters )
  3429.       end
  3430.       if act_result == -1
  3431.         puts "ERROR: -1 returned for action #{self}"
  3432.       else
  3433.         puts "BING: #{act_result} returned for action #{self}"
  3434.       end if YGG.debug_mode?
  3435.       @list_index += 1
  3436.       break if act_result == 1
  3437.     end
  3438.   end
  3439.  
  3440.   #--------------------------------------------------------------------------#
  3441.   # * new-method :extended_actions
  3442.   #--------------------------------------------------------------------------#  
  3443.   def extended_actions( action, parameters )
  3444.   end
  3445.  
  3446.   #--------------------------------------------------------------------------#
  3447.   # * new-method :action_set_skill
  3448.   #--------------------------------------------------------------------------#  
  3449.   def action_set_skill( action, parameters )
  3450.     @skill_id = parameters[0].to_i
  3451.     return 0
  3452.   end  
  3453.  
  3454.   #--------------------------------------------------------------------------#
  3455.   # * new-method :action_set_item
  3456.   #--------------------------------------------------------------------------#  
  3457.   def action_set_item( action, parameters )
  3458.     @item_id = parameters[0].to_i
  3459.     return 0
  3460.   end  
  3461.  
  3462.   #--------------------------------------------------------------------------#
  3463.   # * new-method :action_actionlist
  3464.   #--------------------------------------------------------------------------#  
  3465.   def action_actionlist( action, parameters )
  3466.     @active_list = @active_list.slice(0, @list_index) +
  3467.       ::YGG.get_action_list( parameters[0] ) +
  3468.       @active_list.slice( @list_index, @active_list.size )
  3469.     return 0
  3470.   end  
  3471.  
  3472.   #--------------------------------------------------------------------------#
  3473.   # * new-method :action_animation
  3474.   #--------------------------------------------------------------------------#              
  3475.   def action_animation( action, parameters )
  3476.     p0 = parameters[0].to_s.upcase()
  3477.     p1 = parameters[1].upcase()
  3478.     p2 = parameters[2].upcase()
  3479.    
  3480.     id = 0
  3481.     case p0
  3482.     when "OBJ"
  3483.       id = $data_skills[@skill_id].animation_id if @skill_id > 0
  3484.       id = $data_items[@item_id].animation_id    if @item_id > 0
  3485.       id = @user_event.ygg_battler.atk_animation_id() if id == -1
  3486.     when "ATK", "ATTACK"  
  3487.       id = @user_event.ygg_battler.atk_animation_id()
  3488.     else
  3489.       id = p0.to_i
  3490.     end  
  3491.    
  3492.     case p1  
  3493.     when "POS"  
  3494.       event = @user_event
  3495.       x, y = *YGG.offset_xy(
  3496.        event.x, event.y,
  3497.        [parameters[3].to_i(), parameters[4].to_i()],
  3498.        event.direction )
  3499.       targets = action_target( "TARGET", ["MAP_XY", x, y], true )
  3500.       case p2
  3501.       when "NORMAL"
  3502.         targets.each { |t| t.animation_id = id }
  3503.       when "WILD"    
  3504.         $scene.push_ygg_anim( id, x, y, targets, false ) if $scene.is_a?( Scene_Map )
  3505.       end
  3506.     else
  3507.       action_target( "TARGET", [p1] ).each { |t|
  3508.         case p2
  3509.         when "NORMAL" ; t.animation_id = id
  3510.         when "WILD"   ; t.ygg_anims.push( id )
  3511.         end
  3512.       }  
  3513.     end
  3514.     return 0
  3515.   end
  3516.  
  3517.   #--------------------------------------------------------------------------#
  3518.   # * new-method :action_origin
  3519.   #--------------------------------------------------------------------------#  
  3520.   def action_origin( action, parameters )
  3521.     action_target( "TARGET", parameters, true ).each { |character|
  3522.       character.set_orgin() }
  3523.   end  
  3524.    
  3525.   #--------------------------------------------------------------------------#
  3526.   # * new-method :action_move
  3527.   #--------------------------------------------------------------------------#    
  3528.   def action_move( action, parameters )
  3529.     targets = action_target( "TARGET", [parameters[0]], true )
  3530.     targets.each { |character|
  3531.       case parameters[1].upcase
  3532.       when "FORWARD"
  3533.         character.move_forward()
  3534.       when "BACKWARD"
  3535.         character.move_backward()  
  3536.       when "UP"
  3537.         character.move_up()
  3538.       when "DOWN"
  3539.         character.move_down()
  3540.       when "LEFT"
  3541.         character.move_left()
  3542.       when "RIGHT"
  3543.         character.move_right()
  3544.       when "TO"  
  3545.         case parameters[2]
  3546.         when "ORIGIN"
  3547.           character.moveto( character.origin.x, character.origin.y )
  3548.         else
  3549.           prms = parameters.slice( 2, parameters.size )
  3550.           action_targets( "TARGET", prms, true ).each { |target|
  3551.             character.moveto( target.x, target.y )
  3552.           }
  3553.         end  
  3554.       when "TOXY", "TO_XY", "TO XY"  
  3555.         dist, sway = parameters[2], parameters[3]
  3556.         case character.direction
  3557.         when 2 # // Down
  3558.           x, y = character.x+sway, character.y+dist
  3559.         when 4 # // Left
  3560.           x, y = character.x-dist, character.y+sway
  3561.         when 6 # // Right
  3562.           x, y = character.x+dist, character.y-sway
  3563.         when 8 # // Up
  3564.           x, y = character.x-sway, character.y-dist
  3565.         end
  3566.         character.moveto( x, y )
  3567.       when "TOMAPXY", "TO_MAP_XY", "TO MAP XY"  
  3568.         character.moveto( parameters[2].to_i, parameters[3].to_i )
  3569.       when "TURNUP", "TURN_UP", "TURN UP"
  3570.         character.turn_up()
  3571.       when "TURNDOWN", "TURN_DOWN", "TURN DOWN"
  3572.         character.turn_down()
  3573.       when "TURNLEFT", "TURN_LEFT", "TURN LEFT"
  3574.         character.turn_left()
  3575.       when "TURNRIGHT", "TURN_RIGHT", "TURN RIGHT"
  3576.         character.turn_right()
  3577.       when "TURNRIGHT90", "TURN_RIGHT_90", "TURN RIGHT 90"
  3578.         character.turn_right_90()
  3579.       when "TURNLEFT90", "TURN_LEFT_90", "TURN LEFT 90"
  3580.         character.turn_left_90()  
  3581.       when "TURN180", "TURN_180", "TURN 180"
  3582.         character.turn_180()
  3583.       when "TURNTO", "TURN_TO", "TURN TO"
  3584.         prms = parameters.slice( 2, parameters.size )
  3585.         action_targets( "TARGET", prms, true ).each { |target|
  3586.           character.turn_to_coord( target.x, target.y ) }
  3587.       end
  3588.     }  
  3589.     return 0
  3590.   end
  3591.  
  3592.   #--------------------------------------------------------------------------#
  3593.   # * new-method :action_jump
  3594.   #--------------------------------------------------------------------------#    
  3595.   def action_jump( action, parameters )  
  3596.     users = action_target( "TARGET", parameters[0], true )
  3597.     users.each { |character|
  3598.       case parameters[1].upcase
  3599.       when "XY"
  3600.         character.jump( parameters[2].to_i, parameters[3].to_i )
  3601.       else
  3602.         action_target( "TARGET", parameters[1], true ).each { |t|
  3603.           character.jump_to_char( t )
  3604.         }
  3605.       end  
  3606.     }
  3607.     return 0
  3608.   end
  3609.  
  3610.   #--------------------------------------------------------------------------#
  3611.   # * new-method :action_charge
  3612.   #--------------------------------------------------------------------------#    
  3613.   def action_charge( action, parameters )
  3614.     targets = action_target( "TARGET", parameters[0], true )
  3615.     value = parameters[2].upcase == "MAX" ? t.ygg_battler.cooldown_max : parameters[2].to_i
  3616.     case parameters[1].upcase
  3617.     when "ADD"
  3618.       targets.each { |t| t.ygg_battler.cooldown += value }
  3619.     when "SUB"  
  3620.       targets.each { |t| t.ygg_battler.cooldown -= value }
  3621.     when "SET"  
  3622.       targets.each { |t| t.ygg_battler.cooldown  = value }
  3623.     end  
  3624.     return 0
  3625.   end
  3626.  
  3627.   #--------------------------------------------------------------------------#
  3628.   # * new-method :action_common_event
  3629.   #--------------------------------------------------------------------------#  
  3630.   def action_common_event( action, parameters )
  3631.     case parameters[0].upcase
  3632.     when "SKILL"
  3633.       common_event_id = $data_skills[parameters[1].to_i].common_event_id
  3634.     when "ITEM"  
  3635.       common_event_id = $data_items[parameters[1].to_i].common_event_id
  3636.     when "OBJ"  
  3637.       if @skill_id > 0
  3638.         action_common_event( "COMMON_EVENT", ["SKILL", @skill_id, parameters[2]] )
  3639.       elsif @item_id > 0
  3640.         action_common_event( "COMMON_EVENT", ["ITEM", @item_id, parameters[2]] )
  3641.       end  
  3642.       return
  3643.     when "ID"  
  3644.       common_event_id = parameters[1].to_i
  3645.     end  
  3646.     @interpreter.setup( $data_common_events[common_event_id].list )
  3647.     @wait_for_comev = parameters[2].to_s.upcase == "WAIT"
  3648.     return @wait_for_comev ? 1 : 0
  3649.   end
  3650.  
  3651.   #--------------------------------------------------------------------------#
  3652.   # * new-method :action_range
  3653.   #--------------------------------------------------------------------------#      
  3654.   def action_range( action, parameters )
  3655.     case parameters[0].upcase
  3656.     when "ADD"
  3657.       @range.push( [ parameters[1].to_i, parameters[2].to_i ] )
  3658.     when "SUB"  
  3659.       @range -= [[ parameters[1].to_i, parameters[2].to_i ]]
  3660.     when "CLEAR"  
  3661.       @range.clear()
  3662.     when "CREATE"  
  3663.       rng, minrng, type = parameters[1].to_i, parameters[2].to_i, parameters[3].to_i
  3664.       target = action_target( "TARGET", [parameters[4].to_s], true )[0]
  3665.       direction = target.nil?() ? parameters[4].to_i : target.direction
  3666.       @range = YGG.create_range_data( rng, minrng, type, direction )
  3667.     end  
  3668.     return 0
  3669.   end  
  3670.  
  3671.   #--------------------------------------------------------------------------#
  3672.   # * new-method :action_target
  3673.   #--------------------------------------------------------------------------#          
  3674.   def action_target( action, parameters, return_only=false )
  3675.     raise "Parameter is not an array" unless parameters.is_a?( Array )
  3676.     targets = []
  3677.     case parameters[0].upcase()
  3678.     when "PARENT"
  3679.       targets = [ @parent_event ]
  3680.     when "USER"
  3681.       targets = [ @user_event ]
  3682.     when "TARGET"  
  3683.       targets = [ @target_events[0] ]
  3684.     when "TARGETS"  
  3685.       targets = @target_events
  3686.     when "ALLIES"  
  3687.       targets = @target_events.inject([]) { |r, e| r.push( e ) if @user_event.ally_character?( e ) ; r }
  3688.     when "ENEMIES"  
  3689.       targets = @target_events.inject([]) { |r, e| r.push( e ) if @user_event.enemy_character?( e ) ; r }
  3690.     when "RANDTARGET"  
  3691.       targets = action_target( "TARGET", ["TARGETS"], true )
  3692.       targets = [targets[rand(targets.size)]]
  3693.     when "RANDALLY"  
  3694.       targets = action_target( "TARGET", ["ALLIES"], true )
  3695.       targets = [targets[rand(targets.size)]]  
  3696.     when "RANDENEMY"  
  3697.       targets = action_target( "TARGET", ["ENEMIES"], true )
  3698.       targets = [targets[rand(targets.size)]]    
  3699.     when "SCREEN", "ONSCREEN", "ON_SCREEN"  
  3700.       $game_yggdrasil.battlers.each { |ev|
  3701.         targets.push( ev ) if ev.limitedOnScreen?()
  3702.       }
  3703.     when "OFFSCREEN", "OFF_SCREEN"  
  3704.       $game_yggdrasil.battlers.each { |ev|
  3705.         targets.push( ev ) if !ev.limitedOnScreen?()
  3706.       }
  3707.     when "MAP_XY"
  3708.       xy_list = [ [parameters[1].to_i, parameters[2].to_i] ]
  3709.       targets = @user_event.get_target_events( xy_list )
  3710.     when "XY"  
  3711.       xy_list = [ [parameters[1].to_i, parameters[2].to_i] ]
  3712.       xy_list = YGG::offset_xy_list( @user_event.x, @user_event.y, xy_list, @user_event.direction )
  3713.       targets = @user_event.get_target_events( xy_list )
  3714.     when "RANGE"  
  3715.       xy_list = @range
  3716.       xy_list = YGG::offset_xy_list( @user_event.x, @user_event.y, xy_list, @user_event.direction )
  3717.       targets = @user_event.get_target_events( xy_list )
  3718.     end
  3719.     targets = targets.compact.uniq
  3720.     @target_events = targets unless return_only
  3721.     return targets
  3722.   end
  3723.  
  3724.   #--------------------------------------------------------------------------#
  3725.   # * new-method :action_subtargets
  3726.   #--------------------------------------------------------------------------#  
  3727.   def action_subtargets( action, parameters )
  3728.     @target_events -= action_target( "TARGET", parameters, true )
  3729.     return 0
  3730.   end
  3731.  
  3732.   #--------------------------------------------------------------------------#
  3733.   # * new-method :action_target_select
  3734.   #--------------------------------------------------------------------------#  
  3735.   def action_target_select( action, parameters )
  3736.     if @parent_event.ai_operated?()
  3737.       targs = action_target( "TARGET", parameters.slice( 1, parameters.size ) ).sort_by { rand }
  3738.       result = [] ; for i in 0...parameters[0].to_i ; result.push( targs[i] ) ; end
  3739.       @target_events = result.compact.uniq
  3740.     else  
  3741.       @target_events = $game_yggdrasil.start_target_selection( parameters[0].to_i,
  3742.         action_target( "TARGET", parameters.slice( 1, parameters.size ), true ) )
  3743.     end    
  3744.     return 0
  3745.   end
  3746.  
  3747.   #--------------------------------------------------------------------------#
  3748.   # * new-method :action_effect
  3749.   #--------------------------------------------------------------------------#            
  3750.   def action_effect( action, parameters )
  3751.     users   = action_target( "TARGET", [parameters[0]], true )
  3752.     targets = action_target( "TARGET", [parameters[1]], true )
  3753.     case action.upcase()
  3754.     when "ATTACKEFFECT", "ATTACK_EFFECT", "ATTACK EFFECT"
  3755.       users.each { |user|
  3756.         user.equip_handle( 0 ).do_attack()
  3757.         $game_yggdrasil.action_attack( user, targets )
  3758.       }  
  3759.     when "SKILLEFFECT", "SKILL_EFFECT", "SKILL EFFECT"  
  3760.       users.each { |user|
  3761.         case parameters[2].upcase()
  3762.         when "PRESET", "OBJ"
  3763.           sid = @skill_id
  3764.         else ; sid = parameters[2].to_i
  3765.         end  
  3766.         $game_yggdrasil.action_skill( user, targets, $data_skills[sid] )
  3767.       }  
  3768.     when "ITEMEFFECT", "ITEM_EFFECT", "ITEM EFFECT"  
  3769.       users.each { |user|
  3770.         case parameters[2].upcase()
  3771.         when "PRESET", "OBJ"
  3772.           iid = @item_id
  3773.         else ; iid = parameters[2].to_i
  3774.         end  
  3775.         $game_yggdrasil.action_item( user, targets, $data_items[iid] )
  3776.       }  
  3777.     end  
  3778.     return 0
  3779.   end
  3780.  
  3781.   #--------------------------------------------------------------------------#
  3782.   # * new-method :action_guard
  3783.   #--------------------------------------------------------------------------#                  
  3784.   def action_guard( action, parameters )
  3785.     @user_event.guard_time = parameters[0].to_i
  3786.     @user_event.equip_handle( 1 ).do_guard()
  3787.   end
  3788.  
  3789.   #--------------------------------------------------------------------------#
  3790.   # * new-method :action_projectile
  3791.   #--------------------------------------------------------------------------#                  
  3792.   def action_projectile( action, parameters )
  3793.     users = action_target( "TARGET", [parameters[0]], true )
  3794.     case parameters[1].upcase
  3795.     when "PARENT"
  3796.       direction = action_target( "TARGET", ["PARENT"], true )[0].direction
  3797.     when "USER"
  3798.       direction = action_target( "TARGET", ["USER"], true )[0].direction
  3799.     when "TARGET"  
  3800.       direction = action_target( "TARGET", ["TARGET"], true )[0].direction
  3801.     else  
  3802.       direction = parameters[1].to_i
  3803.     end  
  3804.     projectile = ::YGG::PROJECTILE_MAP[parameters[2].to_s]
  3805.     setup_code = ::YGG::PROJETILE_SETUP[parameters[3].to_s]
  3806.     users.each { |user|
  3807.       pro = projectile.new( user, setup_code )
  3808.       pro.moveto( user.x, user.y ) ; pro.set_direction( direction )
  3809.       $game_yggdrasil.add_projectile( pro )
  3810.     }  
  3811.     return 0
  3812.   end
  3813.  
  3814.   #--------------------------------------------------------------------------#
  3815.   # * new-method :action_script
  3816.   #--------------------------------------------------------------------------#                  
  3817.   def action_script( action, parameters )
  3818.     user    = action_target( "TARGET", ["USER"] )
  3819.     target  = action_target( "TARGET", ["TARGET"] )
  3820.     targets = action_target( "TARGET", ["TARGETS"] )
  3821.     eval( parameters.to_s )
  3822.     return 0
  3823.   end
  3824.  
  3825.   #--------------------------------------------------------------------------#
  3826.   # * new-method :action_through
  3827.   #--------------------------------------------------------------------------#                  
  3828.   def action_through( action, parameters )
  3829.     targets = action_target( "TARGET", [parameters[0]] )
  3830.     case parameters[1].upcase
  3831.     when "TRUE", "ON", "YES"
  3832.       targets.each { |t| t.set_through( true ) }
  3833.     when "FALSE", "OFF", "NO"
  3834.       targets.each { |t| t.set_through( false ) }
  3835.     end
  3836.     return 0
  3837.   end
  3838.  
  3839.   #--------------------------------------------------------------------------#
  3840.   # * new-method :action_parent_wait
  3841.   #--------------------------------------------------------------------------#                  
  3842.   def action_parent_wait( action, parameters )
  3843.     @user_event.wait_count = parameters[0].to_i
  3844.   end
  3845.  
  3846.   #--------------------------------------------------------------------------#
  3847.   # * new-method :action_wait
  3848.   #--------------------------------------------------------------------------#                  
  3849.   def action_wait( action, parameters )
  3850.     case action.upcase
  3851.     when "WAIT FOR ANIMATION"
  3852.       @wait_count = $data_animations[parameters[0].to_i].frame_max * ::Sprite_Base::RATE
  3853.     when "WAIT"
  3854.       @wait_count = parameters[0].to_i
  3855.     end  
  3856.     return 1
  3857.   end
  3858.  
  3859. end  
  3860.  
  3861. # // (YGG_MC) - Mix Code
  3862. #==============================================================================#
  3863. # // RMVX Mixins
  3864. #==============================================================================#
  3865. # ** RPG::Animation
  3866. #==============================================================================#
  3867. class RPG::Animation
  3868.  
  3869.   #----------------------------------------------------------------------------#
  3870.   # * new-method :cell_count
  3871.   #----------------------------------------------------------------------------#
  3872.   def cell_count() ; end unless method_defined? :cell_count
  3873.    
  3874. end  
  3875.  
  3876. #==============================================================================#
  3877. # ** RPG::BaseItem
  3878. #==============================================================================#
  3879. class RPG::BaseItem
  3880.  
  3881.   include YGG::Caches1x6
  3882.  
  3883.   #----------------------------------------------------------------------------#
  3884.   # * Public Instance Variable(s)
  3885.   #----------------------------------------------------------------------------#
  3886.   attr_accessor :pickup_sfx
  3887.  
  3888.   #----------------------------------------------------------------------------#
  3889.   # * new-method :pickup_sfx
  3890.   #----------------------------------------------------------------------------#
  3891.   def pickup_sfx()
  3892.     @pickup_sfx ||= self.note =~ YGG::REGEXP::BASE_ITEM::PICKUP_SFX ?
  3893.       RPG::SE.new( $1, $2.to_i, $3.to_i ) : ::YGG::SOUND_ITEM
  3894.     return @pickup_sfx
  3895.   end
  3896.  
  3897.   #----------------------------------------------------------------------------#
  3898.   # * new-method :drops_attraction?
  3899.   #----------------------------------------------------------------------------#
  3900.   def drops_attraction?() ; return @drops_attraction ; end
  3901.  
  3902. end
  3903.  
  3904. #==============================================================================#
  3905. # ** RPG::Armor
  3906. #==============================================================================#
  3907. class RPG::Armor
  3908.  
  3909.   #----------------------------------------------------------------------------#
  3910.   # * super-method :drops_attraction?
  3911.   #----------------------------------------------------------------------------#  
  3912.   def yggdrasil_1x6_cache_end()
  3913.     super()
  3914.     @ygg_actions[0] ||= ::YGG.get_action_list( "GUARD_ACTION" )
  3915.   end
  3916.  
  3917. end
  3918.  
  3919. #==============================================================================#
  3920. # ** RPG::UsableItem
  3921. #==============================================================================#
  3922. class RPG::UsableItem
  3923.  
  3924.   #----------------------------------------------------------------------------#
  3925.   # * Public Instance Variable(s)
  3926.   #----------------------------------------------------------------------------#  
  3927.   attr_accessor :guardable
  3928.  
  3929.   #----------------------------------------------------------------------------#
  3930.   # * super-method :yggdrasil_1x6_cache_start
  3931.   #----------------------------------------------------------------------------#
  3932.   def yggdrasil_1x6_cache_start()
  3933.     super()
  3934.     @__use_target_select = false
  3935.     @guardable = false
  3936.   end
  3937.  
  3938.   #----------------------------------------------------------------------------#
  3939.   # * super-method :yggdrasil_1x6_cache_check
  3940.   #----------------------------------------------------------------------------#  
  3941.   def yggdrasil_1x6_cache_check( line )
  3942.     super( line )
  3943.     case line
  3944.     when ::YGG::REGEXP::SKILL::UTARGET_SELECT
  3945.       @__use_target_select = true
  3946.     when ::YGG::REGEXP::SKILL::GUARDABLE
  3947.       @guardable = true
  3948.     when ::YGG::REGEXP::SKILL::NOT_GUARDABLE  
  3949.       @guardable = false
  3950.     end  
  3951.   end
  3952.  
  3953.   #----------------------------------------------------------------------------#
  3954.   # * super-method :yggdrasil_1x6_cache_end
  3955.   #----------------------------------------------------------------------------#  
  3956.   def yggdrasil_1x6_cache_end()
  3957.     super()
  3958.     case @scope
  3959.     when 0     # // None
  3960.       @ygg_actions[0] ||= ::YGG.get_action_list( "NORMAL_OBJ0" ).clone
  3961.     when 11    # // User
  3962.       @ygg_actions[0] ||= ::YGG.get_action_list( "NORMAL_OBJ1" ).clone
  3963.     when 1     # // 1 Enemy
  3964.       @ygg_actions[0] ||= @__use_target_select ?
  3965.         ::YGG.get_action_list( "NORMAL_OBJ2_T1" ).clone :
  3966.         ::YGG.get_action_list( "NORMAL_OBJ2_1" ).clone
  3967.     when 3     # // 1 Enemy Dual
  3968.       @ygg_actions[0] ||= @__use_target_select ?
  3969.         ::YGG.get_action_list( "NORMAL_OBJ2_T2" ).clone :
  3970.         ::YGG.get_action_list( "NORMAL_OBJ2_2" ).clone
  3971.     when 4     # // 1 Random Enemy
  3972.       @ygg_actions[0] ||= ::YGG.get_action_list( "NORMAL_OBJ2_R1" ).clone
  3973.     when 5     # // 2 Random Enemies
  3974.       @ygg_actions[0] ||= ::YGG.get_action_list( "NORMAL_OBJ2_R2" ).clone
  3975.     when 6     # // 3 Random Enemies
  3976.       @ygg_actions[0] ||= ::YGG.get_action_list( "NORMAL_OBJ2_R3" ).clone  
  3977.     when 7, 9  # // 1 Ally
  3978.       @ygg_actions[0] ||= @__use_target_select ?
  3979.         ::YGG.get_action_list( "NORMAL_OBJ3_T1" ).clone :
  3980.         ::YGG.get_action_list( "NORMAL_OBJ3_1" ).clone
  3981.     when 2     # // All Enemies
  3982.       @ygg_actions[0] ||= ::YGG.get_action_list( "NORMAL_OBJ4" ).clone  
  3983.     when 8, 10 # // All Allies
  3984.       @ygg_actions[0] ||= ::YGG.get_action_list( "NORMAL_OBJ5" ).clone  
  3985.     end  
  3986.   end
  3987.  
  3988. end
  3989.  
  3990. #==============================================================================#
  3991. # ** RPG::Enemy
  3992. #==============================================================================#
  3993. class RPG::Enemy
  3994.  
  3995.   include YGG::Caches1x6
  3996.  
  3997.   #----------------------------------------------------------------------------#
  3998.   # * Public Instance Variable(s)
  3999.   #----------------------------------------------------------------------------#  
  4000.   attr_accessor :atk_animation_id
  4001.   attr_accessor :atk_animation_id2
  4002.   attr_accessor :drop_items
  4003.   attr_accessor :gold_variation
  4004.  
  4005.   #----------------------------------------------------------------------------#
  4006.   # * super-method :yggdrasil_1x6_cache_check
  4007.   #----------------------------------------------------------------------------#  
  4008.   def yggdrasil_1x6_cache_start()
  4009.     super()
  4010.     @drop_items ||= [] ; @__drop_id = -1
  4011.     @__drop = nil ; @__drop_reading = false
  4012.     @gold_variation = 0
  4013.   end
  4014.  
  4015.   #----------------------------------------------------------------------------#
  4016.   # * super-method :yggdrasil_1x6_cache_check
  4017.   #----------------------------------------------------------------------------#  
  4018.   def yggdrasil_1x6_cache_check( line )
  4019.     super( line )
  4020.     case line
  4021.     when YGG::REGEXP::ENEMY::ATK_ANIMATION_ID
  4022.       @atk_animation_id = $1.to_i
  4023.     when YGG::REGEXP::ENEMY::DROP_ITEM2
  4024.       @drop_items[@__drop_id] = @__drop if @__drop_id > -1
  4025.       @__drop_id = -1 ; @__drop = nil ; @__drop_reading = false  
  4026.     when YGG::REGEXP::ENEMY::DROP_ITEM1
  4027.       @__drop_id = $1.to_i ; @__drop = DropItem.new() ; @__drop_reading = true    
  4028.     when YGG::REGEXP::ENEMY::DROP_CLEAR  
  4029.       @drop_items.clear()
  4030.     when YGG::REGEXP::ENEMY::GOLD_VARI
  4031.       @gold_variation = $1.to_i
  4032.     else
  4033.       if @__drop_reading
  4034.         case line
  4035.         # // Type of the drop item (0: none, 1: item, 2: weapon, 3: armor)
  4036.         when /kind:[ ](\d+)/i
  4037.           @__drop.kind = $1.to_i
  4038.         when /(?:item_id|item id|itemid):[ ](\d+)/i  
  4039.           @__drop.kind = 1 ; @__drop.item_id = $1.to_i
  4040.         when /(?:weapon_id|weapon id|weaponid):[ ](\d+)/i  
  4041.           @__drop.kind = 2 ; @__drop.weapon_id = $1.to_i
  4042.         when /(?:armor_id|armor id|armorid):[ ](\d+)/i    
  4043.           @__drop.kind = 3 ; @__drop.armor_id = $1.to_i
  4044.         when /(?:denom|denominator|prob|probability):[ ](\d+)/i  
  4045.           @__drop.denominator = $1.to_i
  4046.         end
  4047.       end  
  4048.     end  
  4049.   end
  4050.  
  4051.   #----------------------------------------------------------------------------#
  4052.   # * super-method :yggdrasil_1x6_cache_end
  4053.   #----------------------------------------------------------------------------#  
  4054.   def yggdrasil_1x6_cache_end()
  4055.     super()
  4056.     @atk_animation_id  ||= 1
  4057.     @atk_animation_id2 ||= 0
  4058.     @ygg_actions[0]    ||= ::YGG.get_action_list( "NORMAL_ATTACK_EN" ) # // Attack Action
  4059.     @ygg_actions[1]    ||= ::YGG.get_action_list( "GUARD_ACTION_EN" )  # // Guard Action
  4060.     @ygg_actions[2]    ||= ::YGG.get_action_list( "ESCAPE_ACTION_EN" ) # // Escape Action
  4061.     @ygg_actions[3]    ||= ::YGG.get_action_list( "WAIT_ACTION_EN" )   # // Wait Action
  4062.     @drop_items[1]     ||= @drop_item1
  4063.     @drop_items[2]     ||= @drop_item2
  4064.     # // Match Drop Items D: We dont want mismatch and chaos >:
  4065.     @drop_item1 = @drop_items[1]
  4066.     @drop_item2 = @drop_items[2]
  4067.   end
  4068.  
  4069. end  
  4070.  
  4071. #==============================================================================#
  4072. # ** RPG::State
  4073. #==============================================================================#
  4074. class RPG::State
  4075.  
  4076.   #--------------------------------------------------------------------------#
  4077.   # * Public Instance Variable(s)
  4078.   #--------------------------------------------------------------------------#  
  4079.   attr_accessor :hold_ticks
  4080.   attr_accessor :effect_tone
  4081.   attr_accessor :tone_effect
  4082.   attr_accessor :move_mod
  4083.  
  4084.   #----------------------------------------------------------------------------#
  4085.   # * new-method :yggdrasil_1x6_cache
  4086.   #----------------------------------------------------------------------------#  
  4087.   def yggdrasil_1x6_cache()
  4088.     yggdrasil_1x6_cache_start()
  4089.     self.note.split(/[\r\n]+/).each { |line| yggdrasil_1x6_cache_check( line ) }
  4090.     yggdrasil_1x6_cache_end()
  4091.   end
  4092.  
  4093.   #----------------------------------------------------------------------------#
  4094.   # * new-method :yggdrasil_1x6_cache_start
  4095.   #----------------------------------------------------------------------------#  
  4096.   def yggdrasil_1x6_cache_start()
  4097.     @hold_ticks  = self.hold_turn * ::YGG::STATE_TURN_COUNTER
  4098.     @move_mod    = 0
  4099.     @effect_tone = Tone.new( 0, 0, 0, 0 )
  4100.     @tone_effect = false
  4101.     @slip_freq   = ::YGG::SLIP_DAMAGE_FREQUENCY
  4102.   end
  4103.  
  4104.   #----------------------------------------------------------------------------#
  4105.   # * new-method :yggdrasil_1x6_cache_check
  4106.   #----------------------------------------------------------------------------#  
  4107.   def yggdrasil_1x6_cache_check( line )
  4108.     case line
  4109.     when ::YGG::REGEXP::STATE::HOLD_TICKS
  4110.       @hold_ticks = $1.to_i
  4111.     when ::YGG::REGEXP::STATE::TONE  
  4112.       @effect_tone = ::Tone.new( $1.to_i, $2.to_i, $3.to_i, $4.to_i )
  4113.       @tone_effect = true
  4114.     when ::YGG::REGEXP::STATE::MOVE_MOD  
  4115.       @move_mod = $1.to_i
  4116.     when ::YGG::REGEXP::STATE::SLIP_FREQ  
  4117.       @slip_freq = $1.to_i
  4118.     end  
  4119.   end
  4120.  
  4121.   #----------------------------------------------------------------------------#
  4122.   # * new-method :yggdrasil_1x6_cache_end
  4123.   #----------------------------------------------------------------------------#  
  4124.   def yggdrasil_1x6_cache_end()
  4125.   end
  4126.  
  4127.   #----------------------------------------------------------------------------#
  4128.   # * new-method :slip_freq
  4129.   #----------------------------------------------------------------------------#
  4130.   def slip_freq()
  4131.     return self.slip_damage ? @slip_freq : 0
  4132.   end
  4133.  
  4134. end
  4135.  
  4136. #==============================================================================#
  4137. # ** YGG::System ($game_yggdrasil)
  4138. #==============================================================================#
  4139. class YGG::System
  4140.  
  4141.   #--------------------------------------------------------------------------#
  4142.   # * Constants
  4143.   #--------------------------------------------------------------------------#
  4144.   ITEMS_MAPID = ::YGG::ITEM_MAP
  4145.  
  4146.   #--------------------------------------------------------------------------#
  4147.   # * Public Instance Variable(s)
  4148.   #--------------------------------------------------------------------------#
  4149.   attr_accessor :passage_objs
  4150.  
  4151.   attr_reader :projectiles
  4152.   attr_reader :new_projectiles
  4153.  
  4154.   attr_reader :new_poptexts
  4155.  
  4156.   attr_reader :active_ranges
  4157.   attr_reader :battlers
  4158.  
  4159.   #--------------------------------------------------------------------------#
  4160.   # * new-method :initialize
  4161.   #--------------------------------------------------------------------------#
  4162.   def initialize()
  4163.     setup_map( -1 )
  4164.   end
  4165.  
  4166.   #--------------------------------------------------------------------------#
  4167.   # * new-method :hud
  4168.   #--------------------------------------------------------------------------#
  4169.   def hud()
  4170.     @hud ||= YGG::Handlers::HudWrapper.new()
  4171.     return @hud
  4172.   end
  4173.  
  4174.   #--------------------------------------------------------------------------#
  4175.   # * new-method :add_pop
  4176.   #--------------------------------------------------------------------------#
  4177.   def add_pop( poptext, x, y, z=1 )
  4178.     return unless ::YGG::USE_TEXT_POP
  4179.     pop = ::YGG::PopHandler.new( poptext, x, y, z )
  4180.     @pop_texts.push( pop )
  4181.     @new_poptexts  << pop
  4182.     return pop
  4183.   end
  4184.  
  4185.   #--------------------------------------------------------------------------#
  4186.   # * new-method :remove_pop
  4187.   #--------------------------------------------------------------------------#  
  4188.   def remove_pop( pop_handler )
  4189.     pop_handler.force_complete!()
  4190.     @pop_texts.delete( pop_handler )
  4191.     @new_poptexts.delete( pop_handler )
  4192.     return pophandler
  4193.   end
  4194.  
  4195.   #--------------------------------------------------------------------------#
  4196.   # * new-method :add_projectile
  4197.   #--------------------------------------------------------------------------#  
  4198.   def add_projectile( projectile )
  4199.     @projectiles << projectile
  4200.     @new_projectiles << projectile
  4201.     projectile.pro_register()
  4202.     return projectile
  4203.   end
  4204.  
  4205.   #--------------------------------------------------------------------------#
  4206.   # * new-method :remove_projectile
  4207.   #--------------------------------------------------------------------------#  
  4208.   def remove_projectile( projectile )
  4209.     @projectiles.delete( projectile )
  4210.     @new_projectiles.delete( projectile )
  4211.     projectile.pro_unregister()
  4212.     projectile.force_terminate()
  4213.     return projectile
  4214.   end
  4215.  
  4216.   #--------------------------------------------------------------------------#
  4217.   # * new-method :add_battler
  4218.   #--------------------------------------------------------------------------#
  4219.   def add_battler( b ) ; @battlers |= [b] ; end
  4220.  
  4221.   #--------------------------------------------------------------------------#
  4222.   # * new-method :remove_battler
  4223.   #--------------------------------------------------------------------------#
  4224.   def remove_battler( b ) ; @battlers -= [b] ; end
  4225.  
  4226.   #--------------------------------------------------------------------------#
  4227.   # * new-method :add_passage_obj
  4228.   #--------------------------------------------------------------------------#
  4229.   def add_passage_obj( obj )
  4230.     @passage_objs |= [obj]
  4231.   end
  4232.  
  4233.   #--------------------------------------------------------------------------#
  4234.   # * new-method :remove_passage_obj
  4235.   #--------------------------------------------------------------------------#
  4236.   def remove_passage_obj( obj )
  4237.     @passage_objs -= [obj]
  4238.   end
  4239.  
  4240.   #--------------------------------------------------------------------------#
  4241.   # * new-method :update
  4242.   #--------------------------------------------------------------------------#
  4243.   def update()
  4244.     update_poptexts()
  4245.     update_drops()
  4246.     update_roam_events()
  4247.     update_projectiles()
  4248.     update_hud()
  4249.   end
  4250.  
  4251.   #--------------------------------------------------------------------------#
  4252.   # * new-method :update_hud
  4253.   #--------------------------------------------------------------------------#
  4254.   def update_hud()
  4255.     self.hud.update()
  4256.   end
  4257.  
  4258.   #--------------------------------------------------------------------------#
  4259.   # * new-method :update_roam_events
  4260.   #--------------------------------------------------------------------------#
  4261.   def update_roam_events()
  4262.     @roam_events.each { |ev| ev.update() }
  4263.   end
  4264.  
  4265.   #--------------------------------------------------------------------------#
  4266.   # * new-method :update_projectiles
  4267.   #--------------------------------------------------------------------------#
  4268.   def update_projectiles()
  4269.     @projectiles = @projectiles.inject([]) { |result, pro|
  4270.       unless pro.terminated?() ; pro.update() ; result << pro  
  4271.       else ; @new_projectiles.delete( pro ) ; pro.registered = false ; end
  4272.       result
  4273.     } unless @projectiles.empty?()
  4274.   end
  4275.  
  4276.   #--------------------------------------------------------------------------#
  4277.   # * new-method :pop_texts
  4278.   #--------------------------------------------------------------------------#
  4279.   def update_poptexts()
  4280.     @pop_texts = @pop_texts.inject([]) { |result, pop|
  4281.       pop.update() ; result << pop unless pop.complete?() ; result
  4282.     } unless @pop_texts.empty?()
  4283.   end
  4284.  
  4285.   #--------------------------------------------------------------------------#
  4286.   # * new-method :pop_texts
  4287.   #--------------------------------------------------------------------------#
  4288.   def pop_texts() ; return @pop_texts ; end
  4289.  
  4290.   #--------------------------------------------------------------------------#
  4291.   # * new-method :roam_xy
  4292.   #--------------------------------------------------------------------------#
  4293.   def roam_xy( x, y )
  4294.     return (
  4295.       @roam_events +
  4296.       @passage_objs).inject([]) { |r, ev| r << ev if ev.pos?( x, y ) ; ev }
  4297.   end
  4298.            
  4299.   #--------------------------------------------------------------------------#
  4300.   # * new-method :battlers_xy
  4301.   #--------------------------------------------------------------------------#
  4302.   def battlers_xy( x, y )
  4303.     return @battlers.inject([]) { |result, b| result << b if b.pos?( x, y ) ; result }
  4304.   end
  4305.  
  4306.   #--------------------------------------------------------------------------#
  4307.   # * new-method :battlers_range
  4308.   #--------------------------------------------------------------------------#  
  4309.   def battlers_range( x1, y1, x2, y2 )
  4310.     return @battlers.inject([]) { |result, b|
  4311.       result << b if b.x.between?( x1, x2 ) && b.y.between?( y1, y2 ) ; result }
  4312.   end
  4313.  
  4314.   #--------------------------------------------------------------------------#
  4315.   # * new-method :on?
  4316.   #--------------------------------------------------------------------------#  
  4317.   if ::YGG::ABS_SYSTEM_SWITCH.nil?()
  4318.     def on?() ; return true ; end
  4319.   else
  4320.     def on?() ; return $game_switches[::YGG::ABS_SYSTEM_SWITCH] ; end  
  4321.   end  
  4322.  
  4323.   #--------------------------------------------------------------------------#
  4324.   # * new-method :setup_map
  4325.   #--------------------------------------------------------------------------#
  4326.   def setup_map( map_id )
  4327.     @map_id          = map_id
  4328.     @pop_texts     ||= [] ; @pop_texts.clear()
  4329.     @new_poptexts  ||= [] ; @new_poptexts.clear()
  4330.     @battlers      ||= [] ; @battlers.each { |b| b.ygg_unregister() } ; @battlers.clear()  
  4331.     @active_drops  ||= [] ; @active_drops.clear()
  4332.     @active_ranges ||= [] ; @active_ranges.clear()
  4333.     @projectiles   ||= [] ; @projectiles.clear()  
  4334.     @new_projectiles||=[] ; @new_projectiles.clear()
  4335.     @roam_events   ||= [] ; @roam_events.clear()
  4336.     @passage_objs  ||= [] ; @passage_objs.clear()
  4337.   end  
  4338.  
  4339.   #--------------------------------------------------------------------------#
  4340.   # * new-method :get_map
  4341.   #--------------------------------------------------------------------------#  
  4342.   def get_map( map_id )
  4343.     $game_map.get_map( map_id )
  4344.   end
  4345.  
  4346.   #--------------------------------------------------------------------------#
  4347.   # * new-method :setup_itemmap
  4348.   #--------------------------------------------------------------------------#
  4349.   def setup_itemmap()
  4350.     if $items_map.nil?()
  4351.       $items_map = get_map( ITEMS_MAPID )
  4352.       $items_map.events.values.each { |ev| ev.pages.each { |pg|
  4353.         pg.list = YGG.parse_event_list( pg.list ) } }
  4354.     end  
  4355.   end
  4356.  
  4357.   #--------------------------------------------------------------------------#
  4358.   # * new-method :create_drops
  4359.   #--------------------------------------------------------------------------#
  4360.   def create_drops( x, y, dropee )
  4361.     place_drops( x, y, dropee.items, dropee.gold )
  4362.   end  
  4363.  
  4364.   #--------------------------------------------------------------------------#
  4365.   # * new-method :place_drops
  4366.   #--------------------------------------------------------------------------#
  4367.   def place_drops( x, y, item_set, gold = nil )
  4368.     drops = []  
  4369.     for dr in item_set.compact
  4370.       cc = YGG::Drop_Character.new( dr, YGG::ITEM_FADE_TIME )
  4371.       fail_count = 0
  4372.       dx, dy = x, y
  4373.       loop do
  4374.         x_r = rand(YGG::DROP_SCATTER_DISTANCE)
  4375.         y_r = rand(YGG::DROP_SCATTER_DISTANCE)
  4376.         x_r = -x_r if rand(2) == 0
  4377.         y_r = -y_r if rand(2) == 0
  4378.         dx = x + x_r
  4379.         dy = y + y_r
  4380.         if fail_count > 20 ; break dx, dy = x, y ; end
  4381.         break if $game_map.passable?( dx, dy )
  4382.         fail_count += 1
  4383.       end  
  4384.       cc.moveto( dx, dy )
  4385.       drops.push( cc )
  4386.     end
  4387.     unless gold.nil?() || gold.eql?( 0 )
  4388.       cc = YGG::Drop_Character.new( YGG::Containers::GoldItem.new( gold ), YGG::GOLD_FADE_TIME )
  4389.       cc.moveto( x, y )
  4390.       drops.push( cc )
  4391.     end
  4392.     drops.each { |char|
  4393.       @active_drops.push( char ) ;
  4394.       $scene.spriteset.add_drop_sprite( char ) if $scene.is_a?( Scene_Map )
  4395.     }
  4396.     return drops
  4397.   end
  4398.  
  4399.   #--------------------------------------------------------------------------#
  4400.   # * new-method :items_map
  4401.   #--------------------------------------------------------------------------#
  4402.   def items_map() ; return $items_map ; end
  4403.  
  4404.   #--------------------------------------------------------------------------#
  4405.   # * alias-method :update_drops
  4406.   #--------------------------------------------------------------------------#
  4407.   def update_drops()
  4408.     @active_drops = @active_drops.inject([]) { |result, dr| dr.update()
  4409.       result.push( dr ) unless dr.timeout?() ; result } unless @active_drops.empty?()
  4410.   end
  4411.  
  4412.   #--------------------------------------------------------------------------#
  4413.   # * new-method :active_drops
  4414.   #--------------------------------------------------------------------------#
  4415.   def active_drops() ; return @active_drops ; end
  4416.  
  4417.   #--------------------------------------------------------------------------#
  4418.   # * new-method :drops_xy
  4419.   #--------------------------------------------------------------------------#  
  4420.   def drops_xy( x, y )
  4421.     return self.active_drops.inject([]) { |result, dr|
  4422.       result.push(dr) if dr.pos?(x, y) ; result }
  4423.   end
  4424.  
  4425. end
  4426.  
  4427. #==============================================================================#
  4428. # // Start Yggdrasil MixIn Code  
  4429. #==============================================================================#
  4430. YGG::Containers::Drops = Struct.new( :items, :gold )
  4431. #==============================================================================#
  4432. # ** YGG::MixIns::Actor
  4433. #==============================================================================#
  4434. module YGG::MixIns::Actor
  4435.  
  4436.   #--------------------------------------------------------------------------#
  4437.   # * new-method :create_drops_object
  4438.   #--------------------------------------------------------------------------#  
  4439.   def create_drops_object()
  4440.     return ::YGG::Containers::Drops.new( [], 0 )
  4441.   end
  4442.  
  4443. end
  4444.  
  4445. #==============================================================================#
  4446. # ** YGG::MixIns::Enemy
  4447. #==============================================================================#
  4448. module YGG::MixIns::Enemy
  4449.  
  4450.   #--------------------------------------------------------------------------#
  4451.   # * new-method :create_drops_object
  4452.   #--------------------------------------------------------------------------#  
  4453.   def create_drops_object()
  4454.     return ::YGG::Containers::Drops.new( self.all_drops, self.calc_gold )
  4455.   end
  4456.  
  4457. end
  4458.  
  4459. #==============================================================================#
  4460. # ** YGG::MixIns::Movement
  4461. #==============================================================================#
  4462. module YGG::MixIns::Movement
  4463.  
  4464.   #--------------------------------------------------------------------------#
  4465.   # * new-method :distance_from
  4466.   #--------------------------------------------------------------------------#
  4467.   def distance_from( obj )
  4468.     return (obj.x - self.x).abs + (obj.y - self.y).abs
  4469.   end
  4470.  
  4471.   #--------------------------------------------------------------------------#
  4472.   # * Jump to XY
  4473.   #--------------------------------------------------------------------------#  
  4474.   def jump_to_xy( tx, ty )
  4475.     jump( tx-self.x, ty-self.y )
  4476.   end
  4477.  
  4478.   #--------------------------------------------------------------------------#
  4479.   # * Jump to Character
  4480.   #--------------------------------------------------------------------------#  
  4481.   def jump_to_char( char )
  4482.     jump_to_xy( char.x, char.y )
  4483.   end
  4484.  
  4485.   #--------------------------------------------------------------------------#
  4486.   # * Jump to Event
  4487.   #--------------------------------------------------------------------------#  
  4488.   def jump_to_event( event_id )
  4489.     jump_to_char( $game_map.events[event_id] )
  4490.   end
  4491.  
  4492.   #--------------------------------------------------------------------------#
  4493.   # * new-method :jump_forward
  4494.   #--------------------------------------------------------------------------#
  4495.   def jump_forward( amount, offset )
  4496.     case direction
  4497.     when 2
  4498.       jump( offset, amount )
  4499.     when 4
  4500.       jump( -amount, offset )
  4501.     when 6
  4502.       jump( amount, -offset )
  4503.     when 8
  4504.       jump( -offset, -amount )
  4505.     end  
  4506.   end
  4507.  
  4508.   #--------------------------------------------------------------------------#
  4509.   # * new-method :jump_backward
  4510.   #--------------------------------------------------------------------------#
  4511.   def jump_backward( amount, offset )
  4512.     jump_forward( -amount, -offset )
  4513.   end
  4514.  
  4515.   #--------------------------------------------------------------------------#
  4516.   # * new-method :distance_x_from_tx
  4517.   #--------------------------------------------------------------------------#
  4518.   def distance_x_from_tx( tx )
  4519.     sx = @x - tx
  4520.     if $game_map.loop_horizontal?         # When looping horizontally
  4521.       if sx.abs > $game_map.width / 2     # Larger than half the map width?
  4522.         sx -= $game_map.width             # Subtract map width
  4523.       end
  4524.     end
  4525.     return sx
  4526.   end
  4527.  
  4528.   #--------------------------------------------------------------------------#
  4529.   # * new-method :distance_y_from_ty
  4530.   #--------------------------------------------------------------------------#
  4531.   def distance_y_from_ty( ty )
  4532.     sy = @y - ty
  4533.     if $game_map.loop_vertical?           # When looping vertically
  4534.       if sy.abs > $game_map.height / 2    # Larger than half the map height?
  4535.         sy -= $game_map.height            # Subtract map height
  4536.       end
  4537.     end
  4538.     return sy
  4539.   end
  4540.  
  4541.   #--------------------------------------------------------------------------#
  4542.   # * new-method :move_toward_xy
  4543.   #--------------------------------------------------------------------------#
  4544.   def move_toward_xy( x, y )
  4545.     move_8d = false
  4546.     sx = distance_x_from_tx(x)
  4547.     sy = distance_y_from_ty(y)
  4548.     if move_8d
  4549.       # // Need to work on it
  4550.     else  
  4551.       if sx != 0 or sy != 0
  4552.         if sx.abs > sy.abs                  # Horizontal distance is longer
  4553.           sx > 0 ? move_left : move_right   # Prioritize left-right
  4554.           if @move_failed and sy != 0
  4555.             sy > 0 ? move_up : move_down
  4556.           end
  4557.         else                                # Vertical distance is longer
  4558.           sy > 0 ? move_up : move_down      # Prioritize up-down
  4559.           if @move_failed and sx != 0
  4560.             sx > 0 ? move_left : move_right
  4561.           end
  4562.         end
  4563.       end
  4564.     end  
  4565.   end
  4566.  
  4567.   #--------------------------------------------------------------------------#
  4568.   # * new-method :move_away_from_xy
  4569.   #--------------------------------------------------------------------------#
  4570.   def move_away_from_xy( x, y )
  4571.     move_8d = false
  4572.     sx = distance_x_from_tx(x)
  4573.     sy = distance_y_from_ty(y)
  4574.     if move_8d
  4575.       # // Need to work on it
  4576.     else  
  4577.       if sx != 0 or sy != 0
  4578.         if sx.abs > sy.abs                  # Horizontal distance is longer
  4579.           sx > 0 ? move_right : move_left   # Prioritize left-right
  4580.           if @move_failed and sy != 0
  4581.             sy > 0 ? move_down : move_up
  4582.           end
  4583.         else                                # Vertical distance is longer
  4584.           sy > 0 ? move_down : move_up      # Prioritize up-down
  4585.           if @move_failed and sx != 0
  4586.             sx > 0 ? move_right : move_left
  4587.           end
  4588.         end
  4589.       end
  4590.     end  
  4591.   end
  4592.  
  4593.   #--------------------------------------------------------------------------#
  4594.   # * new-method :move_toward_char
  4595.   #--------------------------------------------------------------------------#
  4596.   def move_toward_char( char )
  4597.     move_toward_xy( char.x, char.y )
  4598.   end
  4599.  
  4600.   #--------------------------------------------------------------------------#
  4601.   # * new-method :move_away_from_xy
  4602.   #--------------------------------------------------------------------------#
  4603.   def move_away_from_char( char )
  4604.     move_away_from_xy( char.x, char.y )
  4605.   end
  4606.  
  4607.   #--------------------------------------------------------------------------#
  4608.   # * new-method :move_toward_event
  4609.   #--------------------------------------------------------------------------#
  4610.   def move_toward_event( event_id )
  4611.     move_toward_char( $game_map.events[event_id] )
  4612.   end  
  4613.  
  4614.   #--------------------------------------------------------------------------#
  4615.   # * new-method :move_away_from_event
  4616.   #--------------------------------------------------------------------------#
  4617.   def move_away_from_event( event_id )
  4618.     move_away_from_char( $game_map.events[event_id] )
  4619.   end
  4620.  
  4621.   #--------------------------------------------------------------------------#
  4622.   # * new-method :thrust_wait
  4623.   #--------------------------------------------------------------------------#
  4624.   def thrust_wait( t=30 ) ; @wait_count = t ; end
  4625.  
  4626.   #--------------------------------------------------------------------------#
  4627.   # * new-method :half_down
  4628.   #--------------------------------------------------------------------------#
  4629.   def half_down( turn_ok=true )
  4630.     turn_down if turn_ok
  4631.     @y = $game_map.round_y(@y + 0.5)
  4632.     @real_y = ((@y - 0.5)*256)
  4633.     @move_failed = false
  4634.   end
  4635.  
  4636.   #--------------------------------------------------------------------------#
  4637.   # * new-method :half_left
  4638.   #--------------------------------------------------------------------------#
  4639.   def half_left( turn_ok=true )
  4640.     turn_left if turn_ok
  4641.     @x = $game_map.round_x(@x-0.5)
  4642.     @real_x = ((@x+0.5)*256)
  4643.     @move_failed = false
  4644.   end
  4645.  
  4646.   #--------------------------------------------------------------------------#
  4647.   # * new-method :half_right
  4648.   #--------------------------------------------------------------------------#
  4649.   def half_right( turn_ok=true )
  4650.     turn_right if turn_ok
  4651.     @x = $game_map.round_x(@x+0.5)
  4652.     @real_x = ((@x-0.5)*256)
  4653.     @move_failed = false
  4654.   end
  4655.  
  4656.   #--------------------------------------------------------------------------#
  4657.   # * new-method :half_up
  4658.   #--------------------------------------------------------------------------#
  4659.   def half_up( turn_ok=true )
  4660.     turn_up if turn_ok
  4661.     @y = $game_map.round_y(@y-0.5)
  4662.     @real_y = ((@y+0.5)*256)
  4663.     @move_failed = false
  4664.   end
  4665.  
  4666.   #--------------------------------------------------------------------------#
  4667.   # * new-method :half_forward
  4668.   #--------------------------------------------------------------------------#
  4669.   def half_forward()
  4670.     case @direction
  4671.     when 2 ; half_down
  4672.     when 4 ; half_left
  4673.     when 6 ; half_right
  4674.     when 8 ; half_up
  4675.     end
  4676.   end
  4677.  
  4678.   #--------------------------------------------------------------------------#
  4679.   # * new-method :half_backward
  4680.   #--------------------------------------------------------------------------#
  4681.   def half_backward()
  4682.     last_direction_fix = @direction_fix
  4683.     @direction_fix = true
  4684.     case @direction
  4685.     when 2;  half_up
  4686.     when 4;  half_right
  4687.     when 6;  half_left
  4688.     when 8;  half_down
  4689.     end
  4690.     @direction_fix = last_direction_fix
  4691.   end
  4692.  
  4693.   #--------------------------------------------------------------------------#
  4694.   # * new-method :free_move_toward_target
  4695.   #--------------------------------------------------------------------------#
  4696.   def free_move_toward_target( t_x, t_y )
  4697.     sx = fr_distance_x_from(t_x)
  4698.     sy = fr_distance_y_from(t_y)
  4699.     if sx != 0 or sy != 0
  4700.       if sx.abs > sy.abs                  # Horizontal distance is longer
  4701.         sx > 0 ? free_left : free_right   # Prioritize left-right
  4702.         if @move_failed and sy != 0
  4703.           sy > 0 ? free_up : free_down
  4704.         end
  4705.       else                                # Vertical distance is longer
  4706.         sy > 0 ? free_up : free_down      # Prioritize up-down
  4707.         if @move_failed and sx != 0
  4708.           sx > 0 ? free_left : free_right
  4709.         end
  4710.       end
  4711.     end
  4712.   end
  4713.  
  4714.   #--------------------------------------------------------------------------#
  4715.   # * new-method :fr_distance_x_from
  4716.   #--------------------------------------------------------------------------#
  4717.   def fr_distance_x_from( targ_x )
  4718.     sx = self.x - targ_x
  4719.     if $game_map.loop_horizontal?         # When looping horizontally
  4720.       if sx.abs > $game_map.width / 2     # Larger than half the map width?
  4721.         sx -= $game_map.width             # Subtract map width
  4722.       end
  4723.     end
  4724.     return sx
  4725.   end
  4726.  
  4727.   #--------------------------------------------------------------------------#
  4728.   # * new-method :fr_distance_y_from
  4729.   #--------------------------------------------------------------------------#
  4730.   def fr_distance_y_from( targ_y )
  4731.     sy = self.y - targ_y
  4732.     if $game_map.loop_vertical?           # When looping vertically
  4733.       if sy.abs > $game_map.height / 2    # Larger than half the map height?
  4734.         sy -= $game_map.height            # Subtract map height
  4735.       end
  4736.     end
  4737.     return sy
  4738.   end
  4739.  
  4740.   #--------------------------------------------------------------------------#
  4741.   # * new-method :limited_down
  4742.   #--------------------------------------------------------------------------#
  4743.   def limited_down( orx, ory, limit, dist=1 )
  4744.     dist_x = fr_distance_x_from(orx)
  4745.     dist_y = fr_distance_y_from(ory) + dist
  4746.     move_down() if (dist_x.abs + dist_y.abs) < limit  
  4747.     return (dist_x.abs + dist_y.abs)
  4748.   end  
  4749.  
  4750.   #--------------------------------------------------------------------------#
  4751.   # * new-method :limited_up
  4752.   #--------------------------------------------------------------------------#  
  4753.   def limited_up( orx, ory, limit, dist=1 )
  4754.     dist_x = fr_distance_x_from(orx)
  4755.     dist_y = fr_distance_y_from(ory) - dist
  4756.     move_up() if (dist_x.abs + dist_y.abs) < limit
  4757.     return (dist_x.abs + dist_y.abs)
  4758.   end
  4759.  
  4760.   #--------------------------------------------------------------------------#
  4761.   # * new-method :limited_left
  4762.   #--------------------------------------------------------------------------#  
  4763.   def limited_left( orx, ory, limit, dist=1 )
  4764.     dist_x = fr_distance_x_from(orx) - dist
  4765.     dist_y = fr_distance_y_from(ory)
  4766.     move_left() if (dist_x.abs + dist_y.abs) < limit
  4767.     return (dist_x.abs + dist_y.abs)
  4768.   end
  4769.  
  4770.   #--------------------------------------------------------------------------#
  4771.   # * new-method :limited_right
  4772.   #--------------------------------------------------------------------------#  
  4773.   def limited_right( orx, ory, limit, dist=1 )
  4774.     dist_x = fr_distance_x_from(orx) + dist
  4775.     dist_y = fr_distance_y_from(ory)
  4776.     move_right() if (dist_x.abs + dist_y.abs) < limit
  4777.     return (dist_x.abs + dist_y.abs)
  4778.   end  
  4779.  
  4780.   #--------------------------------------------------------------------------#
  4781.   # * new-method :thrust_down
  4782.   #--------------------------------------------------------------------------#
  4783.   def thrust_down()
  4784.     dudspeed = @move_speed
  4785.     @move_speed = 6
  4786.     half_down()
  4787.     thrust_wait()
  4788.     half_up( false )
  4789.     @move_speed = dudspeed
  4790.   end
  4791.  
  4792.   #--------------------------------------------------------------------------#
  4793.   # * new-method :thrust_up
  4794.   #--------------------------------------------------------------------------#
  4795.   def thrust_up()
  4796.     dudspeed = @move_speed
  4797.     @move_speed = 6
  4798.     half_up()
  4799.     thrust_wait()
  4800.     half_down( false )
  4801.     @move_speed = dudspeed
  4802.   end
  4803.  
  4804.   #--------------------------------------------------------------------------#
  4805.   # * new-method :thrust_left
  4806.   #--------------------------------------------------------------------------#  
  4807.   def thrust_left()
  4808.     dudspeed = @move_speed
  4809.     @move_speed = 6
  4810.     half_left()
  4811.     thrust_wait()
  4812.     half_right( false )
  4813.     @move_speed = dudspeed
  4814.   end
  4815.  
  4816.   #--------------------------------------------------------------------------#
  4817.   # * new-method :thrust_right
  4818.   #--------------------------------------------------------------------------#
  4819.   def thrust_right()
  4820.     dudspeed = @move_speed
  4821.     @move_speed = 6
  4822.     half_right()
  4823.     thrust_wait()
  4824.     half_left( false )
  4825.     @move_speed = dudspeed
  4826.   end
  4827.  
  4828.   #--------------------------------------------------------------------------#
  4829.   # * new-method :thrust_forward
  4830.   #--------------------------------------------------------------------------#
  4831.   def thrust_forward()
  4832.     case @direction
  4833.     when 2 ; thrust_down()
  4834.     when 4 ; thrust_left()
  4835.     when 6 ; thrust_right()
  4836.     when 8 ; thrust_up()
  4837.     end
  4838.   end
  4839.  
  4840.   #--------------------------------------------------------------------------#
  4841.   # * new-method :thrust_backward
  4842.   #--------------------------------------------------------------------------#
  4843.   def thrust_backward()
  4844.     last_direction_fix = @direction_fix
  4845.     @direction_fix = true
  4846.     case @direction
  4847.     when 2 ; thrust_up
  4848.     when 4 ; thrust_right
  4849.     when 6 ; thrust_left
  4850.     when 8 ; thrust_down
  4851.     end
  4852.     @direction_fix = last_direction_fix
  4853.   end
  4854.  
  4855.   #--------------------------------------------------------------------------#
  4856.   # * new-method :ygg_dodge
  4857.   #--------------------------------------------------------------------------#
  4858.   def ygg_dodge()
  4859.     last_direction_fix = @direction_fix
  4860.     @direction_fix = true
  4861.     dodge_val = rand(2)
  4862.     case @direction
  4863.     when 2, 8; dodge_val == 0 ? thrust_left() : thrust_right()
  4864.     when 4, 6; dodge_val == 0 ? thrust_up() : thrust_down()
  4865.     end
  4866.     @direction_fix = last_direction_fix
  4867.   end
  4868.  
  4869.   #--------------------------------------------------------------------------#
  4870.   # * new-method :free_down
  4871.   #--------------------------------------------------------------------------#
  4872.   def free_down( turn_ok=true )
  4873.     if passable?(@x, @y.round.to_i+0.1)                  # Passable
  4874.       turn_down
  4875.       @y = $game_map.round_y(@y+0.1)
  4876.       @real_y = (@y-0.1)*256
  4877.       increase_steps
  4878.       @move_failed = false
  4879.     else                                    # Impassable
  4880.       turn_down if turn_ok
  4881.       check_event_trigger_touch(@x, @y.round+1)   # Touch event is triggered?
  4882.       @move_failed = true
  4883.     end
  4884.   end
  4885.  
  4886.   #--------------------------------------------------------------------------#
  4887.   # * new-method :free_left
  4888.   #--------------------------------------------------------------------------#
  4889.   def free_left( turn_ok=true )
  4890.     if passable?(@x.round.to_i-1, @y)                  # Passable
  4891.       turn_left
  4892.       @x = $game_map.round_x(@x-0.1)
  4893.       @real_x = (@x+0.1)*256
  4894.       increase_steps
  4895.       @move_failed = false
  4896.     else                                    # Impassable
  4897.       turn_left if turn_ok
  4898.       check_event_trigger_touch(@x.round-1, @y)   # Touch event is triggered?
  4899.       @move_failed = true
  4900.     end
  4901.   end
  4902.  
  4903.   #--------------------------------------------------------------------------#
  4904.   # * new-method :free_right
  4905.   #--------------------------------------------------------------------------#
  4906.   def free_right( turn_ok=true )
  4907.     if passable?(@x.round.to_i+1, @y)                  # Passable
  4908.       turn_right
  4909.       @x = $game_map.round_x(@x+0.1)
  4910.       @real_x = (@x-0.1)*256
  4911.       increase_steps
  4912.       @move_failed = false
  4913.     else                                    # Impassable
  4914.       turn_right if turn_ok
  4915.       check_event_trigger_touch(@x.round+1, @y)   # Touch event is triggered?
  4916.       @move_failed = true
  4917.     end
  4918.   end
  4919.  
  4920.   #--------------------------------------------------------------------------#
  4921.   # * new-method :free_up
  4922.   #--------------------------------------------------------------------------#
  4923.   def free_up( turn_ok=true )
  4924.     if passable?(@x, @y.truncate-1)                  # Passable
  4925.       turn_up
  4926.       @y = $game_map.round_y(@y-0.1)
  4927.       @real_y = (@y+0.1)*256
  4928.       increase_steps
  4929.       @move_failed = false
  4930.     else                                    # Impassable
  4931.       turn_up if turn_ok
  4932.       check_event_trigger_touch(@x, @y.truncate-1)   # Touch event is triggered?
  4933.       @move_failed = true
  4934.     end
  4935.   end
  4936.  
  4937.   #--------------------------------------------------------------------------#
  4938.   # * new-method :hit_away
  4939.   #--------------------------------------------------------------------------#
  4940.   def hit_away( atk_direction )
  4941.     def_speed = @move_speed
  4942.     @move_speed = 6
  4943.     case atk_direction
  4944.     when 2
  4945.       turn_up
  4946.       move_backward
  4947.     when 4
  4948.       turn_right
  4949.       move_backward
  4950.     when 6
  4951.       turn_left
  4952.       move_backward
  4953.     when 8
  4954.       turn_down
  4955.       move_backward
  4956.     end
  4957.     @move_speed = def_speed
  4958.   end
  4959.  
  4960.   #--------------------------------------------------------------------------#
  4961.   # * new-method :turn_to_coord
  4962.   #--------------------------------------------------------------------------#
  4963.   def turn_to_coord( sx, sy )
  4964.     if sx > self.x and sy == self.y    ; turn_right()
  4965.     elsif sx < self.x and sy == self.y ; turn_left()
  4966.     elsif sx == self.x and sy > self.y ; turn_down()
  4967.     elsif sx == self.x and sy < self.y ; turn_up()
  4968.     end  
  4969.   end
  4970.  
  4971.   #--------------------------------------------------------------------------#
  4972.   # * new-method :set_origin
  4973.   #--------------------------------------------------------------------------#
  4974.   def set_origin()
  4975.     @origin ||= ::YGG::Pos.new( self.x, self.y ) ; @origin.set( self.x, self.y )
  4976.   end
  4977.    
  4978. end
  4979.  
  4980. #==============================================================================#
  4981. # ** YGG::MixIns::Battle
  4982. #==============================================================================#
  4983. module YGG::MixIns::Battle
  4984.  
  4985.   #--------------------------------------------------------------------------#
  4986.   # * Public Instance Variable(s)
  4987.   #--------------------------------------------------------------------------#
  4988.   attr_accessor :ygg_delay_max
  4989.  
  4990.   #--------------------------------------------------------------------------#
  4991.   # * new-method :ai_operated?
  4992.   #--------------------------------------------------------------------------#
  4993.   def ai_operated?()
  4994.     return @ai_operated
  4995.   end
  4996.  
  4997.   #--------------------------------------------------------------------------#
  4998.   # * new-method :hp_visible?
  4999.   #--------------------------------------------------------------------------#
  5000.   def hp_visible?()
  5001.     return $game_yggdrasil.on?() && @hp_visible
  5002.   end
  5003.    
  5004.   #--------------------------------------------------------------------------#
  5005.   # * new-method :mp_visible?
  5006.   #--------------------------------------------------------------------------#
  5007.   def mp_visible?()
  5008.     return $game_yggdrasil.on?() && @mp_visible
  5009.   end
  5010.    
  5011.   #--------------------------------------------------------------------------#
  5012.   # * new-method :ygg_can_move?
  5013.   #--------------------------------------------------------------------------#
  5014.   def ygg_can_move?() ; return true ; end
  5015.    
  5016.   #--------------------------------------------------------------------------#
  5017.   # * new-method :ygg_attacker | ygg_battler
  5018.   #--------------------------------------------------------------------------#
  5019.   def ygg_attacker() ; return nil ; end  
  5020.   def ygg_battler()  ; return ygg_attacker() ; end
  5021.    
  5022.   #--------------------------------------------------------------------------#
  5023.   # * new-method :wild_type?
  5024.   #--------------------------------------------------------------------------#
  5025.   def wild_type?() ; return false ; end  
  5026.    
  5027.   #--------------------------------------------------------------------------#
  5028.   # * new-method :ygg_enemy?
  5029.   #--------------------------------------------------------------------------#
  5030.   def ygg_enemy?() ; return false ; end  
  5031.    
  5032.   #--------------------------------------------------------------------------#
  5033.   # * new-method :ygg_ally?
  5034.   #--------------------------------------------------------------------------#
  5035.   def ygg_ally?() ; return false ; end  
  5036.    
  5037.   #--------------------------------------------------------------------------#
  5038.   # * new-method :ygg_death
  5039.   #--------------------------------------------------------------------------#
  5040.   def ygg_death() ; end  
  5041.    
  5042.   #--------------------------------------------------------------------------#
  5043.   # * new-method :ygg_boss?
  5044.   #--------------------------------------------------------------------------#
  5045.   def ygg_boss?() ; return false end  
  5046.    
  5047.   #--------------------------------------------------------------------------#
  5048.   # * new-method :process_extension_actions
  5049.   #--------------------------------------------------------------------------#
  5050.   def process_extension_actions() ; end
  5051.    
  5052.   #--------------------------------------------------------------------------#
  5053.   # * new-method :ygg_can_attack?
  5054.   #--------------------------------------------------------------------------#
  5055.   def ygg_can_attack?() ; return true ; end
  5056.  
  5057.   #--------------------------------------------------------------------------#
  5058.   # * new-method :targetable?
  5059.   #--------------------------------------------------------------------------#
  5060.   def targetable?( target )
  5061.     return false if self.ygg_battler.nil?()
  5062.     return true if target.upcase == "ALL"
  5063.     return true if self.ygg_ally?() && target == "ALLY"
  5064.     return true if self.ygg_enemy?() && target == "ENEMY"
  5065.     return false
  5066.   end  
  5067.  
  5068.   #--------------------------------------------------------------------------#
  5069.   # * new-method :ally_character?
  5070.   #--------------------------------------------------------------------------#  
  5071.   def ally_character?( char )
  5072.     return true if self.ygg_ally?() && char.ygg_ally?()
  5073.     return true if self.ygg_enemy?() && char.ygg_enemy?()
  5074.     return false
  5075.   end
  5076.  
  5077.   #--------------------------------------------------------------------------#
  5078.   # * new-method :enemy_character?
  5079.   #--------------------------------------------------------------------------#  
  5080.   def enemy_character?( char )
  5081.     return !ally_character?( char )
  5082.   end
  5083.  
  5084.   #--------------------------------------------------------------------------#
  5085.   # * new-method :ygg_correct_target
  5086.   #--------------------------------------------------------------------------#  
  5087.   def ygg_correct_target( target )
  5088.     return "ALLY" if self.ygg_enemy?() && target =~ /ENEMY/i
  5089.     return "ENEMY" if self.ygg_enemy?() && target =~ /ALLY/i
  5090.     return target
  5091.   end
  5092.  
  5093.   #--------------------------------------------------------------------------#
  5094.   # * new-method :ygg_abs_update
  5095.   #--------------------------------------------------------------------------#  
  5096.   def ygg_abs_update()
  5097.     @guard_time = [@guard_time - 1, 0].max
  5098.   end  
  5099. # ---------------------------------------------------------------------------- #    
  5100. # Calculations
  5101.  
  5102.   #--------------------------------------------------------------------------#
  5103.   # * new-method :Get Targets
  5104.   #--------------------------------------------------------------------------#
  5105.   # This is used to get all targets at a given location
  5106.   # l_x - x coordiante
  5107.   # l_y - y coordiante
  5108.   # target - "A", "E", "N", "W"
  5109.   # exclude_self - If the target that is encountered, happens to be the
  5110.   #                user, should they be ignored?
  5111.   #--------------------------------------------------------------------------#
  5112.   def ygg_get_targets( l_x=0, l_y=0, target="ALL", exclude_self = false )
  5113.     objects = $game_yggdrasil.battlers_xy( l_x, l_y ).inject([]) { |result, event|
  5114.       if event.targetable?( target )
  5115.         result.push( event )  
  5116.       end unless (exclude_self && event == self)
  5117.       result
  5118.     }
  5119.     if $game_player.pos?( l_x, l_y ) and $game_player.targetable?( target )
  5120.       objects.push( $game_player )  
  5121.     end unless (exclude_self && $game_player == self)
  5122.     return objects
  5123.   end
  5124.  
  5125. # ---------------------------------------------------------------------------- #    
  5126. # Processes
  5127.   #--------------------------------------------------------------------------#
  5128.   # * new-method :update_battler
  5129.   #--------------------------------------------------------------------------#
  5130.   def update_battler()
  5131.     update_states()
  5132.     self.ygg_battler.update_obj_handles()
  5133.     self.ygg_battler.update_cooldown()
  5134.   end
  5135.  
  5136.   #--------------------------------------------------------------------------#
  5137.   # * new-method :update_states
  5138.   #--------------------------------------------------------------------------#
  5139.   def update_states()
  5140.     self.ygg_battler.update_states
  5141.   end
  5142.    
  5143. # ---------------------------------------------------------------------------- #    
  5144. # Yggdrasil Battle Actions
  5145.  
  5146.   #--------------------------------------------------------------------------#
  5147.   # * new-method :get_targets_nearby
  5148.   #--------------------------------------------------------------------------#
  5149.   def get_targets_nearby( range=1, type ="ALL" )
  5150.     coords = []
  5151.     if YGG::FULL_FIELD_SCAN
  5152.       coords.concat( YGG.create_range_data( range ) )  
  5153.     else  
  5154.       case direction
  5155.       when 2
  5156.         for i in 0..range
  5157.           coords.push( [0, i] )
  5158.         end  
  5159.       when 4
  5160.         for i in 0..range
  5161.           coords.push( [-i, 0] )
  5162.         end  
  5163.       when 6
  5164.         for i in 0..range
  5165.           coords.push( [i, 0] )
  5166.         end  
  5167.       when 8
  5168.         for i in 0..range
  5169.           coords.push( [0, -i] )
  5170.         end  
  5171.       end  
  5172.     end  
  5173.     for coo in coords
  5174.       o = ygg_get_targets( coo[0]+self.x, coo[1]+self.y, type, true )
  5175.       return o unless o.empty?()
  5176.     end
  5177.     return []
  5178.   end
  5179.  
  5180. end
  5181.  
  5182. #==============================================================================#
  5183. # ** YGG::MixIns::AI
  5184. #==============================================================================#
  5185. module YGG::MixIns::AI
  5186.  
  5187.   #--------------------------------------------------------------------------#
  5188.   # * Public Instance Variables
  5189.   #--------------------------------------------------------------------------#  
  5190.   attr_accessor :ai_engine
  5191.  
  5192.   #--------------------------------------------------------------------------#
  5193.   # * new-method :setup_ai_engine
  5194.   #--------------------------------------------------------------------------#  
  5195.   def setup_ai_engine( engine, setup_data={} )
  5196.     @ai_engine = engine.new( self, setup_data )
  5197.   end
  5198.  
  5199.   #--------------------------------------------------------------------------#
  5200.   # * new-method :terminate_ai_engine
  5201.   #--------------------------------------------------------------------------#  
  5202.   def terminate_ai_engine()
  5203.     @ai_engine = nil
  5204.   end
  5205.  
  5206.   #--------------------------------------------------------------------------#
  5207.   # * new-method :ygg_update_ai
  5208.   #--------------------------------------------------------------------------#
  5209.   def ygg_update_ai()
  5210.     @ai_engine.update() unless @ai_engine.nil?()
  5211.   end
  5212.  
  5213. end
  5214.  
  5215. #==============================================================================#
  5216. # ** YGG::MixIns::Player
  5217. #==============================================================================#
  5218. module YGG::MixIns::Player
  5219.  
  5220.   #--------------------------------------------------------------------------#
  5221.   # * new-method :drop_attraction?
  5222.   #--------------------------------------------------------------------------#
  5223.   def drop_attraction?()
  5224.     return self.ygg_battler.drops_attraction? unless self.ygg_battler.nil?()
  5225.     return false
  5226.   end
  5227.  
  5228. end  
  5229. #==============================================================================#
  5230. # // Mix In
  5231. class Game_Actor     ; include YGG::MixIns::Actor    ; end
  5232. class Game_Enemy     ; include YGG::MixIns::Enemy    ; end
  5233. class Game_Character ; include YGG::MixIns::Movement ; end
  5234. class Game_Character ; include YGG::MixIns::Battle   ; end
  5235. class Game_Event     ; include YGG::MixIns::AI       ; end
  5236. class Game_Player    ; include YGG::MixIns::Player   ; end
  5237. #==============================================================================#  
  5238. #==============================================================================#
  5239. # ** Game_Character
  5240. #==============================================================================#
  5241. class Game_Character
  5242.  
  5243.   #--------------------------------------------------------------------------#
  5244.   # * Public Instance Variable(s)
  5245.   #--------------------------------------------------------------------------#
  5246.   attr_accessor :use_equipment
  5247.  
  5248.   attr_accessor :ygg_atk_delay
  5249.   attr_accessor :ygg_atk_delay_max
  5250.   attr_accessor :ygg_anims
  5251.  
  5252.   attr_accessor :move_speed_mod
  5253.   attr_accessor :tone
  5254.   attr_accessor :zoom_x, :zoom_y
  5255.   attr_accessor :wait_count
  5256.  
  5257.   attr_reader :action_handle
  5258.   attr_accessor :ygg_invincible
  5259.   attr_accessor :guard_time
  5260.  
  5261.   #--------------------------------------------------------------------------#
  5262.   # * alias-method :initialize
  5263.   #--------------------------------------------------------------------------#
  5264.   alias :ygg_gmc_mixin_initialize :initialize unless $@
  5265.   def initialize( *args, &block )
  5266.     ygg_gmc_mixin_initialize( *args, &block )
  5267.     ygg_initialize()
  5268.   end
  5269.  
  5270.   #--------------------------------------------------------------------------#
  5271.   # * new-method :ygg_initialize
  5272.   #--------------------------------------------------------------------------#
  5273.   def ygg_initialize()
  5274.     @use_equipment     = false
  5275.     @equipment_handles = [::YGG::Handlers::Equip.new( self, 0 ),
  5276.                           ::YGG::Handlers::Equip.new( self, 1 )]
  5277.     @action_handle     = ::YGG::Handlers::Action.new( self, [] )
  5278.     @free_act_handles  = []
  5279.     @ygg_registered    = false
  5280.    
  5281.     @ygg_boss          = false
  5282.     @ygg_anims         = []
  5283.     @ygg_slip_counter  = 0
  5284.     @ygg_invincible    = false
  5285.    
  5286.     @move_speed_mod    = 0
  5287.    
  5288.     reset_tone()
  5289.    
  5290.     @zoom_x, @zoom_y   = 1.0, 1.0
  5291.    
  5292.     @ai_operated       = false
  5293.     @hp_visible        = true
  5294.     @mp_visible        = true
  5295.    
  5296.     @guard_time        = 0
  5297.    
  5298.     ygg_register() if $game_system.yggdrasil_on?()  
  5299.   end
  5300.  
  5301.   #--------------------------------------------------------------------------#
  5302.   # * new-method :pop_enabled?
  5303.   #--------------------------------------------------------------------------#  
  5304.   def pop_enabled?() ; return true ; end
  5305.  
  5306.   #--------------------------------------------------------------------------#
  5307.   # * new-method :reset_tone
  5308.   #--------------------------------------------------------------------------#  
  5309.   def reset_tone()
  5310.     @tone              = Tone.new( 0, 0, 0, 0 )
  5311.     @target_tone       = Tone.new( 0, 0, 0, 0 )
  5312.     @tone_time         = 60.0
  5313.   end
  5314.  
  5315.   #--------------------------------------------------------------------------#
  5316.   # * new-method :screen_rect
  5317.   #--------------------------------------------------------------------------#  
  5318.   def screen_rect()
  5319.     @screen_rect ||= Rect.new( -32, -32, Graphics.width, Graphics.height )
  5320.     return @screen_rect
  5321.   end unless method_defined? :screen_rect
  5322.  
  5323.   #--------------------------------------------------------------------------#
  5324.   # * new-method :onScreen?
  5325.   #--------------------------------------------------------------------------#  
  5326.   def onScreen?()
  5327.     r = self.screen_rect
  5328.     return self.screen_x.between?( r.x, r.width ) && self.screen_y.between?( r.y, r.height )
  5329.   end
  5330.  
  5331.   #--------------------------------------------------------------------------#
  5332.   # * new-method :limitedOnScreen?
  5333.   #--------------------------------------------------------------------------#  
  5334.   def limitedOnScreen?()
  5335.     return false unless screen_x.between?( 0, Graphics.width ) && screen_y.between?( 0, Graphics.height )
  5336.     return true
  5337.   end
  5338.  
  5339.   #--------------------------------------------------------------------------#
  5340.   # * overwrite-method :collide_with_characters?
  5341.   #--------------------------------------------------------------------------#
  5342.   def collide_with_characters?( x, y )
  5343.     for event in $game_map.events_xy( x, y )          # Matches event position
  5344.       unless event.through                          # Passage OFF?
  5345.         return true if event.priority_type == 1     # Target is normal char
  5346.       end
  5347.     end
  5348.     if @priority_type == 1                          # Self is normal char
  5349.       return true if $game_player.pos_nt?(x, y)     # Matches player position
  5350.       return true if $game_map.boat.pos_nt?(x, y)   # Matches boat position
  5351.       return true if $game_map.ship.pos_nt?(x, y)   # Matches ship position
  5352.     end
  5353.     return false
  5354.   end
  5355.  
  5356.   #--------------------------------------------------------------------------#
  5357.   # * overwrite-method :update_move
  5358.   #--------------------------------------------------------------------------#  
  5359.   def update_move()
  5360.     distance = 2 ** self.move_speed   # Convert to movement distance
  5361.     distance *= 2 if dash?        # If dashing, double it
  5362.     @real_x = [@real_x - distance, @x * 256].max if @x * 256 < @real_x
  5363.     @real_x = [@real_x + distance, @x * 256].min if @x * 256 > @real_x
  5364.     @real_y = [@real_y - distance, @y * 256].max if @y * 256 < @real_y
  5365.     @real_y = [@real_y + distance, @y * 256].min if @y * 256 > @real_y
  5366.     update_bush_depth unless moving?
  5367.     if @walk_anime
  5368.       @anime_count += 1.5
  5369.     elsif @step_anime
  5370.       @anime_count += 1
  5371.     end
  5372.   end
  5373.  
  5374.   #--------------------------------------------------------------------------#
  5375.   # * overwrite-method :update_animation
  5376.   #--------------------------------------------------------------------------#  
  5377.   def update_animation()
  5378.     speed = self.move_speed + (dash? ? 1 : 0)
  5379.     if @anime_count > 18 - speed * 2
  5380.       if not @step_anime and @stop_count > 0
  5381.         @pattern = @original_pattern
  5382.       else
  5383.         @pattern = (@pattern + 1) % 4
  5384.       end
  5385.       @anime_count = 0
  5386.     end
  5387.   end
  5388.  
  5389.   #--------------------------------------------------------------------------#
  5390.   # * new-method :extra_speed_mod
  5391.   #--------------------------------------------------------------------------#  
  5392.   def extra_speed_mod()
  5393.     return self.ygg_battler.nil?() ? 0 : ygg_battler.move_mod  
  5394.   end
  5395.  
  5396.   #--------------------------------------------------------------------------#
  5397.   # * new-method :move_speed
  5398.   #--------------------------------------------------------------------------#  
  5399.   def move_speed()
  5400.     return @move_speed + @move_speed_mod + extra_speed_mod
  5401.   end
  5402.  
  5403.   #--------------------------------------------------------------------------#
  5404.   # * new-method :equip_handle
  5405.   #--------------------------------------------------------------------------#
  5406.   def equip_handle( eq_id ) ; @equipment_handles[eq_id] ; end
  5407.    
  5408.   #--------------------------------------------------------------------------#
  5409.   # * new-method :equip_icon
  5410.   #--------------------------------------------------------------------------#  
  5411.   def equip_icon( eq_id )
  5412.     return 0 if self.ygg_battler.nil?()
  5413.     return self.ygg_battler.equip_icon( eq_id )
  5414.   end
  5415.  
  5416.   #--------------------------------------------------------------------------#
  5417.   # * new-method :equip_atk_act_name
  5418.   #--------------------------------------------------------------------------#    
  5419.   def equip_atk_act_name( eq_id )
  5420.     return "" if self.ygg_battler.nil?()
  5421.     return self.ygg_battler.equip_atk_act_name( eq_id )
  5422.   end
  5423.  
  5424.   #--------------------------------------------------------------------------#
  5425.   # * new-method :equip_grd_act_name
  5426.   #--------------------------------------------------------------------------#    
  5427.   def equip_grd_act_name( eq_id )
  5428.     return "" if self.ygg_battler.nil?()
  5429.     return self.ygg_battler.equip_grd_act_name( eq_id )
  5430.   end
  5431.    
  5432.   #--------------------------------------------------------------------------#
  5433.   # * alias-method :update
  5434.   #--------------------------------------------------------------------------#
  5435.   alias :ygg_gmc_mixin_update :update unless $@
  5436.   def update( *args, &block )
  5437.     ygg_gmc_mixin_update( *args, &block )
  5438.     if self.ygg_battler.nil?()
  5439.       ygg_unregister() if @ygg_registered
  5440.     else
  5441.       abs_on = $game_system.yggdrasil_on?()  
  5442.       if abs_on
  5443.         @target_tone = self.ygg_battler.effect_tone
  5444.         if self.ygg_battler.character_need_refresh
  5445.           self.ygg_battler.character_need_refresh = false
  5446.         end  
  5447.         ygg_register() unless @ygg_registered
  5448.         @equipment_handles.each { |eq| eq.update() }
  5449.         self.ygg_engage.update() unless self.ygg_engage.nil?()
  5450.         @action_handle.update()
  5451.         @free_act_handles = @free_act_handles.inject([]) { |r, h|
  5452.           h.update() ; r << h if h.busy?() ; r
  5453.         } unless @free_act_handles.empty?()
  5454.       end  
  5455.     end  
  5456.     [:red, :green, :blue, :gray].each { |s|
  5457.       v1, v2 = @tone.send(s), @target_tone.send(s)
  5458.       if v1 > v2
  5459.         @tone.send( s.to_s+"=", [v1-(255.0/@tone_time), v2].max )
  5460.       elsif v1 < v2
  5461.         @tone.send( s.to_s+"=", [v1+(255.0/@tone_time), v2].min )
  5462.       end  
  5463.     }
  5464.   end
  5465.  
  5466.   #--------------------------------------------------------------------------#
  5467.   # * new-method :ygg_engage
  5468.   #--------------------------------------------------------------------------#
  5469.   def ygg_engage()
  5470.     return ygg_battler.ygg_engage
  5471.   end
  5472.  
  5473.   #--------------------------------------------------------------------------#
  5474.   # * new-method :ygg_register
  5475.   #--------------------------------------------------------------------------#
  5476.   def ygg_register()
  5477.     $game_yggdrasil.add_battler( self )
  5478.     @ygg_registered = true
  5479.   end  
  5480.  
  5481.   #--------------------------------------------------------------------------#
  5482.   # * new-method :ygg_unregister
  5483.   #--------------------------------------------------------------------------#
  5484.   def ygg_unregister()
  5485.     $game_yggdrasil.remove_battler( self )
  5486.     @ygg_registered = false
  5487.   end
  5488.  
  5489.   #--------------------------------------------------------------------------#
  5490.   # * new-method :get_target_events
  5491.   #--------------------------------------------------------------------------#
  5492.   def get_target_events( xy_list )
  5493.     return xy_list.inject([]) { |result, point|
  5494.       result + $game_yggdrasil.battlers_xy( *point )
  5495.     }
  5496.   end
  5497.    
  5498.   #--------------------------------------------------------------------------#
  5499.   # * new-method :set_through
  5500.   #--------------------------------------------------------------------------#  
  5501.   def set_through( bool ) ; @through = bool ; end
  5502.    
  5503. end
  5504.  
  5505. # // (YGG_VG)
  5506. #==============================================================================#
  5507. # // Start Yggdrasil Visual Code
  5508. #==============================================================================#
  5509. # ** YGG
  5510. #==============================================================================#
  5511. module YGG
  5512. #==============================================================================#
  5513. # ** YGG::Sprites::ValueBar_Base
  5514. #==============================================================================#  
  5515.   class Sprites::ValueBar_Base < ::Sprite
  5516.    
  5517.     BAR_DRAW_MODE = 0 # // 0 Use 2 sprites, 1 Draw onto base
  5518.    
  5519.     #--------------------------------------------------------------------------#
  5520.     # * super-method :initialize
  5521.     #--------------------------------------------------------------------------#        
  5522.     def initialize( parent, base_name, bar_name, value_proc, max_proc )
  5523.       super( parent.viewport )
  5524.       @parent       = parent
  5525.       @base_name    = base_name
  5526.       @bar_name     = bar_name
  5527.       case BAR_DRAW_MODE
  5528.       when 0
  5529.         self.bitmap   = Cache.system( base_name )
  5530.         @bar          = ::Sprite_Base.new( self.viewport )
  5531.         @bar.bitmap   = Cache.system( bar_name )
  5532.         @bar.x        = self.x       = @parent.x
  5533.         @bar.y        = self.y       = @parent.y
  5534.         @bar.visible  = self.visible = @parent.visible
  5535.       when 1
  5536.         base_ref      = Cache.system( base_name )
  5537.         self.bitmap   = Bitmap.new( base_ref.width, base_ref.height )
  5538.       end  
  5539.       @value_proc     = value_proc
  5540.       @max_proc       = max_proc
  5541.       @last_value     = -1
  5542.       @last_max       = -1
  5543.       @offsets        = ::YGG::Pos.new( 0, 0, 0 )
  5544.       @baroffsets     = ::YGG::Pos.new( 0, 0, 1 )
  5545.     end
  5546.    
  5547.     #--------------------------------------------------------------------------#
  5548.     # * super-method :dispose
  5549.     #--------------------------------------------------------------------------#    
  5550.     def dispose()
  5551.       case BAR_DRAW_MODE
  5552.       when 0
  5553.         @bar.dispose()
  5554.       when 1
  5555.         self.bitmap.dispose()
  5556.       end  
  5557.       super()
  5558.     end
  5559.    
  5560.   case BAR_DRAW_MODE
  5561.   when 0
  5562.    
  5563.     #--------------------------------------------------------------------------#
  5564.     # * super-method :update
  5565.     #--------------------------------------------------------------------------#    
  5566.     def update()
  5567.       super()
  5568.       val = @value_proc.call() #* 100
  5569.       max = @max_proc.call() #* 100
  5570.       if (val != @last_value || max != @last_max)
  5571.         if max.eql?( 0 )
  5572.           @bar.src_rect.width = 0
  5573.         else  
  5574.           bar_width = @bar.bitmap.width * val / max
  5575.           @bar.src_rect.width = bar_width
  5576.         end  
  5577.         @last_value = val
  5578.         @last_max   = max
  5579.       end
  5580.       pox = @parent.src_rect.width / 2 - (@parent.src_rect.width +
  5581.         self.bitmap.width) / 2
  5582.       @bar.x       = @baroffsets.x + self.x       = @parent.x + pox + @offsets.x
  5583.       @bar.y       = @baroffsets.y + self.y       = @parent.y + @offsets.y
  5584.       @bar.z       = @baroffsets.z + self.z       = @parent.z + @offsets.z
  5585.       @bar.visible = self.visible# = @parent.visible
  5586.       @bar.opacity = self.opacity
  5587.     end
  5588.    
  5589.   when 1  
  5590.    
  5591.     #--------------------------------------------------------------------------#
  5592.     # * super-method :update
  5593.     #--------------------------------------------------------------------------#    
  5594.     def update()
  5595.       super()
  5596.       val = @value_proc.call() #* 100
  5597.       max = @max_proc.call() #* 100
  5598.       if (val != @last_value || max != @last_max)
  5599.         self.bitmap.clear()
  5600.         base = Cache.system( @base_name )
  5601.         bar  = Cache.system( @bar_name )
  5602.         self.bitmap.blt( 0, 0, base, base.rect )
  5603.         unless max.eql?( 0 )
  5604.           bar_width = bar.width * val / max
  5605.           rect = bar.rect.clone()
  5606.           rect.width = bar_width
  5607.           self.bitmap.blt( @baroffsets.x, @baroffsets.y, bar, rect )
  5608.         end  
  5609.         @last_value = val
  5610.         @last_max   = max
  5611.       end
  5612.       pox = @parent.src_rect.width / 2 - (@parent.src_rect.width +
  5613.       self.bitmap.width) / 2
  5614.       self.x       = @parent.x + pox + @offsets.x
  5615.       self.y       = @parent.y + @offsets.y
  5616.       self.z       = @parent.z + @offsets.z
  5617.       #self.visible = @parent.visible
  5618.     end  
  5619.    
  5620.   end
  5621.    
  5622.   end
  5623. #==============================================================================#
  5624. # ** YGG::Sprites::HpBar
  5625. #==============================================================================#    
  5626.   class Sprites::HpBar < Sprites::ValueBar_Base
  5627.    
  5628.     #--------------------------------------------------------------------------#
  5629.     # * super-method :initialize
  5630.     #--------------------------------------------------------------------------#    
  5631.     def initialize( parent )
  5632.       val_proc = Proc.new { @parent.character.ygg_attacker.hp }
  5633.       max_proc = Proc.new { @parent.character.ygg_attacker.maxhp }
  5634.       base_name= "1x6Graphics/EventBarBase"
  5635.       if parent.character.ygg_attacker.actor?()
  5636.         bar_name = "1x6Graphics/EventBar2"
  5637.       else
  5638.         bar_name = "1x6Graphics/EventBar3"
  5639.       end  
  5640.       super( parent, base_name, bar_name, val_proc, max_proc )
  5641.       @offsets.set( 0, 0, 0 )
  5642.       @baroffsets.set( 1, 1, 0 )
  5643.     end
  5644.  
  5645.     #--------------------------------------------------------------------------#
  5646.     # * super-method :update
  5647.     #--------------------------------------------------------------------------#
  5648.     def update()
  5649.       self.opacity = @parent.character.ygg_engage.bar_opacity
  5650.       self.visible = @parent.character.hp_visible?() && @parent.visible
  5651.       super()
  5652.     end
  5653.    
  5654.   end
  5655. #==============================================================================#
  5656. # ** YGG::Sprites::MpBar
  5657. #==============================================================================#  
  5658.   class Sprites::MpBar < Sprites::ValueBar_Base
  5659.    
  5660.     #--------------------------------------------------------------------------#
  5661.     # * super-method :initialize
  5662.     #--------------------------------------------------------------------------#    
  5663.     def initialize( parent )
  5664.       val_proc = Proc.new { @parent.character.ygg_attacker.mp }
  5665.       max_proc = Proc.new { @parent.character.ygg_attacker.maxmp }
  5666.       base_name= "1x6Graphics/EventBarBase"
  5667.       bar_name = "1x6Graphics/EventBar5"
  5668.       super( parent, base_name, bar_name, val_proc, max_proc )
  5669.       @offsets.set( 0, 6, 0 )
  5670.       @baroffsets.set( 1, 1, 1 )
  5671.     end
  5672.    
  5673.     #--------------------------------------------------------------------------#
  5674.     # * super-method :update
  5675.     #--------------------------------------------------------------------------#
  5676.     def update()
  5677.       #self.opacity = @parent.character.ygg_engage.bar_opacity
  5678.       self.visible = @parent.character.mp_visible?() && @parent.visible
  5679.       super()
  5680.     end
  5681.    
  5682.   end
  5683.    
  5684. end  
  5685.  
  5686. #==============================================================================#
  5687. # ** Sprite_Character
  5688. #==============================================================================#
  5689. class Sprite_Character < Sprite_Base
  5690.  
  5691.   #--------------------------------------------------------------------------#
  5692.   # * alias-method :initialize
  5693.   #--------------------------------------------------------------------------#
  5694.   alias :ygg1x6_hpmp_spc_initialize :initialize unless $@
  5695.   def initialize( *args )
  5696.     ygg1x6_hpmp_spc_initialize( *args )
  5697.     create_bars()
  5698.     update_bars()
  5699.   end
  5700.  
  5701.   #--------------------------------------------------------------------------#
  5702.   # * new-method :create_bars
  5703.   #--------------------------------------------------------------------------#
  5704.   def create_bars()
  5705.     unless @character.ygg_battler.nil?()
  5706.       create_hp_bar() if @hp_bar.nil?() if ::YGG::USE_HPBAR
  5707.       create_mp_bar() if @mp_bar.nil?() if ::YGG::USE_MPBAR
  5708.     end
  5709.   end
  5710.  
  5711.   #--------------------------------------------------------------------------#
  5712.   # * new-method :create_hp_bar
  5713.   #--------------------------------------------------------------------------#
  5714.   def create_hp_bar()
  5715.     return if @character.ygg_battler.nil?()
  5716.     @hp_bar = ::YGG::Sprites::HpBar.new( self )
  5717.   end
  5718.  
  5719.   #--------------------------------------------------------------------------#
  5720.   # * new-method :create_mp_bar
  5721.   #--------------------------------------------------------------------------#  
  5722.   def create_mp_bar()
  5723.     return if @character.ygg_battler.nil?()
  5724.     @mp_bar = ::YGG::Sprites::MpBar.new( self )
  5725.   end
  5726.  
  5727.   #--------------------------------------------------------------------------#
  5728.   # * alias-method :dispose
  5729.   #--------------------------------------------------------------------------#
  5730.   alias :ygg1x6_hpmp_spc_dispose :dispose unless $@
  5731.   def dispose()
  5732.     dispose_bars()
  5733.     ygg1x6_hpmp_spc_dispose()
  5734.   end
  5735.  
  5736.   #--------------------------------------------------------------------------#
  5737.   # * new-method :dispose_bars
  5738.   #--------------------------------------------------------------------------#  
  5739.   def dispose_bars()
  5740.     dispose_hp_bar() unless @hp_bar.nil?()
  5741.     dispose_mp_bar() unless @mp_bar.nil?()
  5742.   end
  5743.  
  5744.   #--------------------------------------------------------------------------#
  5745.   # * new-method :dispose_hp_bar
  5746.   #--------------------------------------------------------------------------#  
  5747.   def dispose_hp_bar() ; @hp_bar.dispose() ; @hp_bar = nil ; end
  5748.  
  5749.   #--------------------------------------------------------------------------#
  5750.   # * new-method :dispose_mp_bar
  5751.   #--------------------------------------------------------------------------#  
  5752.   def dispose_mp_bar() ; @mp_bar.dispose() ; @mp_bar = nil ; end
  5753.  
  5754.   #--------------------------------------------------------------------------#
  5755.   # * alias-method :update
  5756.   #--------------------------------------------------------------------------#  
  5757.   alias :ygg1x6_hpmp_spc_update :update unless $@
  5758.   def update()
  5759.     ygg1x6_hpmp_spc_update()
  5760.     update_bars() unless @character.nil?()
  5761.   end
  5762.  
  5763.   #--------------------------------------------------------------------------#
  5764.   # * new-method :update_bars
  5765.   #--------------------------------------------------------------------------#  
  5766.   def update_bars()
  5767.     update_hp_bar() unless @hp_bar.nil?()
  5768.     update_mp_bar() unless @mp_bar.nil?()
  5769.   end
  5770.  
  5771.   #--------------------------------------------------------------------------#
  5772.   # * new-method :update_hp_bar
  5773.   #--------------------------------------------------------------------------#  
  5774.   def update_hp_bar()
  5775.     if @hp_bar.nil?() && !@character.ygg_attacker.nil?()
  5776.       create_hp_bar()
  5777.     elsif !@hp_bar.nil?() && @character.ygg_attacker.nil?()  
  5778.       dispose_hp_bar()
  5779.     end
  5780.     @hp_bar.update() unless @hp_bar.nil?()
  5781.   end
  5782.  
  5783.   #--------------------------------------------------------------------------#
  5784.   # * new-method :update_mp_bar
  5785.   #--------------------------------------------------------------------------#  
  5786.   def update_mp_bar()
  5787.     if @mp_bar.nil?() && !@character.ygg_attacker.nil?()
  5788.       create_mp_bar()
  5789.     elsif !@mp_bar.nil?() && @character.ygg_attacker.nil?()  
  5790.       dispose_mp_bar()
  5791.     end
  5792.     @mp_bar.update() unless @mp_bar.nil?()
  5793.   end
  5794.  
  5795. end if ::YGG::USE_STAT_BARS
  5796.  
  5797. #==============================================================================#
  5798. # ** YGG
  5799. #==============================================================================#
  5800. module YGG  
  5801. #==============================================================================#
  5802. # ** PopText
  5803. #==============================================================================#  
  5804.   PopText = Struct.new( :text, :font, :move_rule )
  5805. #==============================================================================#  
  5806.   class PopText
  5807.    
  5808.   #--------------------------------------------------------------------------#
  5809.   # * new-class-method :create_pop
  5810.   #--------------------------------------------------------------------------#  
  5811.     def self.create_pop( setup_data={} )
  5812.       character  = setup_data[:character]
  5813.       bat        = setup_data[:battler] || (character.nil?() ? nil : character.ygg_battler)
  5814.       type       = setup_data[:type] || :nil
  5815.       parameters = setup_data[:parameters] || []
  5816.       move_rule  = :default
  5817.       pop_stack  = []
  5818.       font_size_add = 0
  5819.       case type
  5820.       when :attack_damage, :skill_damage, :item_damage
  5821.         case type
  5822.         when :attack_damage
  5823.           move_rule = bat.critical ? :shatter : :attack_default
  5824.         when :skill_damage  
  5825.           move_rule = bat.critical ? :shatter : :skill_default
  5826.         when :item_damage
  5827.           move_rule = bat.critical ? :shatter : :item_default
  5828.         end
  5829.         font_size_add += ::YGG::CRITICAL_FONTSIZE_ADD if bat.critical
  5830.         if bat.hp_damage > 0
  5831.           rule = YGG::POPUP_RULES["HP_DMG"]
  5832.           text = sprintf( YGG::POPUP_SETTINGS[:hp_dmg], bat.hp_damage.abs )
  5833.         elsif bat.hp_damage < 0
  5834.           rule = YGG::POPUP_RULES["HP_HEAL"]
  5835.           text = sprintf( YGG::POPUP_SETTINGS[:hp_heal], bat.hp_damage.abs )
  5836.         elsif bat.missed    
  5837.           rule = YGG::POPUP_RULES["MISSED"]
  5838.           text = YGG::POPUP_SETTINGS[:missed]
  5839.         elsif bat.evaded    
  5840.           rule = YGG::POPUP_RULES["EVADED"]
  5841.           text = YGG::POPUP_SETTINGS[:evaded]
  5842.         elsif bat.skipped  
  5843.           rule = YGG::POPUP_RULES["NULLED"]
  5844.           text = YGG::POPUP_SETTINGS[:nulled]
  5845.         elsif bat.hp_damage == 0
  5846.           rule = YGG::POPUP_RULES["HP_NO_DMG"]
  5847.           text = sprintf( YGG::POPUP_SETTINGS[:hp_dmg], bat.hp_damage.abs )
  5848.         end
  5849.         pop_stack << [text, rule, move_rule]  
  5850.         pop_stack << [YGG::POPUP_SETTINGS[:critical],
  5851.                       YGG::POPUP_RULES["CRITICAL"],
  5852.                       :crit_default] if bat.critical if YGG::SHOW_CRITICAL
  5853.         pop_stack << [POPUP_SETTINGS[:guard],
  5854.                       YGG::POPUP_RULES["GUARD"],
  5855.                       :guard_default] if bat.guarding?() if YGG::SHOW_GUARD            
  5856.         if type == :skill_damage || type == :item_damage          
  5857.           skip_stack = false
  5858.           if bat.mp_damage > 0
  5859.             rule = YGG::POPUP_RULES["MP_DMG"]
  5860.             text = sprintf( YGG::POPUP_SETTINGS[:mp_dmg], bat.mp_damage.abs )
  5861.           elsif bat.mp_damage < 0
  5862.             rule = YGG::POPUP_RULES["MP_HEAL"]
  5863.             text = sprintf( YGG::POPUP_SETTINGS[:mp_heal], bat.mp_damage.abs )
  5864.           elsif bat.missed  
  5865.             skip_stack = true
  5866.             #rule = YGG::POPUP_RULES["MISSED"]
  5867.             #text = YGG::POPUP_SETTINGS[:missed]
  5868.           elsif bat.evaded    
  5869.             skip_stack = true
  5870.             #rule = YGG::POPUP_RULES["EVADED"]
  5871.             #text = YGG::POPUP_SETTINGS[:evaded]
  5872.           elsif bat.skipped  
  5873.             skip_stack = true
  5874.             #rule = YGG::POPUP_RULES["NULLED"]
  5875.             #text = YGG::POPUP_SETTINGS[:nulled]
  5876.           elsif bat.mp_damage == 0
  5877.             skip_stack = true
  5878.           #  rule = YGG::POPUP_RULES["MP_NO_DMG"]
  5879.           #  text = sprintf( YGG::POPUP_SETTINGS[:mp_dmg], bat.mp_damage.abs )
  5880.           end
  5881.           pop_stack << [text, rule, move_rule] unless skip_stack
  5882.         end
  5883.       when :gain_exp
  5884.         rule = YGG::POPUP_RULES["EXP_POP"]
  5885.         text = sprintf( YGG::POPUP_SETTINGS[:exp_pop], parameters[0] )
  5886.         move_rule = :exp_default
  5887.         pop_stack << [text, rule, move_rule]
  5888.       when :level_up  
  5889.         rule = YGG::POPUP_RULES["LVL_POP"]
  5890.         text = sprintf( YGG::POPUP_SETTINGS[:lvl_pop], parameters[0] )
  5891.         move_rule = :lvl_default
  5892.         pop_stack << [text, rule, move_rule]
  5893.       when :custom
  5894.         rule = [
  5895.           setup_data[:font_size] || font.size,
  5896.           setup_data[:font_color] || Font.default_color,
  5897.           [(setup_data[:font_bold] || Font.default_bold) ? "BOLD" : "NO BOLD",
  5898.            (setup_data[:font_italic] || Font.default_italic) ? "ITALIC" : "NO ITALIC",
  5899.            (setup_data[:font_shadow] || Font.default_shadow) ? "SHADOW" : "NO SHADOW"
  5900.           ],
  5901.           setup_data[:font_name]
  5902.         ]
  5903.         pop_stack << [setup_data[:text] || "", rule, setup_data[:move_rule] || :default]
  5904.       end
  5905.       pop_stack.each { |pop|
  5906.         text, rule, move_rule = *pop
  5907.         font        = Font.new()
  5908.         proprule    = rule[2].inject([]) { |r, s| s.upcase }
  5909.         colors      = rule[1].kind_of?( Array ) ? rule[1] : [rule[1], rule[1]]
  5910.         font.name   = rule[3].empty? ? Font.default_name : rule[3]
  5911.         font.size   = (rule[0] || Font.default_size) + font_size_add
  5912.         font.bold   = proprule.include?("BOLD")
  5913.         font.italic = proprule.include?("ITALIC")
  5914.         font.shadow = proprule.include?("SHADOW")
  5915.         font.bold   = false if proprule.include?("NO BOLD")
  5916.         font.italic = false if proprule.include?("NO ITALIC")
  5917.         font.shadow = false if proprule.include?("NO SHADOW")
  5918.         font.color  = bat.nil?() ? colors[1] : (bat.actor?() ? colors[1] : colors[0])
  5919.         $game_yggdrasil.add_pop( self.new( text, font, move_rule ), character.x, character.y )
  5920.       }
  5921.     end
  5922.    
  5923.   end  
  5924.  
  5925. #==============================================================================#
  5926. # ** PopHandler
  5927. #==============================================================================#  
  5928.   class PopHandler < ::YGG::Handlers::Screen
  5929.    
  5930.     class BounceHandle
  5931.    
  5932.     #--------------------------------------------------------------------------#
  5933.     # * Public Instance Variable(s)
  5934.     #--------------------------------------------------------------------------#    
  5935.       attr_accessor :x, :y
  5936.       attr_accessor :ox, :oy
  5937.      
  5938.       attr_accessor :x_velocity, :y_velocity
  5939.       attr_accessor :x_boost, :y_boost
  5940.       attr_accessor :x_add, :y_add
  5941.    
  5942.       attr_accessor :cap_duration
  5943.       attr_accessor :finished
  5944.       attr_accessor :pause_update
  5945.       attr_accessor :gravity
  5946.       attr_accessor :floor_val
  5947.      
  5948.     #--------------------------------------------------------------------------#
  5949.     # * Constant(s)
  5950.     #--------------------------------------------------------------------------#      
  5951.       GRAVITY = 0.58
  5952.       TRANSEPARENT_START = 0
  5953.       TRANSEPARENT_X_SLIDE = 0    
  5954.      
  5955.     #--------------------------------------------------------------------------#
  5956.     # * new-method :initialize
  5957.     #--------------------------------------------------------------------------#
  5958.       def initialize( setup_data={} )
  5959.         @start_settings = [setup_data[:x] || 0, setup_data[:y] || 0, 0, 0]
  5960.         @cap_duration = setup_data[:cap_duration] || 80
  5961.         @x_velocity = setup_data[:x_velocity] || 0.4
  5962.         @y_velocity = setup_data[:y_velocity] || 1.5
  5963.         @x_boost    = setup_data[:x_boost] || 8
  5964.         @y_boost    = setup_data[:y_boost] || 4
  5965.         @x_add      = setup_data[:x_add] || 0
  5966.         @y_add      = setup_data[:y_add] || 4
  5967.         @gravity    = setup_data[:gravity] || GRAVITY
  5968.         @floor_val  = setup_data[:floor_val] || 0
  5969.         reset()
  5970.       end
  5971.      
  5972.     #--------------------------------------------------------------------------#
  5973.     # * new-method :reset
  5974.     #--------------------------------------------------------------------------#
  5975.       def reset()
  5976.         @x, @y, @ox, @oy = *@start_settings
  5977.         @finished = false
  5978.         @pause_update = false
  5979.         prep_pop()
  5980.       end
  5981.      
  5982.     #--------------------------------------------------------------------------#
  5983.     # * new-method :x_init_velocity
  5984.     #--------------------------------------------------------------------------#
  5985.       def x_init_velocity()
  5986.         return @x_velocity * ( rand(@x_boost) + @x_add )
  5987.       end
  5988.      
  5989.     #--------------------------------------------------------------------------#
  5990.     # * new-method :y_init_velocity
  5991.     #--------------------------------------------------------------------------#
  5992.       def y_init_velocity()
  5993.         return @y_velocity * ( rand(@y_boost) + @y_add )  
  5994.       end
  5995.      
  5996.     #--------------------------------------------------------------------------#
  5997.     # * new-method :prep_pop
  5998.     #--------------------------------------------------------------------------#
  5999.       def prep_pop()
  6000.         @now_x_speed = x_init_velocity
  6001.         @now_y_speed = y_init_velocity
  6002.         @potential_x_energy = 0.0
  6003.         @potential_y_energy = 0.0
  6004.         @speed_off_x = rand(2)
  6005.         @pop_duration = @cap_duration
  6006.       end
  6007.      
  6008.     #--------------------------------------------------------------------------#
  6009.     # * new-method :update
  6010.     #--------------------------------------------------------------------------#
  6011.       def update()
  6012.         return if @finished or @pause_update
  6013.         if @pop_duration <= TRANSEPARENT_START
  6014.           @x += TRANSEPARENT_X_SLIDE if @speed_off_x == 0
  6015.           @x -= TRANSEPARENT_X_SLIDE if @speed_off_x == 1
  6016.         end
  6017.         n = @oy + @now_y_speed
  6018.         if n <= @floor_val #0
  6019.           @now_y_speed *= -1
  6020.           @now_y_speed /=  2
  6021.           @now_x_speed /=  2
  6022.         end      
  6023.         @oy = [n, @floor_val].max
  6024.         @potential_y_energy += @gravity
  6025.         speed                = @potential_y_energy.floor
  6026.         @now_y_speed        -= speed
  6027.         @potential_y_energy -= speed
  6028.         @potential_x_energy += @now_x_speed
  6029.         speed                = @potential_x_energy.floor
  6030.         @ox                 += speed if @speed_off_x == 0
  6031.         @ox                 -= speed if @speed_off_x == 1
  6032.         @potential_x_energy -= speed
  6033.         @pop_duration       -= 1
  6034.         if @pop_duration == 0
  6035.           @finished = true
  6036.         end
  6037.       end
  6038.    
  6039.     end
  6040.  
  6041.   #--------------------------------------------------------------------------#
  6042.   # * Public Instance Variable(s)
  6043.   #--------------------------------------------------------------------------#    
  6044.     attr_accessor :ox, :oy, :oz
  6045.     attr_accessor :width, :height
  6046.     attr_accessor :zoom_x, :zoom_y
  6047.     attr_accessor :opacity
  6048.    
  6049.     attr_accessor :poptext
  6050.     attr_accessor :completed
  6051.    
  6052.   #--------------------------------------------------------------------------#
  6053.   # * new-method :initialize
  6054.   #--------------------------------------------------------------------------#                      
  6055.     def initialize( poptext, x, y, z )
  6056.       super( x, y, z )
  6057.       @frame     = 0
  6058.       @poptext   = poptext
  6059.       @ox        = 0
  6060.       @oy        = 0
  6061.       @oz        = 0
  6062.       @width     = 128
  6063.       @height    = 32
  6064.       @opacity   = 255
  6065.       @zoom_x    = 1.0
  6066.       @zoom_y    = 1.0
  6067.       @completed = false
  6068.       @bounce_handle = BounceHandle.new( { :x => 0, :y => 0 } )
  6069.     end
  6070.    
  6071.   #--------------------------------------------------------------------------#
  6072.   # * new-method :complete?()
  6073.   #--------------------------------------------------------------------------#                    
  6074.     def complete?() ; return @completed ; end
  6075.      
  6076.   #--------------------------------------------------------------------------#
  6077.   # * new-method :update
  6078.   #--------------------------------------------------------------------------#                  
  6079.     def update()
  6080.       case @poptext.move_rule
  6081.       when :default
  6082.         case @frame
  6083.         when 0..10
  6084.           @ox += 2
  6085.         when 11..20
  6086.           @ox -= 2
  6087.         when 21..40
  6088.           @oy -= 2
  6089.         when 41..60
  6090.           @oy -= 4
  6091.           @opacity -= 255 / 20
  6092.         when 61
  6093.           @completed = true
  6094.         end
  6095.       when :attack_default, :skill_default, :item_default  
  6096.         @bounce_handle.update()
  6097.         @ox, @oy = @bounce_handle.ox, -@bounce_handle.oy
  6098.         @completed = @bounce_handle.finished
  6099.       when :exp_default
  6100.         case @frame
  6101.         when 0...1
  6102.           @oy -= 16
  6103.         when 1..32
  6104.           @oy += 1
  6105.         when 33..64
  6106.           @opacity -= 255 / 32
  6107.         when 65
  6108.           @completed = true
  6109.         end
  6110.       when :lvl_default
  6111.         case @frame
  6112.         when 0..64
  6113.           @ox -= 1
  6114.         when 65..96  
  6115.           @opacity -= 255 / 32
  6116.         when 97
  6117.           @completed = true
  6118.         end  
  6119.       when :crit_default
  6120.         case @frame
  6121.         when 0...1
  6122.           @oy -= 16
  6123.         when 1..32
  6124.           @oy -= 2
  6125.           @zoom_x += 1.0 / 32
  6126.           @zoom_y = @zoom_x
  6127.         when 33..64
  6128.           @opacity -= 255 / 32
  6129.           @zoom_x -= 1.0 / 32
  6130.           @zoom_y = @zoom_x
  6131.         when 65
  6132.           @completed = true
  6133.         end
  6134.       when :guard_default  
  6135.         case @frame
  6136.         when 0...1
  6137.           @oy -= 16
  6138.         when 1..32
  6139.           @oy -= 2
  6140.           @zoom_x += 0.5 / 32
  6141.           @zoom_y = @zoom_x
  6142.         when 33..64
  6143.           @opacity -= 255 / 32
  6144.           @zoom_x -= 0.5 / 32
  6145.           @zoom_y = @zoom_x
  6146.         when 65
  6147.           @completed = true
  6148.         end
  6149.       when :shatter
  6150.         case @frame
  6151.         when 0..5
  6152.           @ox += 3
  6153.         when 6..10
  6154.           @ox -= 3
  6155.         when 11..30
  6156.           @ox += 3
  6157.           @oy -= 1
  6158.           @opacity -= 255 / 80
  6159.         when 31..50
  6160.           @ox -= 3
  6161.           @oy -= 1
  6162.           @opacity -= 255 / 80
  6163.         when 51..60  
  6164.           @opacity -= 255 / 40
  6165.         when 61
  6166.           @completed = true
  6167.         end
  6168.       end
  6169.       @frame += 1
  6170.     end  
  6171.    
  6172.   #--------------------------------------------------------------------------#
  6173.   # * new-method :screen_|x/y/z
  6174.   #--------------------------------------------------------------------------#                
  6175.     def screen_x() ; return super() + @ox      ; end    
  6176.     def screen_y() ; return super() + @oy + 32 ; end    
  6177.     def screen_z() ; return super() + @oz      ; end
  6178.    
  6179.   end
  6180.    
  6181. #==============================================================================#
  6182. # ** PopSprite
  6183. #==============================================================================#  
  6184.   class PopSprite < ::Sprite
  6185.    
  6186.   #--------------------------------------------------------------------------#
  6187.   # * Public Instance Variable(s)
  6188.   #--------------------------------------------------------------------------#        
  6189.     attr_accessor :pophandler
  6190.     attr_accessor :completed
  6191.    
  6192.   #--------------------------------------------------------------------------#
  6193.   # * new-method :initialize
  6194.   #--------------------------------------------------------------------------#              
  6195.     def initialize( viewport, pophandler )
  6196.       super( viewport )
  6197.       @pophandler = pophandler
  6198.       self.bitmap = Bitmap.new( @pophandler.width, @pophandler.height )
  6199.       self.ox = @pophandler.width / 2
  6200.       self.bitmap.font = @pophandler.poptext.font
  6201.       self.bitmap.draw_text( 0, 0, @pophandler.width, 24, @pophandler.poptext.text, 1 )
  6202.     end
  6203.    
  6204.   #--------------------------------------------------------------------------#
  6205.   # * new-method :update
  6206.   #--------------------------------------------------------------------------#            
  6207.     def update()
  6208.       super()
  6209.       self.x = @pophandler.screen_x
  6210.       self.y = @pophandler.screen_y
  6211.       self.z = @pophandler.screen_z
  6212.       self.zoom_x = @pophandler.zoom_x
  6213.       self.zoom_y = @pophandler.zoom_y
  6214.       self.opacity = @pophandler.opacity
  6215.       @completed   = @pophandler.completed
  6216.     end
  6217.    
  6218.   end
  6219. #==============================================================================#
  6220. # ** PopSpriteset
  6221. #==============================================================================#
  6222.   class PopSpriteset
  6223.    
  6224.   #--------------------------------------------------------------------------#
  6225.   # * new-method :initialize
  6226.   #--------------------------------------------------------------------------#        
  6227.     def initialize( viewport )
  6228.       @viewport = viewport
  6229.       @pop_sprites = []
  6230.       create_pops()
  6231.     end
  6232.    
  6233.   #--------------------------------------------------------------------------#
  6234.   # * new-method :create_pops
  6235.   #--------------------------------------------------------------------------#    
  6236.     def create_pops()
  6237.       $game_yggdrasil.new_poptexts.clear()
  6238.       $game_yggdrasil.pop_texts.each { |hnd| add_pop( hnd ) }
  6239.     end
  6240.    
  6241.   #--------------------------------------------------------------------------#
  6242.   # * new-method :dispose
  6243.   #--------------------------------------------------------------------------#
  6244.     def dispose()
  6245.       @pop_sprites.each { |sp| sp.dispose() }
  6246.       @pop_sprites.clear()
  6247.     end
  6248.  
  6249.   #--------------------------------------------------------------------------#
  6250.   # * new-method :update
  6251.   #--------------------------------------------------------------------------#
  6252.     def update()
  6253.       unless $game_yggdrasil.new_poptexts.empty?()
  6254.         $game_yggdrasil.new_poptexts.each { |hnd| add_pop( hnd ) }
  6255.         $game_yggdrasil.new_poptexts.clear()
  6256.       end  
  6257.       @pop_sprites = @pop_sprites.inject([]) { |result, sprite|
  6258.         sprite.update() ; sprite.dispose() if sprite.completed
  6259.         result << sprite unless sprite.disposed?() ; result
  6260.       } unless @pop_sprites.empty?()
  6261.     end
  6262.    
  6263.   #--------------------------------------------------------------------------#
  6264.   # * new-method :add_pop
  6265.   #--------------------------------------------------------------------------#
  6266.     def add_pop( pophandler )
  6267.       @pop_sprites << PopSprite.new( @viewport, pophandler )
  6268.     end
  6269.    
  6270.   end
  6271.  
  6272. end
  6273.  
  6274. #==============================================================================#
  6275. # ** Spriteset_Map
  6276. #==============================================================================#
  6277. class Spriteset_Map
  6278.  
  6279.   #--------------------------------------------------------------------------#
  6280.   # * Public Instance Variable(s)
  6281.   #--------------------------------------------------------------------------#      
  6282.   attr_accessor :poptext_spriteset
  6283.  
  6284.   #--------------------------------------------------------------------------#
  6285.   # * new-method :initialize
  6286.   #--------------------------------------------------------------------------#  
  6287.   alias :ygg_spm_ptxt_initialize :initialize unless $@  
  6288.   def initialize( *args, &block )
  6289.     ygg_spm_ptxt_initialize( *args, &block )
  6290.     create_poptext_spriteset()
  6291.   end
  6292.  
  6293.   #--------------------------------------------------------------------------#
  6294.   # * new-method :create_poptext_spriteset
  6295.   #--------------------------------------------------------------------------#  
  6296.   def create_poptext_spriteset()
  6297.     @poptext_spriteset = YGG::PopSpriteset.new( @viewport2 )
  6298.   end
  6299.  
  6300.   #--------------------------------------------------------------------------#
  6301.   # * alias-method :dispose
  6302.   #--------------------------------------------------------------------------#
  6303.   alias :ygg_spm_ptxt_dispose :dispose unless $@  
  6304.   def dispose( *args, &block )
  6305.     @poptext_spriteset.dispose() unless @poptext_spriteset.nil?()
  6306.     ygg_spm_ptxt_dispose( *args, &block )
  6307.   end
  6308.  
  6309.   #--------------------------------------------------------------------------#
  6310.   # * alias-method :update
  6311.   #--------------------------------------------------------------------------#  
  6312.   alias :ygg_spm_ptxt_update :update unless $@
  6313.   def update( *args, &block )
  6314.     ygg_spm_ptxt_update( *args, &block )
  6315.     @poptext_spriteset.update() unless @poptext_spriteset.nil?()
  6316.   end
  6317.  
  6318. end if ::YGG::USE_TEXT_POP
  6319.  
  6320. # // (YGG_DropsWindow)
  6321. #==============================================================================#
  6322. # ** YGG::Drops_Window
  6323. #==============================================================================#
  6324. class YGG::Drops_Window < ::Sprite
  6325.  
  6326.   #--------------------------------------------------------------------------#
  6327.   # * Constant(s)
  6328.   #--------------------------------------------------------------------------#      
  6329.   CHANGE_MAX  = 90  # 120
  6330.   FADE_LIMIT  = 30  # 30
  6331.   FADE_SPEED  = 40  # 60
  6332.   WLH         = 24
  6333.   BORDER_SIZE = 2
  6334.  
  6335.   #--------------------------------------------------------------------------#
  6336.   # * Public Instance Variable(s)
  6337.   #--------------------------------------------------------------------------#      
  6338.   attr_accessor :cleared
  6339.  
  6340.   #--------------------------------------------------------------------------#
  6341.   # * super-method :initialize
  6342.   #--------------------------------------------------------------------------#
  6343.   def initialize( setup_data={}, viewport=nil )
  6344.     super( viewport )
  6345.     width = setup_data[:width] || 128
  6346.     @background = Sprite.new( self.viewport )
  6347.     @background.bitmap = Bitmap.new( width, WLH )
  6348.     @background.bitmap.fill_rect( BORDER_SIZE, BORDER_SIZE,
  6349.       width-(BORDER_SIZE*2), WLH-(BORDER_SIZE*2),
  6350.       Color.new( 0, 0, 0 ) )
  6351.     @background.bitmap.blur() ; @background.bitmap.blur()
  6352.     @background.opacity = 198
  6353.     self.bitmap = Bitmap.new( width, WLH )
  6354.     self.src_rect.set( 0, 0, width, WLH )
  6355.     @change_time = 0
  6356.     @cleared = false
  6357.     self.x, self.y, self.z = setup_data[:x] || 0, setup_data[:y] || 0, setup_data[:z] || 200
  6358.   end
  6359.  
  6360.   #--------------------------------------------------------------------------#
  6361.   # * super-method :dispose
  6362.   #--------------------------------------------------------------------------#
  6363.   def dispose()
  6364.     unless @background.nil?()
  6365.       @background.bitmap.dispose() ; @background.dispose()
  6366.     end
  6367.     self.bitmap.dispose()
  6368.     super()
  6369.   end
  6370.  
  6371.   #--------------------------------------------------------------------------#
  6372.   # * super-method :x=
  6373.   #--------------------------------------------------------------------------#
  6374.   def x=( new_x )
  6375.     super( new_x )
  6376.     @background.x = self.x
  6377.   end
  6378.  
  6379.   #--------------------------------------------------------------------------#
  6380.   # * super-method :y=
  6381.   #--------------------------------------------------------------------------#
  6382.   def y=( new_y )
  6383.     super( new_y )
  6384.     @background.y = self.y
  6385.   end
  6386.  
  6387.   #--------------------------------------------------------------------------#
  6388.   # * super-method :z=
  6389.   #--------------------------------------------------------------------------#
  6390.   def z=( new_z )
  6391.     super( new_z+1 )
  6392.     @background.z = new_z
  6393.   end
  6394.  
  6395.   #--------------------------------------------------------------------------#
  6396.   # * super-method :viewport=
  6397.   #--------------------------------------------------------------------------#
  6398.   def viewport=( new_viewport )
  6399.     super( new_viewport )
  6400.     @background.viewport = self.viewport
  6401.   end
  6402.  
  6403.   #--------------------------------------------------------------------------#
  6404.   # * super-method :visible=
  6405.   #--------------------------------------------------------------------------#
  6406.   def visible=( new_visible )
  6407.     super( new_visible )
  6408.     @background.visible = self.visible
  6409.   end
  6410.  
  6411.   #--------------------------------------------------------------------------#
  6412.   # * new-method :draw_icon
  6413.   #--------------------------------------------------------------------------#
  6414.   def draw_icon( icon_index, x, y, enabled = true )
  6415.     bitmap = Cache.system( "Iconset" )
  6416.     rect = Rect.new( icon_index % 16 * 24, icon_index / 16 * 24, 24, 24 )
  6417.     self.bitmap.blt( x, y, bitmap, rect, enabled ? 255 : 128 )
  6418.   end unless method_defined? :draw_icon
  6419.  
  6420.   #--------------------------------------------------------------------------#
  6421.   # * new-method :draw_currency_value
  6422.   #--------------------------------------------------------------------------#
  6423.   def draw_currency_value( value, x, y, width )
  6424.     cx = self.bitmap.text_size( Vocab::gold ).width
  6425.     self.bitmap.font.color = Color.new( 255, 255, 255 )
  6426.     self.bitmap.draw_text( x, y, width-cx-2, WLH, value, 2 )
  6427.     self.bitmap.font.color = Color.new( 255, 255, 176 )
  6428.     self.bitmap.draw_text( x, y, width, WLH, Vocab::gold, 2 )
  6429.   end unless method_defined? :draw_currency_value
  6430.  
  6431.   #--------------------------------------------------------------------------#
  6432.   # * super-method :update
  6433.   #--------------------------------------------------------------------------#
  6434.   def update()
  6435.     super()
  6436.     @change_time -= 1 unless @change_time == 0
  6437.     if @change_time <= FADE_LIMIT
  6438.       self.opacity -= 255.0 / FADE_SPEED
  6439.     else
  6440.       self.opacity += 255.0 / FADE_SPEED
  6441.     end  
  6442.     if @change_time <= 0
  6443.       unless @cleared
  6444.         self.bitmap.clear()
  6445.         @cleared = true
  6446.       end  
  6447.       unless $game_player.ygg_gained_items.empty?
  6448.         obj = $game_player.ygg_gained_items.shift
  6449.         draw_icon( obj.icon_index, 4, 0 )
  6450.         self.bitmap.font.color = Color.new( 255, 255, 255 )
  6451.         self.bitmap.font.size  = 18
  6452.         self.bitmap.draw_text( 28, 0, self.width + 32, WLH, obj.name )
  6453.         if obj.is_a?( ::YGG::Containers::GoldItem )
  6454.           cc = obj.gold_amount
  6455.           draw_currency_value( cc, 0, 0, self.width - 4 )
  6456.         end  
  6457.         @cleared = false
  6458.         @change_time = CHANGE_MAX
  6459.       end
  6460.     end  
  6461.   end
  6462.  
  6463. end
  6464.  
  6465. #==============================================================================#
  6466. # ** YGG::Sprites::Animation
  6467. #==============================================================================#  
  6468. class YGG::Sprites::Animation < ::YGG::Handlers::Screen
  6469.  
  6470.   #--------------------------------------------------------------------------#
  6471.   # * Constants
  6472.   #--------------------------------------------------------------------------#
  6473.   RATE = 3 # // RMVX Default is 4
  6474.   RATE = ::Sprite_Base::RATE if $imported["IEO-BugFixesUpgrades"] || $imported["CoreFixesUpgradesMelody"]
  6475.  
  6476.   #--------------------------------------------------------------------------#
  6477.   # * Class Variable(s)
  6478.   #--------------------------------------------------------------------------#
  6479.   @@animations = []
  6480.   @@_reference_count = {}
  6481.  
  6482.   #--------------------------------------------------------------------------#
  6483.   # * Public Instance Variable(s)
  6484.   #--------------------------------------------------------------------------#
  6485.   attr_accessor :completed
  6486.   attr_accessor :looped_anim
  6487.   attr_accessor :started_anim
  6488.   attr_accessor :viewport
  6489.   attr_accessor :ox, :oy
  6490.   attr_accessor :opacity
  6491.  
  6492.   #--------------------------------------------------------------------------#
  6493.   # * new-method :initialize
  6494.   #--------------------------------------------------------------------------#
  6495.   def initialize( viewport=nil )
  6496.     super( 0, 0, 0 )
  6497.     @viewport           = viewport
  6498.     @animation          = nil
  6499.     @animation_bitmap1  = nil
  6500.     @animation_bitmap2  = nil
  6501.     @animation_duration = 0     # Remaining animation time
  6502.     @started_anim       = false
  6503.     @looped_anim        = false
  6504.     @completed          = true
  6505.     @targets            = []
  6506.     @ox, @oy            = -16, -32
  6507.     @opacity            = 255
  6508.   end
  6509.  
  6510.   #--------------------------------------------------------------------------#
  6511.   # * new-method :animation?
  6512.   #--------------------------------------------------------------------------#
  6513.   def animation? ; return !@animation.nil?() ; end
  6514.    
  6515.   #--------------------------------------------------------------------------#
  6516.   # * new-method :width
  6517.   #--------------------------------------------------------------------------#  
  6518.   def width ; return 32 ; end
  6519.    
  6520.   #--------------------------------------------------------------------------#
  6521.   # * new-method :height
  6522.   #--------------------------------------------------------------------------#    
  6523.   def height ; return 32 ; end
  6524.    
  6525.   #--------------------------------------------------------------------------#
  6526.   # * new-method :cell_limit
  6527.   #--------------------------------------------------------------------------#    
  6528.   def cell_limit ; 4 ; end  
  6529.  
  6530.   #--------------------------------------------------------------------------#
  6531.   # * new-method :flash
  6532.   #--------------------------------------------------------------------------#  
  6533.   def flash( color, duration )
  6534.     @targets.each { |sp| sp.flash( color, duration ) unless sp.disposed?() }
  6535.   end
  6536.  
  6537.   #--------------------------------------------------------------------------#
  6538.   # * new-method :screen_rect
  6539.   #--------------------------------------------------------------------------#  
  6540.   def screen_rect()
  6541.     @screen_rect ||= Rect.new( -32, -32, Graphics.width, Graphics.height )
  6542.     return @screen_rect
  6543.   end
  6544.  
  6545.   #--------------------------------------------------------------------------#
  6546.   # * new-method :onScreen?
  6547.   #--------------------------------------------------------------------------#  
  6548.   def onScreen?()
  6549.     r = self.screen_rect
  6550.     return self.screen_x.between?( r.x, r.width ) && self.screen_y.between?( r.y, r.height )
  6551.   end
  6552.  
  6553.   #--------------------------------------------------------------------------#
  6554.   # * new-method :limitedOnScreen?
  6555.   #--------------------------------------------------------------------------#  
  6556.   def limitedOnScreen?()
  6557.     return false unless screen_x.between?( 0, Graphics.width ) && screen_y.between?( 0, Graphics.height )
  6558.     return true
  6559.   end
  6560.  
  6561.   #--------------------------------------------------------------------------#
  6562.   # * new-method :play_anim
  6563.   #--------------------------------------------------------------------------#
  6564.   def play_anim( anim_id, targets=[] )
  6565.     set_targets( targets ) ; animation = $data_animations[anim_id]
  6566.     raise "Animation #{anim_id} does not exist" if ::YGG.debug_mode?() && animation.nil?()
  6567.     animation = RPG::Animation.new if animation.nil?() if ::YGG.silent_error?()
  6568.     start_animation( animation )
  6569.   end
  6570.  
  6571.   #--------------------------------------------------------------------------#
  6572.   # * new-method :setup_pos
  6573.   #--------------------------------------------------------------------------#
  6574.   def setup_pos( x, y, looped = false )
  6575.     self.moveto( x, y )
  6576.     @looped_anim = looped
  6577.   end
  6578.  
  6579.   #--------------------------------------------------------------------------#
  6580.   # * new-method :set_targets
  6581.   #--------------------------------------------------------------------------#
  6582.   def set_targets( new_targets )
  6583.     @targets.clear() ; @targets += new_targets
  6584.     @targets = @targets.flatten.uniq.compact
  6585.   end
  6586.  
  6587.   #--------------------------------------------------------------------------#
  6588.   # * new-method :load_animation_bitmap
  6589.   #--------------------------------------------------------------------------#  
  6590.   def load_animation_bitmap()
  6591.     animation1_name    = @animation.animation1_name
  6592.     animation1_hue     = @animation.animation1_hue
  6593.     animation2_name    = @animation.animation2_name
  6594.     animation2_hue     = @animation.animation2_hue
  6595.     @animation_bitmap1 = Cache.animation(animation1_name, animation1_hue)
  6596.     @animation_bitmap2 = Cache.animation(animation2_name, animation2_hue)
  6597.     if @@_reference_count.include?(@animation_bitmap1)
  6598.       @@_reference_count[@animation_bitmap1] += 1
  6599.     else
  6600.       @@_reference_count[@animation_bitmap1] = 1
  6601.     end
  6602.     if @@_reference_count.include?(@animation_bitmap2)
  6603.       @@_reference_count[@animation_bitmap2] += 1
  6604.     else
  6605.       @@_reference_count[@animation_bitmap2] = 1
  6606.     end
  6607.     Graphics.frame_reset()
  6608.   end
  6609.  
  6610.   #--------------------------------------------------------------------------#
  6611.   # * overwrite-method :start_animation
  6612.   #--------------------------------------------------------------------------#
  6613.   def start_animation( animation, mirror = false )
  6614.     dispose_animation()
  6615.     @animation = animation
  6616.     return if @animation.nil?()
  6617.     @animation_mirror = mirror
  6618.     @animation_duration = @animation.frame_max * RATE + 1
  6619.     load_animation_bitmap()
  6620.     @animation_sprites = []
  6621.     @cell_count = [animation.cell_count, self.cell_limit].min
  6622.     if @animation.position != 3 or not @@animations.include?( animation )
  6623.       for i in 0...@cell_count
  6624.         sprite = ::Sprite.new( viewport )
  6625.         sprite.visible = false
  6626.         @animation_sprites.push( sprite )
  6627.       end
  6628.       unless @@animations.include?( animation )
  6629.         @@animations.push( animation )
  6630.       end
  6631.     end
  6632.     update_animation_position()
  6633.     @started_anim = true
  6634.   end
  6635.  
  6636.   #--------------------------------------------------------------------------#
  6637.   # * new-method :dispose
  6638.   #--------------------------------------------------------------------------#
  6639.   def dispose() ; dispose_animation() ; end
  6640.  
  6641.   #--------------------------------------------------------------------------#
  6642.   # * new-method :dispose_animation
  6643.   #--------------------------------------------------------------------------#
  6644.   def dispose_animation()
  6645.     if @animation_bitmap1 != nil
  6646.       @@_reference_count[@animation_bitmap1] -= 1
  6647.       if @@_reference_count[@animation_bitmap1] == 0
  6648.         @animation_bitmap1.dispose
  6649.       end
  6650.     end
  6651.     if @animation_bitmap2 != nil
  6652.       @@_reference_count[@animation_bitmap2] -= 1
  6653.       if @@_reference_count[@animation_bitmap2] == 0
  6654.         @animation_bitmap2.dispose()
  6655.       end
  6656.     end
  6657.     @animation_sprites.each { |sprite| sprite.dispose } unless @animation_sprites.nil?()
  6658.     @animation_sprites = nil
  6659.     @animation = nil
  6660.     @animation_bitmap1 = nil
  6661.     @animation_bitmap2 = nil
  6662.   end
  6663.  
  6664.   #--------------------------------------------------------------------------#
  6665.   # * new-method: update
  6666.   #--------------------------------------------------------------------------#
  6667.   def update()
  6668.     update_animation() if @animation != nil
  6669.     @@animations.clear
  6670.   end
  6671.  
  6672.   #--------------------------------------------------------------------------#
  6673.   # * new-method: update_animation
  6674.   #--------------------------------------------------------------------------#
  6675.   def update_animation()
  6676.     @animation_duration -= 1
  6677.     update_animation_position() if @animation_duration > 0
  6678.     return unless @animation_duration % RATE == 0
  6679.     if @animation_duration > 0
  6680.       frame_index = @animation.frame_max - ((@animation_duration+RATE-1)/RATE)
  6681.       animation_set_sprites( @animation.frames[frame_index] )
  6682.       for timing in @animation.timings
  6683.         next unless timing.frame == frame_index
  6684.         animation_process_timing( timing )
  6685.       end
  6686.       return
  6687.     end
  6688.     return start_animation( @animation ) if @looped_anim
  6689.     dispose_animation()
  6690.   end
  6691.  
  6692.   #--------------------------------------------------------------------------#
  6693.   # * new-method :animation_set_sprites
  6694.   #--------------------------------------------------------------------------#
  6695.   def animation_set_sprites( frame )
  6696.     cell_data = frame.cell_data
  6697.     for i in 0...@cell_count
  6698.       sprite = @animation_sprites[i]
  6699.       next if sprite.nil?()
  6700.       pattern = cell_data[i, 0]
  6701.       if pattern == nil or pattern == -1
  6702.         sprite.visible = false
  6703.         next
  6704.       end  
  6705.       unless self.onScreen?()
  6706.         sprite.visible = false
  6707.         next
  6708.       end  
  6709.       if pattern < 100
  6710.         sprite.bitmap = @animation_bitmap1
  6711.       else
  6712.         sprite.bitmap = @animation_bitmap2
  6713.       end
  6714.       sprite.visible = true
  6715.       sprite.src_rect.set( pattern % 5 * 192,
  6716.         pattern % 100 / 5 * 192, 192, 192 )
  6717.       if @animation_mirror
  6718.         sprite.x = @animation_ox - cell_data[i, 1]
  6719.         sprite.y = @animation_oy + cell_data[i, 2]
  6720.         sprite.angle = (360 - cell_data[i, 4])
  6721.         sprite.mirror = (cell_data[i, 5] == 0)
  6722.       else
  6723.         sprite.x = @animation_ox + cell_data[i, 1]
  6724.         sprite.y = @animation_oy + cell_data[i, 2]
  6725.         sprite.angle = cell_data[i, 4]
  6726.         sprite.mirror = (cell_data[i, 5] == 1)
  6727.       end
  6728.       sprite.z = self.screen_z + 300 + i
  6729.       sprite.ox = 96
  6730.       sprite.oy = 96
  6731.       sprite.zoom_x = cell_data[i, 3] / 100.0
  6732.       sprite.zoom_y = cell_data[i, 3] / 100.0
  6733.       sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  6734.       sprite.blend_type = cell_data[i, 7]
  6735.     end
  6736.   end
  6737.  
  6738.   #--------------------------------------------------------------------------#
  6739.   # * new-method: animation_process_timing
  6740.   #--------------------------------------------------------------------------#
  6741.   def animation_process_timing( timing )
  6742.     timing.se.play()
  6743.     case timing.flash_scope
  6744.     when 1
  6745.       self.flash( timing.flash_color, timing.flash_duration * RATE )
  6746.     when 2
  6747.       self.viewport.flash( timing.flash_color, timing.flash_duration * RATE ) unless self.viewport.nil?()
  6748.     when 3
  6749.       self.flash( nil, timing.flash_duration * RATE )
  6750.     end
  6751.   end
  6752.  
  6753.   #--------------------------------------------------------------------------#
  6754.   # * new-method :update_animation_position
  6755.   #--------------------------------------------------------------------------#  
  6756.   def update_animation_position()
  6757.     unless self.onScreen?()
  6758.       @animation_ox = -Graphics.width
  6759.       @animation_oy = -Graphics.height
  6760.       return
  6761.     end
  6762.     if @animation.position == 3
  6763.       if self.viewport.nil?()
  6764.         @animation_ox = Integer(Graphics.width) / 2
  6765.         @animation_oy = Integer(Graphics.height) / 2
  6766.       else
  6767.         @animation_ox = self.viewport.rect.width / 2
  6768.         @animation_oy = self.viewport.rect.height / 2
  6769.       end
  6770.     else
  6771.       @animation_ox = self.screen_x + self.ox + self.width / 2
  6772.       @animation_oy = self.screen_y + self.oy + self.height / 2
  6773.       if @animation.position == 0
  6774.         @animation_oy -= self.height / 2
  6775.       elsif @animation.position == 2
  6776.         @animation_oy += self.height / 2
  6777.       end
  6778.     end
  6779.   end
  6780.  
  6781. end
  6782.  
  6783. #==============================================================================#
  6784. # ** YGG::Sprites::Pos
  6785. #==============================================================================#
  6786. class YGG::Sprites::Pos < ::Sprite
  6787.  
  6788. # // Customize Start  
  6789.   #--------------------------------------------------------------------------#
  6790.   # * Constant(s)
  6791.   #--------------------------------------------------------------------------#
  6792.   COLOR1    = Color.new( 128, 128, 255 ) # Main Color
  6793.   COLOR2    = Color.new( 255, 178, 178 ) # Flash Color
  6794.   FLASHTIME = 60
  6795. # // Customize End  
  6796.   #--------------------------------------------------------------------------#
  6797.   # * Public Instance Variable(s)
  6798.   #--------------------------------------------------------------------------#
  6799.   attr_accessor :completed
  6800.   attr_accessor :pos_data
  6801.  
  6802.   #--------------------------------------------------------------------------#
  6803.   # * super-method :initialize
  6804.   #--------------------------------------------------------------------------#
  6805.   def initialize( pos_data, viewport = nil )
  6806.     @completed    = false
  6807.     super( viewport )
  6808.     @use_sprite = true
  6809.     @pos_data = pos_data
  6810.     self.x = @pos_data.screen_x ; self.y = @pos_data.screen_y
  6811.     self.z = 1
  6812.     self.bitmap = Bitmap.new( 32, 32 )
  6813.     rect = Rect.new(1, 1, 30, 30)
  6814.     self.bitmap.fill_rect( rect, COLOR1 )
  6815.     self.ox = 16 ; self.oy = 32
  6816.   end
  6817.  
  6818.   #--------------------------------------------------------------------------#
  6819.   # * super-method :update
  6820.   #--------------------------------------------------------------------------#
  6821.   def update()
  6822.     return if @completed
  6823.     self.x = @pos_data.screen_x()
  6824.     self.y = @pos_data.screen_y()
  6825.     self.z = @pos_data.screen_z()
  6826.     case @pos_data.fader_type
  6827.     when 0
  6828.       self.opacity -= 255 / @pos_data.fade_max
  6829.       @pos_data.fade_amount -= 1 unless @pos_data.fade_amount == 0
  6830.       @completed = true if @pos_data.fade_amount == 0
  6831.     end  
  6832.     super()
  6833.   end
  6834.  
  6835. end
  6836.  
  6837. #==============================================================================#
  6838. # ** YGG::Sprites::Icon
  6839. #==============================================================================#
  6840. class YGG::Sprites::Icon < ::Sprite
  6841.  
  6842.   #--------------------------------------------------------------------------#
  6843.   # * Public Instance Variable(s)
  6844.   #--------------------------------------------------------------------------#  
  6845.   ICON_WIDTH  = 24
  6846.   ICON_HEIGHT = 24
  6847.  
  6848.   #--------------------------------------------------------------------------#
  6849.   # * Public Instance Variable(s)
  6850.   #--------------------------------------------------------------------------#  
  6851.   attr_accessor :ref_object
  6852.  
  6853.   #--------------------------------------------------------------------------#
  6854.   # * super-method :initialize
  6855.   #--------------------------------------------------------------------------#  
  6856.   def initialize( viewport, ref_object )
  6857.     super( viewport )
  6858.     @ref_object = ref_object
  6859.     self.bitmap = Cache.system( "Iconset" )
  6860.     @icon_index = -1
  6861.     update_bitmap()
  6862.   end
  6863.  
  6864.   #--------------------------------------------------------------------------#
  6865.   # * super-method :update
  6866.   #--------------------------------------------------------------------------#
  6867.   def update()
  6868.     super() ; update_bitmap() ; update_position()
  6869.   end
  6870.  
  6871.   #--------------------------------------------------------------------------#
  6872.   # * new-method :update_position
  6873.   #--------------------------------------------------------------------------#
  6874.   def update_position()
  6875.     self.x = @ref_object.screen_x
  6876.     self.y = @ref_object.screen_y
  6877.     self.z = @ref_object.screen_z
  6878.   end
  6879.  
  6880.   #--------------------------------------------------------------------------#
  6881.   # * new-method :update_bitmap
  6882.   #--------------------------------------------------------------------------#
  6883.   def update_bitmap()
  6884.     if @ref_object.icon_index != @icon_index
  6885.       @icon_index = @ref_object.icon_index
  6886.       self.src_rect.set(
  6887.        @icon_index % 16 * ICON_WIDTH ,
  6888.        @icon_index / 16 * ICON_HEIGHT,
  6889.        ICON_WIDTH, ICON_HEIGHT )
  6890.     end
  6891.   end
  6892.  
  6893. end  
  6894.  
  6895. #==============================================================================#
  6896. # ** YGG::Sprites::EquipIcon
  6897. #==============================================================================#
  6898. class YGG::Sprites::EquipIcon < ::YGG::Sprites::Icon
  6899.  
  6900.   #--------------------------------------------------------------------------#
  6901.   # * super-method :initialize
  6902.   #--------------------------------------------------------------------------#
  6903.   def initialize( viewport, character, eqhnd_id )
  6904.     @eqhnd_id = eqhnd_id
  6905.     @parent   = character
  6906.     super( viewport, equip_handle() )
  6907.   end
  6908.  
  6909.   #--------------------------------------------------------------------------#
  6910.   # * overwrite-method :equip_handle
  6911.   #--------------------------------------------------------------------------#
  6912.   def equip_handle() ; return @parent.character.equip_handle( @eqhnd_id ) ; end
  6913.    
  6914.   #--------------------------------------------------------------------------#
  6915.   # * overwrite-method :update_position
  6916.   #--------------------------------------------------------------------------#
  6917.   def update_position()
  6918.     self.ox, self.oy = @ref_object.sox, @ref_object.soy
  6919.     self.x = @parent.x + @ref_object.ox
  6920.     self.y = @parent.y + @ref_object.oy
  6921.     self.z = @parent.z + @ref_object.oz
  6922.   end
  6923.  
  6924.   #--------------------------------------------------------------------------#
  6925.   # * new-method :update_angle
  6926.   #--------------------------------------------------------------------------#
  6927.   def update_angle()
  6928.     self.angle  = @ref_object.angle
  6929.     self.mirror = @ref_object.mirror
  6930.   end
  6931.  
  6932.   #--------------------------------------------------------------------------#
  6933.   # * new-method :update_visible
  6934.   #--------------------------------------------------------------------------#
  6935.   def update_visible()
  6936.     self.visible = @ref_object.visible
  6937.     self.opacity = @ref_object.opacity
  6938.   end
  6939.  
  6940.   #--------------------------------------------------------------------------#
  6941.   # * super-method :update
  6942.   #--------------------------------------------------------------------------#
  6943.   def update()
  6944.     @ref_object = equip_handle()
  6945.     super()
  6946.     update_angle()
  6947.     update_visible()
  6948.   end
  6949.  
  6950. end
  6951.  
  6952. #==============================================================================#
  6953. # ** YGG::Sprites::CharacterIcon
  6954. #==============================================================================#
  6955. class YGG::Sprites::CharacterIcon < ::YGG::Sprites::Icon
  6956.  
  6957.   #--------------------------------------------------------------------------#
  6958.   # * Public Instance Variable(s)
  6959.   #--------------------------------------------------------------------------#
  6960.   attr_accessor :self_timeout
  6961.  
  6962.   #--------------------------------------------------------------------------#
  6963.   # * super-method :initialize
  6964.   #--------------------------------------------------------------------------#
  6965.   def initialize( viewport, character = nil )
  6966.     super( viewport, character )
  6967.     @icon_index = 0
  6968.     self.ox = 12
  6969.     self.oy = 24
  6970.     @ready_to_remove = false
  6971.     @self_timeout = 120
  6972.     update
  6973.   end
  6974.  
  6975.   #--------------------------------------------------------------------------#
  6976.   # * new-method :ready_to_remove?
  6977.   #--------------------------------------------------------------------------#
  6978.   def ready_to_remove?() ; return @ready_to_remove ; end
  6979.  
  6980.   #--------------------------------------------------------------------------#
  6981.   # * super-method :update
  6982.   #--------------------------------------------------------------------------#
  6983.   def update()
  6984.     super()
  6985.     @self_timeout    = @ref_object.icon_time_out
  6986.     @ready_to_remove = true if @self_timeout == 0
  6987.     self.visible     = @ref_object.visible
  6988.     self.opacity     = @ref_object.opacity
  6989.   end
  6990.  
  6991. end
  6992.  
  6993. #==============================================================================#
  6994. # ** Sprite_Character
  6995. #==============================================================================#
  6996. class Sprite_Character < Sprite_Base
  6997.  
  6998.   #--------------------------------------------------------------------------#
  6999.   # * alias-method :initialize
  7000.   #--------------------------------------------------------------------------#
  7001.   alias :ygg_spc_initialize :initialize unless $@
  7002.   def initialize( *args, &block )
  7003.     ygg_spc_initialize( *args, &block )
  7004.     create_equipment()
  7005.   end
  7006.  
  7007.   #--------------------------------------------------------------------------#
  7008.   # * alias-method :dispose
  7009.   #--------------------------------------------------------------------------#
  7010.   alias :ygg_spc_dispose :dispose unless $@
  7011.   def dispose( *args, &block )
  7012.     ygg_spc_dispose( *args, &block )
  7013.     dispose_equipment()
  7014.   end
  7015.  
  7016.   #--------------------------------------------------------------------------#
  7017.   # * alias-method :update
  7018.   #--------------------------------------------------------------------------#
  7019.   alias :ygg_spc_update :update unless $@
  7020.   def update( *args, &block )
  7021.     ygg_spc_update( *args, &block )
  7022.     unless @equipment.nil?()
  7023.       if @character.use_equipment && @equipment.empty?() ; create_equipment()
  7024.       elsif !@character.use_equipment && !@equipment.empty?() ; dispose_equipment()
  7025.       end
  7026.       update_equipment()
  7027.     end  
  7028.     if $scene.is_a?( Scene_Map )
  7029.       @character.ygg_anims.each { |aid| $scene.push_ygg_anim( aid, @character.x, @character.y ) }
  7030.       @character.ygg_anims.clear()
  7031.     end  
  7032.     self.tone = @character.tone
  7033.     self.zoom_x = @character.zoom_x
  7034.     self.zoom_y = @character.zoom_y
  7035.   end
  7036.  
  7037.   #--------------------------------------------------------------------------#
  7038.   # * new-method :create_equipment
  7039.   #--------------------------------------------------------------------------#
  7040.   def create_equipment()
  7041.     @equipment = []
  7042.     if @character.use_equipment
  7043.       @equipment[0] = YGG::Sprites::EquipIcon.new( self.viewport, self, 0 ) # Weap
  7044.       @equipment[1] = YGG::Sprites::EquipIcon.new( self.viewport, self, 1 ) # Shld
  7045.     end  
  7046.   end
  7047.  
  7048.   #--------------------------------------------------------------------------#
  7049.   # * new-method :dispose_equipment
  7050.   #--------------------------------------------------------------------------#
  7051.   def dispose_equipment()
  7052.     @equipment.each { |e| e.dispose() } ; @equipment.clear()
  7053.   end
  7054.  
  7055.   #--------------------------------------------------------------------------#
  7056.   # * new-method :update_equipment
  7057.   #--------------------------------------------------------------------------#
  7058.   def update_equipment() ; @equipment.each { |e| e.update() } ; end
  7059.  
  7060. end
  7061.  
  7062. #==============================================================================#
  7063. # ** YGG::Sprites::Projectile
  7064. #==============================================================================#
  7065. class ::YGG::Sprites::Projectile < Sprite_Character
  7066.  
  7067.   #--------------------------------------------------------------------------#
  7068.   # * overwrite-method :create_bars
  7069.   #--------------------------------------------------------------------------#  
  7070.   def create_bars()  ; end
  7071.    
  7072.   #--------------------------------------------------------------------------#
  7073.   # * overwrite-method :dispose_bars
  7074.   #--------------------------------------------------------------------------#    
  7075.   def dispose_bars() ; end
  7076.  
  7077.   #--------------------------------------------------------------------------#
  7078.   # * overwrite-method :update_bars
  7079.   #--------------------------------------------------------------------------#    
  7080.   def update_bars()  ; end
  7081.    
  7082. end
  7083.  
  7084. #==============================================================================#
  7085. # ** Spriteset_Map
  7086. #==============================================================================#
  7087. class Spriteset_Map
  7088.  
  7089.   #--------------------------------------------------------------------------#
  7090.   # * Public Instance Variable(s)
  7091.   #--------------------------------------------------------------------------#
  7092.   attr_accessor :anim_viewport # Viewport used by Ygg Anims
  7093.   attr_accessor :character_sprites
  7094.   attr_accessor :projectile_sprites
  7095.   attr_accessor :range_sprites
  7096.   attr_accessor :drop_sprites
  7097.   attr_accessor :ygg_anims
  7098.   attr_accessor :viewport1, :viewport2, :viewport3
  7099.  
  7100.   #--------------------------------------------------------------------------#
  7101.   # * alias-method :initialize
  7102.   #--------------------------------------------------------------------------#
  7103.   alias :ygg_anim_ssm_initialize :initialize unless $@
  7104.   def initialize( *args, &block )
  7105.     ygg_anim_ssm_initialize( *args, &block )
  7106.     @disposed = false
  7107.     create_projectiles()
  7108.     create_anims()
  7109.     create_ranges()
  7110.     create_drops()
  7111.   end
  7112.  
  7113.   #--------------------------------------------------------------------------#
  7114.   # * new-method :get_character
  7115.   #--------------------------------------------------------------------------#
  7116.   def get_character( ev )
  7117.     @character_sprites.each { |s| return s if s.character == ev }
  7118.   end  
  7119.  
  7120.   #--------------------------------------------------------------------------#
  7121.   # * new-method :disposed?
  7122.   #--------------------------------------------------------------------------#
  7123.   def disposed?() ; return @disposed ; end
  7124.    
  7125.   #--------------------------------------------------------------------------#
  7126.   # * alias-method :dispose
  7127.   #--------------------------------------------------------------------------#
  7128.   alias :ygg_anim_ssm_dispose :dispose unless $@
  7129.   def dispose( *args, &block )
  7130.     ygg_anim_ssm_dispose( *args, &block )
  7131.     @projectile_sprites.each { |spr| ; spr.dispose() } unless @projectile_sprites.nil?()
  7132.     @ygg_anims.each { |anim| ; anim.dispose()        } unless @ygg_anims.nil?()
  7133.     @range_sprites.each { |rng| ; rng.dispose()      } unless @range_sprites.nil?()
  7134.     @drop_sprites.each { |dr| ; dr.dispose()         } unless @drop_sprites.nil?()
  7135.     @projectile_sprites = nil ; @ygg_anims          = nil
  7136.     @range_sprites      = nil ; @drop_sprites       = nil
  7137.     @disposed = true
  7138.   end
  7139.  
  7140.   #--------------------------------------------------------------------------#
  7141.   # * new-method :create_drops
  7142.   #--------------------------------------------------------------------------#
  7143.   def create_drops()
  7144.     drops = $game_map.active_drops
  7145.     @drop_sprites = drops.inject([]) { |result, char|
  7146.       spr = YGG::Sprites::CharacterIcon.new( @viewport1, char )
  7147.       spr.self_timeout = char.icon_time_out
  7148.       result.push( spr )
  7149.     }
  7150.   end  
  7151.  
  7152.   #--------------------------------------------------------------------------#
  7153.   # * new-method :create_ranges
  7154.   #--------------------------------------------------------------------------#
  7155.   def create_ranges()
  7156.     @range_sprites = $game_map.active_ranges.inject([]) { |result, range|
  7157.       result.push( YGG::Sprites::Pos.new( range, @viewport1 ) )
  7158.     }
  7159.   end  
  7160.  
  7161.   #--------------------------------------------------------------------------#
  7162.   # * new-method :create_projectiles
  7163.   #--------------------------------------------------------------------------#
  7164.   def create_projectiles()
  7165.     @projectile_sprites = []
  7166.     $game_yggdrasil.new_projectiles.clear()
  7167.     $game_yggdrasil.projectiles.each { |pro| add_projectile_sprite( pro ) }
  7168.   end
  7169.  
  7170.   #--------------------------------------------------------------------------#
  7171.   # * new-method :create_anims
  7172.   #--------------------------------------------------------------------------#
  7173.   def create_anims()
  7174.     @ygg_anims = []
  7175.     for i in 0...YGG::TOTAL_WILD_ANIMS
  7176.       anim = ::YGG::Sprites::Animation.new( @anim_viewport )
  7177.       @ygg_anims.push( anim )
  7178.     end
  7179.   end
  7180.  
  7181.   #--------------------------------------------------------------------------#
  7182.   # * new-method :push_anim
  7183.   #--------------------------------------------------------------------------#
  7184.   def push_anim( anim_id, x, y, targets=[], looped=false )
  7185.     return if @disposed
  7186.     for anim in @ygg_anims#.compact()
  7187.       unless anim.animation?
  7188.         anim.setup_pos( x, y, looped )  
  7189.         anim.play_anim( anim_id,
  7190.           targets.inject([]) { |r, e| r << get_character( e ) } )  
  7191.         return anim
  7192.       end  
  7193.     end
  7194.   end
  7195.  
  7196.   #--------------------------------------------------------------------------#
  7197.   # * new-method :add_projectile_sprite
  7198.   #--------------------------------------------------------------------------#
  7199.   def add_projectile_sprite( projectile )
  7200.     return if @disposed
  7201.     return nil if projectile.nil?()
  7202.     spr = ::YGG::Sprites::Projectile.new( @viewport1, projectile )
  7203.     @projectile_sprites.push( spr )
  7204.     return spr
  7205.   end
  7206.  
  7207.   #--------------------------------------------------------------------------#
  7208.   # * new-method :range
  7209.   #--------------------------------------------------------------------------#
  7210.   def add_range_sprite( range )
  7211.     return if @disposed
  7212.     return nil if range.nil?()
  7213.     sprite = ::YGG::Sprites::Pos.new( range, @viewport1 )
  7214.     @range_sprites.push( sprite )
  7215.     return spr
  7216.   end  
  7217.  
  7218.   #--------------------------------------------------------------------------#
  7219.   # * new-method :add_drop_sprite
  7220.   #--------------------------------------------------------------------------#
  7221.   def add_drop_sprite( char )
  7222.     return if @disposed
  7223.     return nil if char.nil?()
  7224.     spr = YGG::Sprites::CharacterIcon.new( @viewport1, char )
  7225.     spr.self_timeout = char.icon_time_out
  7226.     @drop_sprites.push( spr )
  7227.     return spr
  7228.   end
  7229.  
  7230.   #--------------------------------------------------------------------------#
  7231.   # * alias-method :create_viewports
  7232.   #--------------------------------------------------------------------------#
  7233.   alias :ygg_anim_ssm_create_viewports :create_viewports unless $@
  7234.   def create_viewports( *args, &block )
  7235.     ygg_anim_ssm_create_viewports( *args, &block )
  7236.     @anim_viewport = Viewport.new( 0, 0, Graphics.width, Graphics.height )
  7237.     @anim_viewport.z = 100
  7238.   end
  7239.  
  7240.   #--------------------------------------------------------------------------#
  7241.   # * alias-method :update
  7242.   #--------------------------------------------------------------------------#
  7243.   alias :ygg_anim_ssm_update :update unless $@
  7244.   def update( *args, &block )
  7245.     return if @disposed
  7246.     ygg_anim_ssm_update( *args, &block )  
  7247.     update_anims()       unless @ygg_anims.nil?()
  7248.     update_projectiles() unless @projectile_sprites.nil?()  
  7249.     update_ranges()      unless @range_sprites.nil?()
  7250.     update_drops()       unless @drop_sprites.nil?()
  7251.   end
  7252.  
  7253.   #--------------------------------------------------------------------------#
  7254.   # * new-method :update_anims
  7255.   #--------------------------------------------------------------------------#
  7256.   def update_anims()
  7257.     @ygg_anims.each { |anim| anim.update() if anim.animation?() }
  7258.   end
  7259.  
  7260.   #--------------------------------------------------------------------------#
  7261.   # * new-method :update_projectiles
  7262.   #--------------------------------------------------------------------------#
  7263.   def update_projectiles()
  7264.     unless $game_yggdrasil.new_projectiles.empty?()
  7265.       $game_yggdrasil.new_projectiles.each { |pro| add_projectile_sprite( pro ) }
  7266.       $game_yggdrasil.new_projectiles.clear()
  7267.     end  
  7268.     @projectile_sprites = @projectile_sprites.inject([]) { |result, spr|
  7269.       spr.update() ; spr.dispose() if spr.character.terminated?()
  7270.       result << spr unless spr.disposed?() ; result
  7271.     } unless @projectile_sprites.empty?()
  7272.   end
  7273.  
  7274.   #--------------------------------------------------------------------------#
  7275.   # * new-method :update_ranges
  7276.   #--------------------------------------------------------------------------#
  7277.   def update_ranges()
  7278.     @range_sprites = @range_sprites.inject([]) { |result, rng|
  7279.       ran.update()
  7280.       if ran.completed()
  7281.         $game_map.active_ranges.delete( ran.pos_data ) ; ran.dispose()
  7282.       else ; ran.update() ; end  
  7283.       result << rng unless ran.disposed?() ; result
  7284.     } unless @range_sprites.empty?()
  7285.   end
  7286.  
  7287.   #--------------------------------------------------------------------------#
  7288.   # * new-method :update_drops
  7289.   #--------------------------------------------------------------------------#
  7290.   def update_drops()
  7291.     @drop_sprites = @drop_sprites.inject([]) { |result, dr|
  7292.       dr.ready_to_remove?() ? dr.dispose() : dr.update()
  7293.       result << dr unless dr.disposed?() ; result
  7294.     } unless @drop_sprites.empty?()
  7295.   end
  7296.  
  7297.   #--------------------------------------------------------------------------#
  7298.   # * alias-method :update_viewports
  7299.   #--------------------------------------------------------------------------#
  7300.   alias :ygg_anim_ssm_update_viewports :update_viewports unless $@
  7301.   def update_viewports( *args, &block )
  7302.     ygg_anim_ssm_update_viewports( *args, &block )
  7303.     @anim_viewport.update() unless @anim_viewport.nil?()
  7304.   end
  7305.  
  7306.   #--------------------------------------------------------------------------#
  7307.   # * alias-method :dispose_viewports
  7308.   #--------------------------------------------------------------------------#
  7309.   alias :ygg_anim_ssm_dispose_viewports :dispose_viewports unless $@
  7310.   def dispose_viewports( *args, &block )
  7311.     ygg_anim_ssm_dispose_viewports( *args, &block )
  7312.     @anim_viewport.dispose() unless @anim_viewport.nil?() ; @anim_viewport = nil
  7313.   end
  7314.  
  7315. end
  7316.  
  7317. # // (YGG_SC) - System Code
  7318. #==============================================================================#
  7319. # // Start Yggdrasil Main Code
  7320. #==============================================================================#
  7321. # ** Game System
  7322. #==============================================================================#
  7323. class Game_System
  7324.  
  7325.   #--------------------------------------------------------------------------#
  7326.   # * Public Instance Variable(s)
  7327.   #--------------------------------------------------------------------------#
  7328.   attr_accessor :ygg_hit_count
  7329.   attr_accessor :ygg_hit_down_wait
  7330.  
  7331.   attr_accessor :draw_damage_ranges
  7332.   attr_accessor :gameover_alldead
  7333.  
  7334.   #--------------------------------------------------------------------------#
  7335.   # * alias-method :initialize
  7336.   #--------------------------------------------------------------------------#
  7337.   alias :ygg_gs_initialize :initialize unless $@
  7338.   def initialize( *args, &block )
  7339.     ygg_gs_initialize( *args, &block )
  7340.     @ygg_hit_count      = 0
  7341.     @ygg_hit_down_wait  = 0
  7342.     @draw_damage_ranges = YGG::DRAW_RANGES
  7343.     @gameover_alldead   = YGG::ALL_DEAD_GAMEOVER
  7344.   end
  7345.  
  7346.   #--------------------------------------------------------------------------#
  7347.   # * new-method :gameover_alldead?
  7348.   #--------------------------------------------------------------------------#
  7349.   def gameover_alldead?() ; return @gameover_alldead end
  7350.    
  7351.   #--------------------------------------------------------------------------#
  7352.   # * alias-method :update
  7353.   #--------------------------------------------------------------------------#
  7354.   alias :ygg_gs_update :update unless $@
  7355.   def update( *args, &block )
  7356.     ygg_gs_update( *args, &block )
  7357.     unless $game_message.visible
  7358.       @ygg_hit_down_wait -= 1 unless @ygg_hit_down_wait == 0
  7359.       @ygg_hit_count = 0 if @ygg_hit_down_wait == 0
  7360.     end if $scene.is_a?( Scene_Map )
  7361.   end
  7362.  
  7363.   #--------------------------------------------------------------------------#
  7364.   # * mew-method :control_self_switch
  7365.   #--------------------------------------------------------------------------#
  7366.   def control_self_switch( map_id, event_id, switch, value )
  7367.     $game_self_switches[[map_id, event_id, switch]] = value
  7368.     $game_map.need_refresh = true
  7369.   end
  7370.  
  7371.   #--------------------------------------------------------------------------#
  7372.   # * new-method :yggdrasil_on?
  7373.   #--------------------------------------------------------------------------#
  7374.   def yggdrasil_on?() ; return $game_yggdrasil.on?() ; end
  7375.    
  7376. end
  7377.  
  7378. #==============================================================================#
  7379. # ** Game Battler
  7380. #==============================================================================#
  7381. class Game_Battler
  7382.  
  7383.   #--------------------------------------------------------------------------#
  7384.   # * Public Instance Variable(s)
  7385.   #--------------------------------------------------------------------------#
  7386.   attr_accessor :character_need_refresh
  7387.   attr_accessor :ygg_slip_counter
  7388.  
  7389.   attr_accessor :ygg_engage
  7390.  
  7391.   attr_accessor :skill_slot_size, :item_slot_size
  7392.  
  7393.   attr_accessor :ygg_guard
  7394.  
  7395.   #--------------------------------------------------------------------------#
  7396.   # * alias-method :initialize
  7397.   #--------------------------------------------------------------------------#
  7398.   alias :ygg_gb_initialize :initialize unless $@
  7399.   def initialize( *args, &block )
  7400.     ygg_gb_initialize( *args, &block )
  7401.     @state_ticks      = {}
  7402.     @ygg_slip_counter = 0
  7403.     @ygg_engage       = ::YGG::Handlers::Engage.new( self )
  7404.     @skill_slot_size, @item_slot_size =  5, 5
  7405.     @skill_slots    , @item_slots     = [], []
  7406.     @skill_handles  , @item_handles   = {}, {}
  7407.     @ygg_guard = false
  7408.     @cooldown, @cooldown_max, = 0, 300
  7409.     clear_stat_cache()
  7410.     clear_item_slots()
  7411.     clear_skill_slots()
  7412.   end
  7413.  
  7414.   #--------------------------------------------------------------------------#
  7415.   # * overwrite-method :skill_can_use?
  7416.   #--------------------------------------------------------------------------#
  7417.   def skill_can_use?( skill )
  7418.     return false unless skill.is_a?( RPG::Skill )
  7419.     return false unless movable?()
  7420.     return false if silent?() and skill.spi_f > 0
  7421.     return false if calc_mp_cost( skill ) > mp
  7422.     if $game_temp.in_battle  
  7423.       return skill.battle_ok?()
  7424.     elsif $game_system.yggdrasil_on?() and $scene.is_a?( Scene_Map )
  7425.       return skill.battle_ok?()
  7426.     else
  7427.       return skill.menu_ok?()
  7428.     end
  7429.   end
  7430.  
  7431.   #--------------------------------------------------------------------------#
  7432.   # * new-method :guarding?
  7433.   #--------------------------------------------------------------------------#
  7434.   def guarding?()
  7435.     return @action.guard?() || @ygg_guard
  7436.   end
  7437.  
  7438.   #--------------------------------------------------------------------------#
  7439.   # * new-method :get_action_by_id
  7440.   #--------------------------------------------------------------------------#
  7441.   def get_action_by_id( id )
  7442.     return []
  7443.   end
  7444.  
  7445.   #--------------------------------------------------------------------------#
  7446.   # ** new-method :ygg_range
  7447.   #--------------------------------------------------------------------------#
  7448.   def ygg_range ; return 0 end
  7449.  
  7450.   #--------------------------------------------------------------------------#
  7451.   # ** new-method :drops_attraction?
  7452.   #--------------------------------------------------------------------------#
  7453.   def drops_attraction? ; return false end
  7454.    
  7455.   #--------------------------------------------------------------------------#
  7456.   # ** new-method :equip_icon
  7457.   #--------------------------------------------------------------------------#
  7458.   def equip_icon( eq_id ) ; return 0 ; end
  7459.    
  7460.   #--------------------------------------------------------------------------#
  7461.   # * new-method :equip_atk_act_name
  7462.   #--------------------------------------------------------------------------#    
  7463.   def equip_atk_act_name( eq_id ) ; return "" ; end
  7464.  
  7465.   #--------------------------------------------------------------------------#
  7466.   # * new-method :equip_grd_act_name
  7467.   #--------------------------------------------------------------------------#    
  7468.   def equip_grd_act_name( eq_id ) ; return "" ; end
  7469.  
  7470.   #--------------------------------------------------------------------------#
  7471.   # * alias-method :maxhp/maxmp/atk/def/spi/agi
  7472.   #--------------------------------------------------------------------------#    
  7473.   [:maxhp, :maxmp, :atk, :def, :spi, :agi].each { |m|  
  7474.     module_eval( %Q(
  7475.     alias :ygg_gb_#{m.to_s} #{m} unless $@
  7476.     def #{m.to_s}( *args, &block )
  7477.       @cached_#{m.to_s} ||= ygg_gb_#{m.to_s}( *args, &block )
  7478.       return @cached_#{m.to_s}  
  7479.     end  
  7480.    
  7481.     alias :ygg_gb_#{m.to_s}_set #{m}= unless $@
  7482.     def #{m.to_s}=( new_value )
  7483.       @cached_#{m.to_s} = nil if new_value != @cached_#{m.to_s}
  7484.       ygg_gb_#{m.to_s}_set( new_value )
  7485.     end
  7486.     ) )
  7487.   }  
  7488.  
  7489.   #--------------------------------------------------------------------------#
  7490.   # * new-method :clear_stat_cache
  7491.   #--------------------------------------------------------------------------#  
  7492.   def clear_stat_cache()
  7493.     @cached_maxhp = nil
  7494.     @cached_maxmp = nil
  7495.     @cached_atk   = nil
  7496.     @cached_def   = nil
  7497.     @cached_spi   = nil
  7498.     @cached_agi   = nil
  7499.    
  7500.     @cached_move  = nil
  7501.     @cached_tone  = nil
  7502.     @cached_slip  = nil
  7503.     @cached_slip_freq = nil
  7504.    
  7505.     @cached_level_exp = nil
  7506.     @cached_next_level_exp = nil
  7507.    
  7508.     @character_need_refresh = true
  7509.   end
  7510.  
  7511.   #--------------------------------------------------------------------------#
  7512.   # * alias-method :recover_all
  7513.   #--------------------------------------------------------------------------#
  7514.   alias :ygg_gb_recover_all :recover_all unless $@
  7515.   def recover_all( *args, &block )
  7516.     clear_stat_cache()
  7517.     ygg_gb_recover_all( *args, &block )
  7518.   end
  7519.  
  7520. if ::YGG::FULL_INTEGRATION  
  7521.  
  7522.   #--------------------------------------------------------------------------#
  7523.   # * alias-method :add_state
  7524.   #--------------------------------------------------------------------------#  
  7525.   alias :ygg_gb_fi_add_state :add_state unless $@
  7526.   def add_state( state_id )
  7527.     sti = state_ignore?( state_id )
  7528.     ygg_gb_fi_add_state( state_id )
  7529.     state = $data_states[state_id]        
  7530.     return if state.nil?() ; return if sti
  7531.     @state_ticks[state_id] = state.hold_ticks unless state.id == 1
  7532.   end
  7533.  
  7534.   #--------------------------------------------------------------------------#
  7535.   # * alias-method :remove_state
  7536.   #--------------------------------------------------------------------------#  
  7537.   alias :ygg_gb_fi_remove_state :remove_state unless $@
  7538.   def remove_state( state_id )
  7539.     ygg_gb_fi_remove_state( state_id )
  7540.     @state_ticks.delete( state_id )
  7541.   end
  7542.  
  7543.   #--------------------------------------------------------------------------#
  7544.   # * alias-method :update_state_ticks
  7545.   #--------------------------------------------------------------------------#
  7546.   def update_state_ticks()
  7547.     @state_ticks.keys.clone.each { |key|
  7548.       state = $data_states[key]
  7549.       if state.nil?() ; @state_ticks.delete(key) ; next ; end
  7550.       @state_ticks[key] -= 1
  7551.       remove_state( key ) if @state_ticks[key] < 0 && rand(100) < state.auto_release_prob
  7552.     }
  7553.   end  
  7554.  
  7555.   #--------------------------------------------------------------------------#
  7556.   # * overwrite-method :slip_damage?
  7557.   #--------------------------------------------------------------------------#  
  7558.   def slip_damage?()
  7559.     @cached_slip ||= self.states.any?() { |s| s.slip_damage }
  7560.     return @cached_slip
  7561.   end
  7562.  
  7563.   #--------------------------------------------------------------------------#
  7564.   # * overwrite-method :slip_damage_effect
  7565.   #--------------------------------------------------------------------------#  
  7566.   def slip_damage_effect()
  7567.     self.hp -= 1 if slip_damage? and @hp > 0
  7568.   end
  7569.  
  7570. end # // Full Integration
  7571.  
  7572.   #--------------------------------------------------------------------------#
  7573.   # * overwrite-method :item_growth_effect
  7574.   #--------------------------------------------------------------------------#
  7575.   def item_growth_effect( user, item )
  7576.     if item.parameter_type > 0 and item.parameter_points != 0
  7577.       case item.parameter_type
  7578.       when 1  # Maximum HP
  7579.         @maxhp_plus += item.parameter_points
  7580.         @cached_maxhp = nil
  7581.       when 2  # Maximum MP
  7582.         @maxmp_plus += item.parameter_points
  7583.         @cached_maxmp = nil
  7584.       when 3  # Attack
  7585.         @atk_plus += item.parameter_points
  7586.         @cached_atk = nil
  7587.       when 4  # Defense
  7588.         @def_plus += item.parameter_points
  7589.         @cached_def = nil
  7590.       when 5  # Spirit
  7591.         @spi_plus += item.parameter_points
  7592.         @cached_spi = nil
  7593.       when 6  # Agility
  7594.         @agi_plus += item.parameter_points
  7595.         @cached_agi = nil
  7596.       end
  7597.     end
  7598.   end
  7599.  
  7600.   #--------------------------------------------------------------------------#
  7601.   # * alias-method :add_state
  7602.   #--------------------------------------------------------------------------#  
  7603.   alias :ygg_gb_add_state :add_state unless $@
  7604.   def add_state( *args, &block )
  7605.     old_states = self.states
  7606.     ygg_gb_add_state( *args, &block )
  7607.     clear_stat_cache() unless self.states == old_states
  7608.   end
  7609.  
  7610.   #--------------------------------------------------------------------------#
  7611.   # * alias-method :remove_state
  7612.   #--------------------------------------------------------------------------#  
  7613.   alias :ygg_gb_remove_state :remove_state unless $@
  7614.   def remove_state( *args, &block )
  7615.     old_states = self.states
  7616.     ygg_gb_remove_state( *args, &block )
  7617.     clear_stat_cache() unless self.states == old_states
  7618.   end
  7619.  
  7620.   #--------------------------------------------------------------------------#
  7621.   # * new-method :move_mod
  7622.   #--------------------------------------------------------------------------#  
  7623.   def move_mod()
  7624.     @cached_move ||= self.states.inject(0) { |r, s| r+s.move_mod }
  7625.     return @cached_move
  7626.   end
  7627.  
  7628.   #--------------------------------------------------------------------------#
  7629.   # * new-method :effect_tone
  7630.   #--------------------------------------------------------------------------#  
  7631.   def effect_tone()
  7632.     if @cached_tone.nil?()
  7633.       @cached_tone = ::Tone.new( 0, 0, 0, 0 )
  7634.       self.states.each { |s|
  7635.         if s.tone_effect ; @cached_tone = s.effect_tone ; break ; end }  
  7636.     end  
  7637.     return @cached_tone
  7638.   end
  7639.  
  7640.   #--------------------------------------------------------------------------#
  7641.   # * new-method :slip_frequency
  7642.   #--------------------------------------------------------------------------#  
  7643.   def slip_frequency()
  7644.     if @cached_slip_freq.nil?()
  7645.       r = 1 ; count = 1
  7646.       self.states.each { |s|
  7647.         if s.slip_freq != 0
  7648.           count += 1 ; r += s.slip_freq
  7649.         end  
  7650.       }  
  7651.       @cached_slip_freq = r / count
  7652.     end  
  7653.     return @cached_slip_freq
  7654.   end
  7655.  
  7656.   #--------------------------------------------------------------------------#
  7657.   # * new-method :update_states
  7658.   #--------------------------------------------------------------------------#  
  7659. if ::YGG::FULL_INTEGRATION
  7660.  
  7661.   def update_states()
  7662.     update_state_ticks()
  7663.     update_slip_damage()  if (Graphics.frame_count % slip_frequency) == 0
  7664.   end
  7665.  
  7666. else  
  7667.  
  7668.   def update_states()
  7669.     @ygg_slip_counter = [@ygg_slip_counter-1, 0].max
  7670.     if @ygg_slip_counter == 0
  7671.       remove_states_auto() ; update_slip_damage()
  7672.       @ygg_slip_counter = YGG::STATE_TURN_COUNTER        
  7673.     end
  7674.   end
  7675.  
  7676. end
  7677.  
  7678.   #--------------------------------------------------------------------------#
  7679.   # * new-method :update_slip_damage
  7680.   #--------------------------------------------------------------------------#
  7681.   def update_slip_damage()
  7682.     if slip_damage?()
  7683.       slip_damage_effect() ; self.ygg_engage.engage( 30 )
  7684.     end  
  7685.   end
  7686.  
  7687.   #--------------------------------------------------------------------------#
  7688.   # * new-method :skill_slot_valid?
  7689.   #--------------------------------------------------------------------------#
  7690.   def skill_slot_valid?( i )
  7691.     return i.between?( 0, @skill_slot_size-1 )
  7692.   end
  7693.  
  7694.   #--------------------------------------------------------------------------#
  7695.   # * new-method :item_slot_valid?
  7696.   #--------------------------------------------------------------------------#
  7697.   def item_slot_valid?( i )
  7698.     return i.between?( 0, @item_slot_size-1 )
  7699.   end
  7700.  
  7701.   #--------------------------------------------------------------------------#
  7702.   # * new-method :skill_slot
  7703.   #--------------------------------------------------------------------------#
  7704.   def skill_slot( i )
  7705.     return nil unless skill_slot_valid?( i )
  7706.     return $data_skills[(@skill_slots[i].obj_id)]
  7707.   end
  7708.  
  7709.   #--------------------------------------------------------------------------#
  7710.   # * new-method :skill_slots
  7711.   #--------------------------------------------------------------------------#
  7712.   def skill_slot_skills()
  7713.     result = []
  7714.     @skill_slot_size.times { |i| result << skill_slot( i ) } ; return result
  7715.   end
  7716.  
  7717.   #--------------------------------------------------------------------------#
  7718.   # * new-method :item_slot
  7719.   #--------------------------------------------------------------------------#
  7720.   def item_slot( i )
  7721.     return nil unless item_slot_valid?( i )
  7722.     return $data_items[(@item_slots[i].obj_id)]
  7723.   end
  7724.  
  7725.   #--------------------------------------------------------------------------#
  7726.   # * new-method :item_slot_items
  7727.   #--------------------------------------------------------------------------#
  7728.   def item_slot_items()
  7729.     result = []
  7730.     @item_slot_size.times { |i| result << item_slot( i ) } ; return result
  7731.   end
  7732.  
  7733.   #--------------------------------------------------------------------------#
  7734.   # * new-method :set_skill_slot
  7735.   #--------------------------------------------------------------------------#
  7736.   def set_skill_slot( i, sid )
  7737.     return unless skill_slot_valid?( i )
  7738.     @skill_slots[i] = get_skill_handle( sid )
  7739.   end
  7740.  
  7741.   #--------------------------------------------------------------------------#
  7742.   # * new-method :set_item_slot
  7743.   #--------------------------------------------------------------------------#
  7744.   def set_item_slot( i, iid )
  7745.     return unless item_slot_valid?( i )
  7746.     @item_slots[i] = get_item_handle( iid )
  7747.   end
  7748.  
  7749.   #--------------------------------------------------------------------------#
  7750.   # * new-method :clear_skill_slots
  7751.   #--------------------------------------------------------------------------#  
  7752.   def clear_skill_slots()
  7753.     @skill_slot_size.times { |i| set_skill_slot( i, 0 ) }
  7754.   end
  7755.  
  7756.   #--------------------------------------------------------------------------#
  7757.   # * new-method :clear_item_slots
  7758.   #--------------------------------------------------------------------------#  
  7759.   def clear_item_slots()  
  7760.     @item_slot_size.times { |i| set_item_slot( i, 0 ) }
  7761.   end
  7762.  
  7763.   #--------------------------------------------------------------------------#
  7764.   # * new-method :get_skill_handle
  7765.   #--------------------------------------------------------------------------#
  7766.   def get_skill_handle( sid )  
  7767.     @skill_handles[sid] ||= ::YGG::Handlers::BattleObj.new( sid, :skill )
  7768.     return @skill_handles[sid]
  7769.   end  
  7770.  
  7771.   #--------------------------------------------------------------------------#
  7772.   # * new-method :get_item_handle
  7773.   #--------------------------------------------------------------------------#
  7774.   def get_item_handle( iid )  
  7775.     @item_handles[iid] ||= ::YGG::Handlers::BattleObj.new( iid, :item )
  7776.     return @item_handles[iid]
  7777.   end  
  7778.  
  7779.   #--------------------------------------------------------------------------#
  7780.   # * new-method :update_obj_handles
  7781.   #--------------------------------------------------------------------------#
  7782.   def update_obj_handles()
  7783.     (@skill_slots+@item_slots).each { |hnd| hnd.update() }
  7784.   end
  7785.  
  7786.   #--------------------------------------------------------------------------#
  7787.   # * new-method :cooldown
  7788.   #--------------------------------------------------------------------------#
  7789.   attr_reader :cooldown
  7790.  
  7791.   #--------------------------------------------------------------------------#
  7792.   # * new-method :cooldown=
  7793.   #--------------------------------------------------------------------------#
  7794.   def cooldown=( cool )
  7795.     @cooldown = [cool, @cooldown_max].min
  7796.   end
  7797.  
  7798.   #--------------------------------------------------------------------------#
  7799.   # * new-method :cooldown_max
  7800.   #--------------------------------------------------------------------------#
  7801.   def cooldown_max() ; @cooldown_max ; end
  7802.  
  7803.   #--------------------------------------------------------------------------#
  7804.   # * new-method :cap_cooldown
  7805.   #--------------------------------------------------------------------------#
  7806.   def cap_cooldown()
  7807.     @cooldown = @cooldown_max
  7808.   end
  7809.  
  7810.   #--------------------------------------------------------------------------#
  7811.   # * new-method :update_cooldown
  7812.   #--------------------------------------------------------------------------#
  7813.   def update_cooldown()
  7814.     @cooldown = [@cooldown - 1, 0].max
  7815.   end
  7816.  
  7817.   #--------------------------------------------------------------------------#
  7818.   # * new-method :cooling_down?
  7819.   #--------------------------------------------------------------------------#
  7820.   def cooling_down?() ; return @cooldown > 0 ; end
  7821.  
  7822.   #--------------------------------------------------------------------------#
  7823.   # * new-method :ygg_can_attack?
  7824.   #--------------------------------------------------------------------------#
  7825.   def ygg_can_attack?() ;
  7826.     return false if cooling_down?()
  7827.     return true
  7828.   end
  7829.  
  7830.   #--------------------------------------------------------------------------#
  7831.   # * new-method :ygg_skill_can_use?
  7832.   #--------------------------------------------------------------------------#
  7833.   def ygg_skill_can_use?( obj )
  7834.     return false if cooling_down?()
  7835.     return false unless skill_can_use?( obj )
  7836.     return get_skill_handle( obj.id ).can_use?()
  7837.   end
  7838.  
  7839.   #--------------------------------------------------------------------------#
  7840.   # * new-method :ygg_item_can_use?
  7841.   #--------------------------------------------------------------------------#
  7842.   def ygg_item_can_use?( obj )
  7843.     return false if cooling_down?()
  7844.     return false unless item_can_use?( obj )
  7845.     return get_item_handle( obj.id ).can_use?()
  7846.   end
  7847.  
  7848.   #--------------------------------------------------------------------------#
  7849.   # * new-method :item_can_use?
  7850.   #--------------------------------------------------------------------------#
  7851.   def item_can_use?( obj )
  7852.     return $game_party.item_can_use?( obj )
  7853.   end unless method_defined? :item_can_use?
  7854.  
  7855.   #--------------------------------------------------------------------------#
  7856.   # * new-method :ygg_use_skill
  7857.   #--------------------------------------------------------------------------#
  7858.   def ygg_use_skill( obj )
  7859.     self.mp -= calc_mp_cost( obj )
  7860.   end
  7861.  
  7862.   #--------------------------------------------------------------------------#
  7863.   # * new-method :ygg_use_item
  7864.   #--------------------------------------------------------------------------#
  7865.   def ygg_use_item( obj )
  7866.     $game_party.consume_item( obj )
  7867.   end
  7868.  
  7869. end
  7870.  
  7871. #==============================================================================#
  7872. # ** Game Actor
  7873. #==============================================================================#
  7874. class Game_Actor < Game_Battler
  7875.  
  7876.   #--------------------------------------------------------------------------#
  7877.   # * alias-method :level_up
  7878.   #--------------------------------------------------------------------------#  
  7879.   alias :ygg_gb_level_up :level_up unless $@
  7880.   def level_up( *args, &block )
  7881.     clear_stat_cache()
  7882.     ygg_gb_level_up( *args, &block )
  7883.     clear_stat_cache()
  7884.   end
  7885.  
  7886.   #--------------------------------------------------------------------------#
  7887.   # * alias-method :level_down
  7888.   #--------------------------------------------------------------------------#  
  7889.   alias :ygg_gb_level_down :level_down unless $@
  7890.   def level_down( *args, &block )
  7891.     clear_stat_cache()
  7892.     ygg_gb_level_down( *args, &block )
  7893.     clear_stat_cache()
  7894.   end
  7895.  
  7896.   #--------------------------------------------------------------------------#
  7897.   # * alias-method :change_equip
  7898.   #--------------------------------------------------------------------------#  
  7899.   alias :ygg_gb_change_equip :change_equip unless $@
  7900.   def change_equip( *args, &block )
  7901.     clear_stat_cache()
  7902.     ygg_gb_change_equip( *args, &block )
  7903.     clear_stat_cache()
  7904.   end
  7905.  
  7906.   #--------------------------------------------------------------------------#
  7907.   # * ygg_target_range
  7908.   #--------------------------------------------------------------------------#
  7909.   def ygg_target_range()
  7910.     eq = weapons[0]
  7911.     eq.nil?() ? 0 : eq.ygg_target_range
  7912.   end  
  7913.    
  7914.   #--------------------------------------------------------------------------#
  7915.   # * new-method :drops_attraction?
  7916.   #--------------------------------------------------------------------------#
  7917.   def drops_attraction?() ; equips.compact.any? { |eq| eq.drops_attraction?() } ; end
  7918.    
  7919.   #--------------------------------------------------------------------------#
  7920.   # * new-method :equip_icon
  7921.   #--------------------------------------------------------------------------#
  7922.   def equip_icon( eq_id )
  7923.     if self.two_swords_style
  7924.       weps = weapons
  7925.       return weps[eq_id].nil?() ? 0 : weps[eq_id].icon_index
  7926.     else
  7927.       weps = [weapons[0], armors[0]]
  7928.       return weps[eq_id].nil?() ? 0 : weps[eq_id].icon_index
  7929.     end  
  7930.   end
  7931.  
  7932.   #--------------------------------------------------------------------------#
  7933.   # * new-method :equip_atk_act_name
  7934.   #--------------------------------------------------------------------------#    
  7935.   def equip_atk_act_name( eq_id )
  7936.     if self.two_swords_style
  7937.       weps = weapons
  7938.     else
  7939.       weps = [weapons[0], armors[0]]
  7940.     end
  7941.     return weps[eq_id].nil?() ? "" : weps[eq_id].atk_act_name
  7942.   end
  7943.  
  7944.   #--------------------------------------------------------------------------#
  7945.   # * new-method :equip_grd_act_name
  7946.   #--------------------------------------------------------------------------#    
  7947.   def equip_grd_act_name( eq_id )
  7948.     if self.two_swords_style
  7949.       weps = weapons
  7950.     else
  7951.       weps = [weapons[0], armors[0]]
  7952.     end
  7953.     return weps[eq_id].nil?() ? "" : weps[eq_id].grd_act_name
  7954.   end
  7955.  
  7956.   #--------------------------------------------------------------------------#
  7957.   # * alias-method :change_exp
  7958.   #--------------------------------------------------------------------------#    
  7959.   alias :ygg_gb_change_exp :change_exp unless $@
  7960.   def change_exp( *args, &block )
  7961.     ygg_gb_change_exp( *args, &block )
  7962.     @cached_level_exp = nil
  7963.     @cached_next_level_exp = nil
  7964.   end
  7965.  
  7966.   #--------------------------------------------------------------------------#
  7967.   # * new-method :level_exp
  7968.   #--------------------------------------------------------------------------#    
  7969.   def level_exp()
  7970.     @cached_level_exp ||= @exp - @exp_list[@level]
  7971.     return @cached_level_exp
  7972.   end
  7973.  
  7974.   #--------------------------------------------------------------------------#
  7975.   # * new-method :next_level_exp
  7976.   #--------------------------------------------------------------------------#  
  7977.   def next_level_exp()
  7978.     @cached_next_level_exp ||= @exp_list[@level+1] - @exp_list[@level]
  7979.     return @cached_next_level_exp
  7980.   end
  7981.  
  7982. end
  7983.  
  7984. #==============================================================================#
  7985. # ** Game Enemy
  7986. #==============================================================================#
  7987. class Game_Enemy < Game_Battler
  7988.  
  7989.   #--------------------------------------------------------------------------#
  7990.   # * alias-method :initialize
  7991.   #--------------------------------------------------------------------------#
  7992.   alias :ygg_gmen_initialize :initialize unless $@
  7993.   def initialize( *args, &block )
  7994.     ygg_gmen_initialize( *args, &block )
  7995.     @skill_slot_size = 0
  7996.     skillz = []
  7997.     enemy.actions.each { |act| if act.kind == 1 ; skillz << act.skill_id ; end }
  7998.     @skill_slot_size = skillz.size
  7999.     for i in 0...@skill_slot_size ; set_skill_slot( i, skillz[i] ) ; end
  8000.   end
  8001.  
  8002.   #--------------------------------------------------------------------------#
  8003.   # * new-method :calc_gold
  8004.   #--------------------------------------------------------------------------#
  8005.   def calc_gold()
  8006.     return YGG::Random.variation( gold, enemy.gold_variation )
  8007.   end
  8008.  
  8009.   #--------------------------------------------------------------------------#
  8010.   # * new-method :gain_exp
  8011.   #--------------------------------------------------------------------------#
  8012.   def gain_exp( exp, show ) ; end unless method_defined? :gain_exp
  8013.    
  8014.   #--------------------------------------------------------------------------#
  8015.   # * new-method :get_action_by_id
  8016.   #--------------------------------------------------------------------------#
  8017.   def get_action_by_id( id )
  8018.     return enemy.ygg_actions[id]
  8019.   end
  8020.  
  8021.   #--------------------------------------------------------------------------#
  8022.   # * new-method :all_drops
  8023.   #--------------------------------------------------------------------------#
  8024.   def all_drops()
  8025.     dro = []
  8026.     for di in self.enemy.drop_items.compact
  8027.       next if di.kind == 0 ; next if rand(di.denominator) != 0
  8028.       case di.kind
  8029.       when 1 ; dro.push($data_items[di.item_id])
  8030.       when 2 ; dro.push($data_weapons[di.weapon_id])
  8031.       when 3 ; dro.push($data_armors[di.armor_id])
  8032.       end
  8033.     end
  8034.     more_drops.compact.each { |mri|
  8035.       for num in 1..mri[2] ; dro.push(mri[0]) if rand(mri[1]).to_i == 0 ; end
  8036.     } if $imported["IEX_Rand_Drop"]
  8037.     return dro
  8038.   end  
  8039.  
  8040.   #--------------------------------------------------------------------------#
  8041.   # * new-method :atk_animation_id
  8042.   #--------------------------------------------------------------------------#
  8043.   def atk_animation_id ; return enemy.atk_animation_id ; end
  8044.  
  8045.   #--------------------------------------------------------------------------#
  8046.   # * new-method :atk_animation_id2
  8047.   #--------------------------------------------------------------------------#
  8048.   def atk_animation_id2 ; return enemy.atk_animation_id2 ; end
  8049.  
  8050. end
  8051.  
  8052. #==============================================================================#
  8053. # ** Game_Party
  8054. #==============================================================================#
  8055. class Game_Party
  8056.  
  8057.   #--------------------------------------------------------------------------#
  8058.   # * alias-method :on_player_walk
  8059.   #--------------------------------------------------------------------------#
  8060.   alias :ygg1x6_gmpt_on_player_walk :on_player_walk unless $@
  8061.   def on_player_walk( *args, &block )
  8062.     unless $game_system.yggdrasil_on?()
  8063.       ygg1x6_gmpt_on_player_walk( *args, &block )
  8064.     end  
  8065.   end
  8066.  
  8067.   #--------------------------------------------------------------------------#
  8068.   # * new-method :ygg_slip_damage
  8069.   #--------------------------------------------------------------------------#
  8070.   def ygg_slip_damage()
  8071.     ($game_party.members-[$game_player.ygg_battler]).each { |m| m.update_states() }
  8072.   end
  8073.  
  8074. end  
  8075.  
  8076. #==============================================================================#
  8077. # ** Game Map
  8078. #==============================================================================#
  8079. class Game_Map
  8080.  
  8081.   #--------------------------------------------------------------------------#
  8082.   # * new-method :get_map
  8083.   #--------------------------------------------------------------------------#  
  8084.   def get_map( map_id )
  8085.     return load_data( sprintf("Data/Map%03d.rvdata", map_id) )
  8086.   end unless method_defined? :get_map
  8087.  
  8088.   #--------------------------------------------------------------------------#
  8089.   # * alias-method :events_xy
  8090.   #--------------------------------------------------------------------------#
  8091.   alias :ygg_gmm_events_xy :events_xy unless $@
  8092.   def events_xy( x, y )
  8093.     return ygg_gmm_events_xy( x, y ) + $game_yggdrasil.roam_xy( x, y )
  8094.   end
  8095.  
  8096.   #--------------------------------------------------------------------------#
  8097.   # * alias-method :setup
  8098.   #--------------------------------------------------------------------------#
  8099.   alias :ygg_gmm_setup :setup unless $@
  8100.   def setup( *args, &block )
  8101.     $game_player.ygg_unregister()
  8102.     ygg_gmm_setup( *args, &block )
  8103.     ygg_setup()
  8104.     $game_player.ygg_register()
  8105.   end
  8106.  
  8107.   #--------------------------------------------------------------------------#
  8108.   # * new-method :ygg_setup
  8109.   #--------------------------------------------------------------------------#
  8110.   def ygg_setup()
  8111.     $game_yggdrasil.setup_map( self.map_id )
  8112.   end
  8113.  
  8114.   #--------------------------------------------------------------------------#
  8115.   # * new-method :setup_itemmap
  8116.   #--------------------------------------------------------------------------#
  8117.   def setup_itemmap()
  8118.     $game_yggdrasil.setup_itemmap()  
  8119.   end
  8120.  
  8121.   #--------------------------------------------------------------------------#
  8122.   # * new-method :create_drops
  8123.   #--------------------------------------------------------------------------#
  8124.   def create_drops( x, y, dropee )
  8125.     $game_yggdrasil.create_drops( x, y, dropee )
  8126.   end  
  8127.  
  8128.   #--------------------------------------------------------------------------#
  8129.   # * new-method :place_drops
  8130.   #--------------------------------------------------------------------------#
  8131.   def place_drops( x, y, item_set, gold = nil )
  8132.     return $game_yggdrasil.place_drops( x, y, item_set, gold )
  8133.   end
  8134.  
  8135.   #--------------------------------------------------------------------------#
  8136.   # * new-method :items_map
  8137.   #--------------------------------------------------------------------------#
  8138.   def items_map() ; return $items_map ; end
  8139.  
  8140.   #--------------------------------------------------------------------------#
  8141.   # * alias-method :update
  8142.   #--------------------------------------------------------------------------#
  8143.   #alias :ygg_gm_update :update unless $@
  8144.   #def update( *args, &block )
  8145.   #  ygg_gm_update( *args, &block )
  8146.   #  update_drops()
  8147.   #end
  8148.  
  8149.   #--------------------------------------------------------------------------#
  8150.   # * new-method :active_drops
  8151.   #--------------------------------------------------------------------------#
  8152.   def active_drops() ; return $game_yggdrasil.active_drops ; end
  8153.    
  8154.   #--------------------------------------------------------------------------#
  8155.   # * new-method :active_ranges
  8156.   #--------------------------------------------------------------------------#  
  8157.   def active_ranges() ; return $game_yggdrasil.active_ranges ; end
  8158.    
  8159.   #--------------------------------------------------------------------------#
  8160.   # * new-method :projectiles
  8161.   #--------------------------------------------------------------------------#  
  8162.   def projectiles() ; return $game_yggdrasil.projectiles ; end
  8163.    
  8164.   #--------------------------------------------------------------------------#
  8165.   # * new-method :drops_xy
  8166.   #--------------------------------------------------------------------------#  
  8167.   def drops_xy( x, y )
  8168.     return $game_yggdrasil.drops_xy( x, y )
  8169.   end
  8170.  
  8171. end
  8172.  
  8173. #==============================================================================#
  8174. # ** Game Event
  8175. #==============================================================================#
  8176. class Game_Event < Game_Character
  8177.  
  8178.   #--------------------------------------------------------------------------#
  8179.   # * alias-method :initialize
  8180.   #--------------------------------------------------------------------------#
  8181.   alias :ygg_ge_initialize :initialize unless $@
  8182.   def initialize( *args, &block )
  8183.     ygg_ge_initialize( *args, &block )
  8184.     @ai_operated        = true
  8185.   end
  8186.  
  8187.   #--------------------------------------------------------------------------#
  8188.   # * alias-method :erase
  8189.   #--------------------------------------------------------------------------#
  8190.   alias :ygg_gme_erase :erase unless $@
  8191.   def erase( *args, &block )
  8192.     terminate_ai_engine()
  8193.     ygg_unregister() ; ygg_gme_erase( *args, &block )
  8194.   end
  8195.  
  8196.   #--------------------------------------------------------------------------#
  8197.   # * alias-method :setup
  8198.   #--------------------------------------------------------------------------#
  8199.   alias :ygg_gme_setup :setup unless $@
  8200.   def setup( *args, &block )
  8201.     @dont_scan_events = YGG::DONT_SCAN_EVENTS
  8202.     @ygg_cache_complete = false
  8203.     ygg_gme_setup( *args, &block )
  8204.     ygg_event_cache()
  8205.   end
  8206.  
  8207.   #--------------------------------------------------------------------------#
  8208.   # * new-method :pop_enabled?
  8209.   #--------------------------------------------------------------------------#  
  8210.   def pop_enabled?()
  8211.     return @ygg_pop_enabled
  8212.   end
  8213.  
  8214.   #--------------------------------------------------------------------------#
  8215.   # * new-method :ygg_event_cache
  8216.   #--------------------------------------------------------------------------#
  8217.   def ygg_event_cache()
  8218.     ygg_event_cache_start()
  8219.     return if @list.nil?()
  8220.     for i in 0..@list.size
  8221.       next if @list[i].nil?()
  8222.       if [108, 408].include?( @list[i].code )
  8223.         @list[i].parameters.to_s.split(/[\r\n]+/).each { |line|
  8224.           ygg_event_cache_check( line )
  8225.         }
  8226.       end
  8227.     end
  8228.     ygg_event_cache_end()
  8229.   end
  8230.  
  8231.   #--------------------------------------------------------------------------#
  8232.   # * new-method :ygg_event_cache_start
  8233.   #--------------------------------------------------------------------------#
  8234.   def ygg_event_cache_start()
  8235.     @ygg_cache_complete     = false
  8236.     @ygg_battler            = nil
  8237.     @ygg_ally               = false
  8238.     @ygg_enemy              = false
  8239.     @ygg_boss               = false
  8240.     @ygg_invincible         = false
  8241.     @ygg_pop_enabled        = true
  8242.     @hp_visible             = true
  8243.     @mp_visible             = true
  8244.     @ygg_ondeath            = []
  8245.    
  8246.     @ygg_fading_death       = true  # // Depreceated
  8247.     @ygg_instant_death      = false # // Depreceated
  8248.     @ygg_dead_switches      = []    # // Depreceated
  8249.     @ygg_dead_self_switches = []    # // Depreceated
  8250.     @ygg_dieing             = false # // Depreceated
  8251.     @die_count_down         = 255   # // Depreceated
  8252.     @ygg_death_anim         = 0     # // Depreceated
  8253.    
  8254.     setup_ai_engine( YGG::Handlers::AIEngines::Default, {} )
  8255.    
  8256.     @__aiengine, @__aieng_setup_data = nil, {}
  8257.     @__read_aiengine = 0
  8258.    
  8259.     @__read_ondeath = 0
  8260.   end
  8261.  
  8262.   #--------------------------------------------------------------------------#
  8263.   # * new-method :ygg_event_cache_check
  8264.   #--------------------------------------------------------------------------#
  8265.   def ygg_event_cache_check( line )  
  8266.     case line
  8267.     when YGG::REGEXP::EVENT::SELF_SWITCH
  8268.       @ygg_dead_self_switches.push($1.to_s.upcase)
  8269.     when YGG::REGEXP::EVENT::SWITCH
  8270.       @ygg_dead_switches.push([$1.to_i, $2.to_s])
  8271.     when YGG::REGEXP::EVENT::INVINCIBLE
  8272.       @ygg_invincible = true
  8273.     when YGG::REGEXP::EVENT::NO_FADE_DEATH  
  8274.       @ygg_fading_death = false
  8275.     when YGG::REGEXP::EVENT::INSTANT_DEATH
  8276.       @ygg_instant_death = true
  8277.     when YGG::REGEXP::EVENT::ABS_ALLY
  8278.       next if $game_actors[$1.to_i].nil?()
  8279.       setup_ygg_battler( $game_actors[$1.to_i], :actor )
  8280.     when YGG::REGEXP::EVENT::ABS_ENEMY
  8281.       next if $data_enemies[$1.to_i].nil?()
  8282.       setup_ygg_battler( Game_Enemy.new(0, $1.to_i), :enemy )  
  8283.     when YGG::REGEXP::EVENT::ABS_SET_AS_ALLY
  8284.       @ygg_enemy = !@ygg_ally = true
  8285.     when YGG::REGEXP::EVENT::ABS_SET_AS_ENEMY  
  8286.       @ygg_ally = !@ygg_enemy = true
  8287.     when YGG::REGEXP::EVENT::ABS_BOSS
  8288.       @ygg_boss = true
  8289.     when YGG::REGEXP::EVENT::DEATH_ANIM  
  8290.       @ygg_death_anim = $1.to_i
  8291.     when YGG::REGEXP::EVENT::AI_ENGINE1  
  8292.       @__aiengine = ::YGG::AI_ENGINES[$1.to_s.downcase]
  8293.       @__read_aiengine = 1
  8294.     when YGG::REGEXP::EVENT::AI_ENGINE2    
  8295.       @__read_aiengine = 0
  8296.     when YGG::REGEXP::EVENT::ENABLE_POP
  8297.       @ygg_pop_enabled = true
  8298.     when YGG::REGEXP::EVENT::DISABLE_POP
  8299.       @ygg_pop_enabled = false
  8300.     when YGG::REGEXP::EVENT::SHOW_HP_BAR
  8301.       @hp_visible = true
  8302.     when YGG::REGEXP::EVENT::HIDE_HP_BAR    
  8303.       @hp_visible = false
  8304.     when YGG::REGEXP::EVENT::SHOW_MP_BAR    
  8305.       @mp_visible = true
  8306.     when YGG::REGEXP::EVENT::HIDE_MP_BAR    
  8307.       @mp_visible = false
  8308.     when YGG::REGEXP::EVENT::ONDEATH1
  8309.       @__read_ondeath = 1
  8310.     when YGG::REGEXP::EVENT::ONDEATH2  
  8311.       @__read_ondeath = 0
  8312.     else
  8313.       if @__read_aiengine == 1
  8314.         case line
  8315.         when /(.*)\=[ ](.*)/i
  8316.           @__aieng_setup_data[$1] = $2
  8317.         end  
  8318.       elsif @__read_ondeath == 1
  8319.         @ygg_ondeath << ::YGG.get_action_from_line( line )
  8320.       end  
  8321.     end
  8322.   end
  8323.  
  8324.   #--------------------------------------------------------------------------#
  8325.   # * new-method :ygg_event_cache_end
  8326.   #--------------------------------------------------------------------------#
  8327.   def ygg_event_cache_end()
  8328.     setup_ai_engine( @__aiengine, @__aieng_setup_data ) unless @__aiengine.nil?()
  8329.     @__read_aiengine, @__aiengine, @__aieng_setup_data = 0, nil, {}
  8330.     @ygg_cache_complete = true
  8331.     #setup_target_group()
  8332.   end
  8333.  
  8334.   #--------------------------------------------------------------------------#
  8335.   # * new-method :setup_ygg_battler
  8336.   #--------------------------------------------------------------------------#  
  8337.   def setup_ygg_battler( battler, type=:actor )
  8338.     @ygg_battler = battler
  8339.     case type
  8340.     when :actor ; @ygg_enemy = !@ygg_ally = true
  8341.     when :enemy ; @ygg_ally  = !@ygg_enemy = true
  8342.     end  
  8343.   end
  8344.  
  8345.   #--------------------------------------------------------------------------#
  8346.   # * new-method :terminate_ygg_battler
  8347.   #--------------------------------------------------------------------------#
  8348.   def terminate_ygg_battler()
  8349.     @ygg_battler = nil
  8350.   end
  8351.  
  8352.   #--------------------------------------------------------------------------#
  8353.   # * new-method :ygg_attacker
  8354.   #--------------------------------------------------------------------------#
  8355.   def ygg_attacker() ; @ygg_battler || super ; end
  8356.  
  8357.   #--------------------------------------------------------------------------#
  8358.   # * new-method :ygg_ally?
  8359.   #--------------------------------------------------------------------------#
  8360.   def ygg_ally?() ; return @ygg_ally ; end
  8361.  
  8362.   #--------------------------------------------------------------------------#
  8363.   # * new-method :Is an enemy?
  8364.   #--------------------------------------------------------------------------#
  8365.   def ygg_enemy? ; return @ygg_enemy ; end
  8366.  
  8367.   #--------------------------------------------------------------------------#
  8368.   # * new-method :ygg_boss?
  8369.   #--------------------------------------------------------------------------#
  8370.   def ygg_boss? ; return @ygg_boss ; end
  8371.  
  8372.   #--------------------------------------------------------------------------#
  8373.   # * new-method :ygg_death
  8374.   #--------------------------------------------------------------------------#
  8375.   def ygg_death()
  8376.     ygg_enemy?() ? Sound.play_enemy_collapse() : Sound.play_actor_collapse()
  8377.     create_drops()
  8378.     @ygg_battler = nil
  8379.     @ygg_boss    = false
  8380.     @ygg_dieing  = true
  8381.   end
  8382.  
  8383.   #--------------------------------------------------------------------------#
  8384.   # * new-method :create_drops
  8385.   #--------------------------------------------------------------------------#
  8386.   def create_drops()
  8387.     $game_map.create_drops( self.x, self.y, ygg_battler.create_drops_object() )
  8388.   end
  8389.  
  8390.   #--------------------------------------------------------------------------#
  8391.   # * alias-method :update
  8392.   #--------------------------------------------------------------------------#
  8393.   alias :ygg_gme_update :update unless $@
  8394.   def update()
  8395.     ygg_gme_update()
  8396.     ygg_abs_update() if $game_system.yggdrasil_on?()
  8397.   end
  8398.  
  8399.   #--------------------------------------------------------------------------#
  8400.   # * new-method :ygg_abs_update
  8401.   #--------------------------------------------------------------------------#
  8402.   def ygg_abs_update()
  8403.     super()
  8404.     unless self.ygg_battler.nil?()
  8405.       update_battler()
  8406.       if ygg_attacker.dead? ; ygg_death()
  8407.       else                  ; ygg_update_ai()
  8408.       end
  8409.     end
  8410.     if @ygg_dieing
  8411.       if @ygg_instant_death  
  8412.         @die_count_down = 0
  8413.       elsif @ygg_fading_death
  8414.         @opacity = @die_count_down -= 255 / YGG::DIE_WAIT_TIME
  8415.       else
  8416.         @die_count_down -= 255 / YGG::DIE_WAIT_TIME
  8417.       end  
  8418.       if @die_count_down <= 0
  8419.         @ygg_dieing = false
  8420.         ygg_perform_death()
  8421.       end  
  8422.     end
  8423.   end
  8424.  
  8425.   #--------------------------------------------------------------------------#
  8426.   # * new-method :ygg_perform_death
  8427.   #--------------------------------------------------------------------------#
  8428.   # Hp == 0 .'. Dead. If no switch is present the event is simply erased
  8429.   # If IRME is present, and the event is generated the irme_die is called
  8430.   # Therefore the event is removed.
  8431.   #--------------------------------------------------------------------------#
  8432.   if $imported["IRME_Event_Generator"]
  8433.     def ygg_perform_death()
  8434.       ygg_death_operations()
  8435.       if @ygg_dead_self_switches.empty? and @ygg_dead_switches.empty? # If no switches are present do normal erasing
  8436.         unless @generator_id.nil?()
  8437.           self.irme_die()
  8438.         else
  8439.           self.erase
  8440.         end  
  8441.       end
  8442.     end  
  8443.   else
  8444.     def ygg_perform_death()
  8445.       ygg_death_operations()
  8446.       if @ygg_dead_self_switches.empty? and @ygg_dead_switches.empty? # If no switches are present do normal erasing
  8447.         self.erase()
  8448.       end
  8449.     end
  8450.   end
  8451.  
  8452.   #--------------------------------------------------------------------------#
  8453.   # * new-method :ygg_death_operations
  8454.   #--------------------------------------------------------------------------#
  8455.   def ygg_death_operations()
  8456.     @ygg_anims.push(@ygg_death_anim) if @ygg_death_anim > 0
  8457.     if !@ygg_dead_self_switches.empty?() or !@ygg_dead_switches.empty?()
  8458.       @ygg_dead_self_switches.compact.each { |selswit|
  8459.         $game_system.control_self_switch( $game_map.map_id, @id, selswit, true )
  8460.       }
  8461.       @ygg_dead_switches.compact.each { |swit|
  8462.         swit_id = swit[0]
  8463.         case swit[1].to_s
  8464.         when /(?:TRUE|ON)/i
  8465.           $game_switches[swit_id] = true
  8466.           $game_map.need_refresh = true
  8467.         when /(?:FALSE|OFF)/i  
  8468.           $game_switches[swit_id] = false
  8469.           $game_map.need_refresh = true
  8470.         end          
  8471.       }
  8472.       $game_map.need_refresh = true
  8473.     end
  8474.   end
  8475.  
  8476. end
  8477.  
  8478. #==============================================================================#
  8479. # ** Game Player
  8480. #==============================================================================#
  8481. class Game_Player < Game_Character
  8482.  
  8483.   #--------------------------------------------------------------------------#
  8484.   # * Public Instance Variable(s)
  8485.   #--------------------------------------------------------------------------#
  8486.   attr_accessor :ygg_gained_items
  8487.  
  8488.   #--------------------------------------------------------------------------#
  8489.   # * alias-method :initialize
  8490.   #--------------------------------------------------------------------------#
  8491.   alias :ygg_gmp_initialize :initialize unless $@
  8492.   def initialize( *args, &block )
  8493.     ygg_gmp_initialize( *args, &block )
  8494.     @ygg_targeting_mode = false
  8495.     @ygg_remote_sprite  = nil
  8496.     @ygg_old_actor      = nil
  8497.     @ygg_old_target_pos = [0, 0]
  8498.     @ygg_gained_items   = []
  8499.   end
  8500.    
  8501.   #--------------------------------------------------------------------------#
  8502.   # * alias-method :update
  8503.   #--------------------------------------------------------------------------#
  8504.   alias :ygg_gmp_update :update unless $@
  8505.   def update( *args, &block )
  8506.     abs_on = $game_system.yggdrasil_on?()  
  8507.     if abs_on    
  8508.       ygg_abs_update()
  8509.       ygg_update_pickup()
  8510.     end  
  8511.     ygg_gmp_update( *args, &block )
  8512.     if abs_on
  8513.       @ygg_old_actor = $game_party.members[0]
  8514.     end  
  8515.   end
  8516.  
  8517.   #--------------------------------------------------------------------------#
  8518.   # * new-method :ygg_update_pickup
  8519.   #--------------------------------------------------------------------------#
  8520.   def ygg_update_pickup()
  8521.     $game_map.drops_xy( self.x, self.y ).compact.each { |dr|
  8522.       self.ygg_gain_drop( dr.drop ) ; dr.drop_remove() }
  8523.   end
  8524.  
  8525.   #--------------------------------------------------------------------------#
  8526.   # * new-method :gain_drop
  8527.   #--------------------------------------------------------------------------#
  8528.   def ygg_gain_drop( drop )
  8529.     return if drop.nil?()
  8530.     drop.pickup_sfx.play() unless drop.pickup_sfx.nil?()
  8531.     @ygg_gained_items << drop
  8532.     @ygg_gained_items.shift() while @ygg_gained_items.size > 20 # // remove really old drops to save memory
  8533.     if drop.is_a?( YGG::Containers::GoldItem )
  8534.       $game_party.gain_gold( drop.gold_amount )
  8535.     else
  8536.       $game_party.gain_item( drop, 1 )
  8537.     end  
  8538.   end
  8539.  
  8540.   #--------------------------------------------------------------------------#
  8541.   # * new-method :ygg_abs_update
  8542.   #--------------------------------------------------------------------------#
  8543.   def ygg_abs_update()
  8544.     super()
  8545.     unless self.ygg_battler.nil?()
  8546.       update_battler() ; ygg_attack_input()
  8547.     end  
  8548.   end
  8549.  
  8550.   #--------------------------------------------------------------------------#
  8551.   # * new-method :ygg_attacker
  8552.   #--------------------------------------------------------------------------#
  8553.   def ygg_attacker() ; return $game_party.members[0] ; end
  8554.  
  8555.   #--------------------------------------------------------------------------#
  8556.   # * new-method :ygg_ally?, ygg_enemy?, ygg_wild?, ygg_boss?
  8557.   #--------------------------------------------------------------------------#
  8558.   def ygg_ally?  ; return true  ; end
  8559.   def ygg_enemy? ; return false ; end
  8560.   def ygg_wild?  ; return false ; end
  8561.   def ygg_boss?  ; return false ; end
  8562.    
  8563.   #--------------------------------------------------------------------------#
  8564.   # * new-method :ygg_can_move?
  8565.   #--------------------------------------------------------------------------#
  8566.   def ygg_can_move?() ; super() ; end
  8567.  
  8568.   #--------------------------------------------------------------------------#
  8569.   # * overwrite-method :use_equipment
  8570.   #--------------------------------------------------------------------------#
  8571.   def use_equipment ; return true ; end
  8572.      
  8573. end
  8574.  
  8575. #==============================================================================#
  8576. # ** YGG::Drop_Character
  8577. #==============================================================================#
  8578. class YGG::Drop_Character < YGG::Handlers::Screen
  8579.  
  8580.   #--------------------------------------------------------------------------#
  8581.   # * Public Instance Variable(s)
  8582.   #--------------------------------------------------------------------------#  
  8583.   attr_accessor :icon_index
  8584.   attr_accessor :ready_to_remove
  8585.   attr_accessor :icon_time_out
  8586.   attr_accessor :opacity
  8587.   attr_accessor :visible
  8588.  
  8589.   #--------------------------------------------------------------------------#
  8590.   # * super-method :initialize
  8591.   #--------------------------------------------------------------------------#
  8592.   def initialize( object, time = 640 )
  8593.     super( 0, 0, 0 )
  8594.     @drop_object     = object
  8595.     @icon_index      = @drop_object.icon_index
  8596.     @icon_time_out   = time
  8597.     @icon_fade_thres = YGG::DROP_FADE_THRESHOLD
  8598.     @opacity         = 255
  8599.     @visible         = true
  8600.   end
  8601.  
  8602.   #--------------------------------------------------------------------------#
  8603.   # * new-method :pos?
  8604.   #--------------------------------------------------------------------------#
  8605.   def pos?( tx, ty ) ; return (self.x == tx && self.y == ty) ; end
  8606.    
  8607.   #--------------------------------------------------------------------------#
  8608.   # * new-method :update
  8609.   #--------------------------------------------------------------------------#
  8610.   def update()
  8611.     @icon_time_out   = [@icon_time_out-1, 0].max
  8612.     @ready_to_remove = true if @icon_time_out <= 0
  8613.     @opacity -= 255 / 60 if @icon_time_out <= @icon_fade_thres
  8614.     if $game_player.drop_attraction?()
  8615.       if $game_player.x > self.x    ; self.x = [self.x-0.1, $game_player.x].min
  8616.       elsif $game_player.x < self.x ; self.x = [self.x-0.1, $game_player.x].max
  8617.       end  
  8618.       if $game_player.y > self.y    ; self.y = [self.y-0.1, $game_player.y].min
  8619.       elsif $game_player.y < self.y ; self.y = [self.y-0.1, $game_player.y].max
  8620.       end
  8621.       @real_x = self.x*256 ; @real_y = self.y*256
  8622.     end  
  8623.   end
  8624.  
  8625.   #--------------------------------------------------------------------------#
  8626.   # * super-method :drop_remove
  8627.   #--------------------------------------------------------------------------#
  8628.   def drop_remove()
  8629.     @drop_object = nil
  8630.     @icon_index = 0
  8631.     @icon_time_out = 0
  8632.   end
  8633.  
  8634.   #--------------------------------------------------------------------------#
  8635.   # * new-method :timeout?
  8636.   #--------------------------------------------------------------------------#
  8637.   def timeout? ; return @icon_time_out == 0 end
  8638.    
  8639.   #--------------------------------------------------------------------------#
  8640.   # * new-method :drop
  8641.   #--------------------------------------------------------------------------#
  8642.   def drop ; return @drop_object end
  8643.    
  8644. end
  8645.  
  8646. #==============================================================================#
  8647. # ** Scene_Title
  8648. #==============================================================================#  
  8649. class Scene_Title < Scene_Base
  8650.  
  8651.   #--------------------------------------------------------------------------#
  8652.   # * alias-method :load_database
  8653.   #--------------------------------------------------------------------------#  
  8654.   alias :ygg_sct_load_database :load_database unless $@
  8655.   def load_database()
  8656.     ygg_sct_load_database()
  8657.     load_ygg_database()
  8658.   end
  8659.  
  8660.   #--------------------------------------------------------------------------#
  8661.   # * alias-method :load_bt_database
  8662.   #--------------------------------------------------------------------------#  
  8663.   alias :ygg_sct_load_bt_database :load_bt_database unless $@
  8664.   def load_bt_database()
  8665.     ygg_sct_load_bt_database()
  8666.     load_ygg_database()
  8667.   end
  8668.  
  8669.   #--------------------------------------------------------------------------#
  8670.   # * alias-method :load_ygg_database
  8671.   #--------------------------------------------------------------------------#  
  8672.   def load_ygg_database()
  8673.     data = []
  8674.     data += $data_items
  8675.     data += $data_skills
  8676.     data += $data_enemies
  8677.     data += $data_weapons
  8678.     data += $data_armors
  8679.     data += $data_states
  8680.     data.compact.each { |obj| obj.yggdrasil_1x6_cache() }
  8681.   end
  8682.  
  8683.   #--------------------------------------------------------------------------#
  8684.   # * alias-method :create_game_objects
  8685.   #--------------------------------------------------------------------------#
  8686.   alias :ygg_sct_ptxt_create_game_objects :create_game_objects unless $@
  8687.   def create_game_objects()
  8688.     $game_yggdrasil = YGG::System.new()
  8689.     ygg_sct_ptxt_create_game_objects()
  8690.   end
  8691.  
  8692. end
  8693.  
  8694. #==============================================================================#
  8695. # ** Scene_Map
  8696. #==============================================================================#
  8697. class Scene_Map < Scene_Base
  8698.  
  8699.   #--------------------------------------------------------------------------#
  8700.   # * Public Instance Variable(s)
  8701.   #--------------------------------------------------------------------------#  
  8702.   attr_accessor :spriteset
  8703.        
  8704.   #--------------------------------------------------------------------------#
  8705.   # * new-method :push_ygg_anim
  8706.   #--------------------------------------------------------------------------#
  8707.   def push_ygg_anim( anim_id, x, y, targets=[], looped = false )
  8708.     @spriteset.push_anim( anim_id, x, y, targets, looped ) unless @spriteset.nil?()
  8709.   end  
  8710.  
  8711.   #--------------------------------------------------------------------------#
  8712.   # * alias-method :update
  8713.   #--------------------------------------------------------------------------#
  8714.   alias :ygg_scm_update :update unless $@
  8715.   def update( *args, &block )
  8716.     ygg_scm_update( *args, &block )
  8717.     $game_yggdrasil.update()
  8718.     $game_party.ygg_slip_damage() if $game_yggdrasil.on?()
  8719.     $game_yggdrasil.gameover_process() if $game_party.all_dead?() if $game_system.gameover_alldead?()
  8720.   end
  8721.  
  8722. if ::YGG::USE_DROPS_WINDOW
  8723.  
  8724.   #--------------------------------------------------------------------------#
  8725.   # * alias-method :start
  8726.   #--------------------------------------------------------------------------#  
  8727.   alias :ygg_drop_win_start :start unless $@
  8728.   def start( *args, &block )
  8729.     ygg_drop_win_start( *args, &block )
  8730.     create_drops_window()
  8731.   end
  8732.  
  8733.   #--------------------------------------------------------------------------#
  8734.   # * new-method :create_drops_window
  8735.   #--------------------------------------------------------------------------#
  8736.   def create_drops_window()
  8737.     size = YGG::DROPS_WINDOW_SIZE
  8738.     @drops_logging = YGG::Drops_Window.new(
  8739.       { :x => size[0], :y => size[1], :z => size[2], :width => size[3] }, nil )  
  8740.     @drops_logging.visible = $game_yggdrasil.drops_window_visible?()
  8741.   end
  8742.  
  8743.   #--------------------------------------------------------------------------#
  8744.   # * alias-method :terminate
  8745.   #--------------------------------------------------------------------------#
  8746.   alias :ygg_drop_win_terminate :terminate unless $@
  8747.   def terminate( *args, &block )
  8748.     @drops_logging.dispose() unless @drops_logging.nil?() ; @drops_logging = nil
  8749.     ygg_drop_win_terminate( *args, &block )
  8750.   end
  8751.  
  8752.   #--------------------------------------------------------------------------#
  8753.   # * alias-method :update
  8754.   #--------------------------------------------------------------------------#  
  8755.   alias :ygg_drop_win_update :update unless $@
  8756.   def update( *args, &block )
  8757.     unless @drops_logging.nil?()
  8758.       @drops_logging.visible = $game_yggdrasil.drops_window_visible?()
  8759.       @drops_logging.update()
  8760.     end
  8761.     ygg_drop_win_update( *args, &block )
  8762.   end
  8763.  
  8764. end # // Drops Window
  8765.  
  8766. end
  8767.  
  8768. # // (YGG_ShiftSystem)
  8769. if YGG::USE_SHIFT_SYSTEM
  8770. #==============================================================================#
  8771. # ** Game_Party
  8772. #==============================================================================#
  8773. class Game_Party < Game_Unit
  8774.  
  8775.   #--------------------------------------------------------------------------#
  8776.   # * Public Instance Variables
  8777.   #--------------------------------------------------------------------------#
  8778.   attr_accessor :actors
  8779.  
  8780. end
  8781.  
  8782. #==============================================================================#
  8783. # ** YGG::Handlers::Shift
  8784. #==============================================================================#
  8785. class YGG::Handlers::Shift
  8786.  
  8787.   #--------------------------------------------------------------------------#
  8788.   # * Public Instance Variables
  8789.   #--------------------------------------------------------------------------#  
  8790.   attr_accessor :shift_time
  8791.   attr_accessor :shift_cap
  8792.  
  8793.   #--------------------------------------------------------------------------#
  8794.   # * new-method :initialize
  8795.   #--------------------------------------------------------------------------#
  8796.   def initialize()
  8797.     @shift_time = 0
  8798.     @shift_cap  = Graphics.frame_rate*5
  8799.   end
  8800.  
  8801.   #--------------------------------------------------------------------------#
  8802.   # * new-method :reset_shift_time
  8803.   #--------------------------------------------------------------------------#
  8804.   def reset_shift_time() ; @shift_time = @shift_cap ; end
  8805.  
  8806.   #--------------------------------------------------------------------------#
  8807.   # * new-method :time
  8808.   #--------------------------------------------------------------------------#  
  8809.   def time() ; return @shift_time ; end
  8810.  
  8811.   #--------------------------------------------------------------------------#
  8812.   # * new-method :cap
  8813.   #--------------------------------------------------------------------------#  
  8814.   def cap() ; return @shift_cap ; end  
  8815.    
  8816.   #--------------------------------------------------------------------------#
  8817.   # * new-method :can_shift?
  8818.   #--------------------------------------------------------------------------#  
  8819.   def can_shift?() ; return @shift_time == 0 ; end
  8820.  
  8821.   #--------------------------------------------------------------------------#
  8822.   # * new-method :swap_actors
  8823.   #--------------------------------------------------------------------------#
  8824.   def swap_actors( target_index, swap_index )
  8825.     target_id = $game_party.actors[target_index]
  8826.     swap_id = $game_party.actors[swap_index]
  8827.   end
  8828.  
  8829.   #--------------------------------------------------------------------------#
  8830.   # * new-method :rotate_actors
  8831.   #--------------------------------------------------------------------------#
  8832.   def rotate_actors( n=1 )
  8833.     $game_party.actors.rotate!( n )
  8834.   end
  8835.  
  8836.   #--------------------------------------------------------------------------#
  8837.   # * new-method :perform_shift
  8838.   #--------------------------------------------------------------------------#
  8839.   def perform_shift( n )
  8840.     rotate_actors( n ) ;
  8841.     $game_player.ygg_anims << 81
  8842.     $game_player.thrust_backward()
  8843.     $game_player.refresh()
  8844.     reset_shift_time()
  8845.   end
  8846.  
  8847.   #--------------------------------------------------------------------------#
  8848.   # * new-method :update
  8849.   #--------------------------------------------------------------------------#
  8850.   def update()
  8851.     @shift_time = [@shift_time - 1, 0].max
  8852.     update_shift() if can_shift?
  8853.     perform_shift( 1 ) while $game_party.members[0].dead?() unless $game_party.all_dead?()
  8854.   end
  8855.  
  8856.   #--------------------------------------------------------------------------#
  8857.   # * new-method :update_shift
  8858.   #--------------------------------------------------------------------------#
  8859.   def update_shift()
  8860.     if Input.trigger?( Input::R )
  8861.       perform_shift( 1 )
  8862.     elsif Input.trigger?( Input::L )  
  8863.       perform_shift( -1 )
  8864.     end  
  8865.   end
  8866.  
  8867. end
  8868.  
  8869. #==============================================================================#
  8870. # ** YGG::System
  8871. #==============================================================================#
  8872. class YGG::System
  8873.  
  8874.   #--------------------------------------------------------------------------#
  8875.   # * Public Instance Variables
  8876.   #--------------------------------------------------------------------------#  
  8877.   attr_accessor :shift_system
  8878.  
  8879.   #--------------------------------------------------------------------------#
  8880.   # * alias-method :initialize
  8881.   #--------------------------------------------------------------------------#  
  8882.   alias :ygg_shift_sys_initialize :initialize unless $@
  8883.   def initialize( *args, &block )
  8884.     ygg_shift_sys_initialize( *args, &block )
  8885.     @shift_system = ::YGG::Handlers::Shift.new()
  8886.   end
  8887.  
  8888.   #--------------------------------------------------------------------------#
  8889.   # * alias-method :update
  8890.   #--------------------------------------------------------------------------#  
  8891.   alias :ygg_shift_sys_update :update unless $@
  8892.   def update( *args, &block )
  8893.     ygg_shift_sys_update( *args, &block )
  8894.     @shift_system.update()
  8895.   end
  8896.  
  8897. end
  8898.  
  8899. end
  8900.  
  8901. # // (YGG_LevelUpWindow)
  8902. if YGG::USE_LEVEL_UP_WINDOW > 0
  8903. #==============================================================================#
  8904. # ** YGG::Windows::Level_Up
  8905. #==============================================================================#
  8906. class YGG::Windows::Level_Up < ::Sprite
  8907.  
  8908.   #--------------------------------------------------------------------------#
  8909.   # * Constant(s)
  8910.   #--------------------------------------------------------------------------#  
  8911.   WLH = 20
  8912.   BORDER_SIZE = 2
  8913.  
  8914.   #--------------------------------------------------------------------------#
  8915.   # * super-method :initialize
  8916.   #--------------------------------------------------------------------------#  
  8917.   def initialize( x, y, width, viewport=nil )
  8918.     super( viewport )
  8919.     @background = Sprite.new( self.viewport )
  8920.     @background.bitmap = Bitmap.new( width, WLH )
  8921.     @background.bitmap.fill_rect( BORDER_SIZE, BORDER_SIZE,
  8922.       width-(BORDER_SIZE*2), WLH-(BORDER_SIZE*2),
  8923.       Color.new( 0, 0, 0 ) )
  8924.     @background.bitmap.blur() ; @background.bitmap.blur()
  8925.     @background.opacity = 198
  8926.     self.bitmap = Bitmap.new( width, WLH*7 )
  8927.     self.src_rect.set( 0, 0, width, WLH )
  8928.     @count = 0 ; @index = 0
  8929.     self.x, self.y, self.z = x, y, 9999
  8930.     @target_opacity = 0
  8931.   end
  8932.  
  8933.   #--------------------------------------------------------------------------#
  8934.   # * super-method :dispose
  8935.   #--------------------------------------------------------------------------#
  8936.   def dispose()
  8937.     unless @background.nil?()
  8938.       @background.bitmap.dispose() ; @background.dispose()
  8939.     end
  8940.     self.bitmap.dispose()
  8941.     super()
  8942.   end
  8943.  
  8944.   #--------------------------------------------------------------------------#
  8945.   # * super-method :x=
  8946.   #--------------------------------------------------------------------------#
  8947.   def x=( new_x )
  8948.     super( new_x )
  8949.     @background.x = self.x
  8950.   end
  8951.  
  8952.   #--------------------------------------------------------------------------#
  8953.   # * super-method :y=
  8954.   #--------------------------------------------------------------------------#
  8955.   def y=( new_y )
  8956.     super( new_y )
  8957.     @background.y = self.y
  8958.   end
  8959.  
  8960.   #--------------------------------------------------------------------------#
  8961.   # * super-method :z=
  8962.   #--------------------------------------------------------------------------#
  8963.   def z=( new_z )
  8964.     super( new_z+1 )
  8965.     @background.z = new_z
  8966.   end
  8967.  
  8968.   #--------------------------------------------------------------------------#
  8969.   # * super-method :viewport=
  8970.   #--------------------------------------------------------------------------#
  8971.   def viewport=( new_viewport )
  8972.     super( new_viewport )
  8973.     @background.viewport = self.viewport
  8974.   end
  8975.  
  8976.   #--------------------------------------------------------------------------#
  8977.   # * super-method :visible=
  8978.   #--------------------------------------------------------------------------#
  8979.   def visible=( new_visible )
  8980.     super( new_visible )
  8981.     @background.visible = self.visible
  8982.   end
  8983.  
  8984.   #--------------------------------------------------------------------------#
  8985.   # * super-method :show_level_up
  8986.   #--------------------------------------------------------------------------#
  8987.   def show_level_up( battler, old_level )
  8988.     self.bitmap.clear()
  8989.     @count = 0 ; @index = 0 ; @last_index = -1
  8990.     stats = [:maxhp, :maxmp, :atk, :def, :spi, :agi]
  8991.     self.bitmap.font.size = 16
  8992.     self.bitmap.draw_text( 0, 0, self.width, WLH,
  8993.       sprintf( "%s: %s > %s", Vocab.level, old_level, battler.level ) )
  8994.     for i in 0...stats.size
  8995.       stat = stats[i]
  8996.       self.bitmap.draw_text( 0, WLH+(WLH*i), self.width, 20,
  8997.         sprintf( "%s: %s", Vocab.send( stat ), battler.send( stat ) ) )
  8998.     end  
  8999.     @target_opacity = 198
  9000.     self.visible = true
  9001.   end
  9002.  
  9003.   #--------------------------------------------------------------------------#
  9004.   # * super-method :update
  9005.   #--------------------------------------------------------------------------#
  9006.   def update()
  9007.     super()
  9008.     return if @index >= 8
  9009.     @count += 1
  9010.     @index += 1 if @count % 60 == 0
  9011.     if @index >= 7
  9012.       @target_opacity = 0
  9013.       self.visible = false
  9014.     else  
  9015.       if @index != @last_index
  9016.         self.src_rect.set( 0, WLH*@index, self.width, WLH )
  9017.         @last_index = @index
  9018.       end  
  9019.     end  
  9020.     if @background.opacity > @target_opacity
  9021.       @background.opacity = [@background.opacity - (255/30.0), @target_opacity].max
  9022.     elsif @background.opacity < @target_opacity  
  9023.       @background.opacity = [@background.opacity + (255/30.0), @target_opacity].min
  9024.     end  
  9025.   end
  9026.  
  9027. end  
  9028.  
  9029. #==============================================================================#
  9030. # ** Scene_Map
  9031. #==============================================================================#
  9032. class Scene_Map < Scene_Base
  9033.  
  9034.   #--------------------------------------------------------------------------#
  9035.   # * Public Instance Variable(s)
  9036.   #--------------------------------------------------------------------------#
  9037.   attr_accessor :level_up_window
  9038.  
  9039.   #--------------------------------------------------------------------------#
  9040.   # * alias-method :start
  9041.   #--------------------------------------------------------------------------#
  9042.   alias :ygg_lvl_up_win_scm_start :start unless $@
  9043.   def start( *args, &block )
  9044.     ygg_lvl_up_win_scm_start( *args, &block )
  9045.     @level_up_window = YGG::Windows::Level_Up.new( 0, 0, 128 )
  9046.   end
  9047.  
  9048.   #--------------------------------------------------------------------------#
  9049.   # * alias-method :terminate
  9050.   #--------------------------------------------------------------------------#
  9051.   alias :ygg_lvl_up_win_scm_terminate :terminate unless $@
  9052.   def terminate( *args, &block )
  9053.     ygg_lvl_up_win_scm_terminate( *args, &block )
  9054.     @level_up_window.dispose() unless @level_up_window.nil?() ; @level_up_window = nil
  9055.   end
  9056.  
  9057.   #--------------------------------------------------------------------------#
  9058.   # * alias-method :update
  9059.   #--------------------------------------------------------------------------#
  9060.   alias :ygg_lvl_up_win_scm_update :update unless $@
  9061.   def update( *args, &block )
  9062.     ygg_lvl_up_win_scm_update( *args, &block )
  9063.     @level_up_window.update() unless @level_up_window.nil?()
  9064.   end
  9065.  
  9066. end
  9067.  
  9068. end # // Level Up Window
  9069.  
  9070. #==============================================================================#
  9071. # ** Scene_File
  9072. #==============================================================================#
  9073. class Scene_File < Scene_Base
  9074.  
  9075.   #--------------------------------------------------------------------------#
  9076.   # * alias-method :write_save_data
  9077.   #--------------------------------------------------------------------------#
  9078.   alias :ygg_scnf_ptxt_write_save_data :write_save_data unless $@
  9079.   def write_save_data( file )
  9080.     ygg_scnf_ptxt_write_save_data( file )
  9081.     Marshal.dump( $game_yggdrasil,      file )
  9082.   end  
  9083.  
  9084.   #--------------------------------------------------------------------------#
  9085.   # * alias-method :read_save_data
  9086.   #--------------------------------------------------------------------------#
  9087.   alias :ygg_scnf_ptxt_read_save_data :read_save_data unless $@
  9088.   def read_save_data( file )
  9089.     ygg_scnf_ptxt_read_save_data( file )
  9090.     $game_yggdrasil = Marshal.load( file )
  9091.   end
  9092.  
  9093. end
  9094.  
  9095. # // (Skill/Item Setting) // #
  9096. #==============================================================================#
  9097. # ** YGG::Windows::ActorObjSlots
  9098. #==============================================================================#
  9099. class ::YGG::Windows::ActorObjSlots < ::Window_Selectable
  9100.  
  9101.   #--------------------------------------------------------------------------#
  9102.   # * super-method :initialize
  9103.   #--------------------------------------------------------------------------#  
  9104.   def initialize( actor, x, y, width, height )
  9105.     super( x, y, width, height )
  9106.     @actor = actor
  9107.     @column_max = 1
  9108.     self.active = false
  9109.     self.index  = 0
  9110.     refresh()
  9111.   end
  9112.  
  9113.   #--------------------------------------------------------------------------#
  9114.   # * new-method :enabled?
  9115.   #--------------------------------------------------------------------------#  
  9116.   def enabled?( index )
  9117.     return !@data[index].nil?()
  9118.   end
  9119.  
  9120.   #--------------------------------------------------------------------------#
  9121.   # * new-method :obj
  9122.   #--------------------------------------------------------------------------#  
  9123.   def obj( i=@index ) ; return @data[i] ; end
  9124.    
  9125.   #--------------------------------------------------------------------------#
  9126.   # * new-method :get_objs
  9127.   #--------------------------------------------------------------------------#  
  9128.   def get_objs()
  9129.     return []
  9130.   end
  9131.  
  9132.   #--------------------------------------------------------------------------#
  9133.   # * new-method :refresh
  9134.   #--------------------------------------------------------------------------#  
  9135.   def refresh()
  9136.     @data     = get_objs()
  9137.     @item_max = @data.size
  9138.     @data_enabled = []
  9139.     create_contents()
  9140.     for i in 0...@item_max
  9141.       @data_enabled[i] = enabled?( i )
  9142.       draw_item( i )
  9143.     end
  9144.   end
  9145.  
  9146.   #--------------------------------------------------------------------------#
  9147.   # * new-method :selective_refresh
  9148.   #--------------------------------------------------------------------------#  
  9149.   def selective_refresh()
  9150.     newdata   = get_objs()
  9151.     @item_max = newdata.size
  9152.     if @data.size != @item_max
  9153.       @data.clear()
  9154.       create_contents()
  9155.     end
  9156.     for i in 0...newdata.size
  9157.       if newdata[i] != @data[i] || @data_enabled[i] != enabled?( i )
  9158.         @data[i] = newdata[i]
  9159.         @data_enabled[i] = enabled?( i )
  9160.         draw_item( i )
  9161.       end  
  9162.     end
  9163.   end
  9164.  
  9165.   #--------------------------------------------------------------------------#
  9166.   # * new-method :draw_item
  9167.   #--------------------------------------------------------------------------#  
  9168.   def draw_item( index )
  9169.     rect = item_rect( index )
  9170.     obj  = @data[index]
  9171.     enabled = enabled?( index )
  9172.     self.contents.clear_rect( rect )
  9173.     self.contents.font.color = normal_color
  9174.     self.contents.font.color.alpha -= 128 unless enabled
  9175.     unless obj.nil?()
  9176.       draw_item_name( obj, rect.x, rect.y, enabled )
  9177.     else
  9178.       draw_icon( 98, rect.x, rect.y )
  9179.       rect.x += 24
  9180.       self.contents.draw_text( rect, "----------------" )
  9181.     end  
  9182.   end
  9183.  
  9184.   #--------------------------------------------------------------------------#
  9185.   # * kill-method :cursor_pagedown
  9186.   #--------------------------------------------------------------------------#  
  9187.   def cursor_pagedown() ; end
  9188.    
  9189.   #--------------------------------------------------------------------------#
  9190.   # * kill-method :cursor_pageup
  9191.   #--------------------------------------------------------------------------#    
  9192.   def cursor_pageup() ; end
  9193.    
  9194. end  
  9195.  
  9196. #==============================================================================#
  9197. # ** YGG::Windows::ItemList
  9198. #==============================================================================#
  9199. class ::YGG::Windows::ItemList < ::YGG::Windows::ActorObjSlots
  9200.  
  9201.   #--------------------------------------------------------------------------#
  9202.   # * new-method :item
  9203.   #--------------------------------------------------------------------------#    
  9204.   def item() ; return obj() ; end
  9205.    
  9206.   #--------------------------------------------------------------------------#
  9207.   # * new-method :enabled?
  9208.   #--------------------------------------------------------------------------#    
  9209.   def enabled?( index )
  9210.     return false if @actor.item_slot_items.include?( @data[index] )
  9211.     return false if @data[index].cant_equip_slot unless @data[index].nil?()
  9212.     return super( index )
  9213.   end
  9214.  
  9215.   #--------------------------------------------------------------------------#
  9216.   # * overwrite-method :get_objs
  9217.   #--------------------------------------------------------------------------#    
  9218.   def get_objs()
  9219.     return [nil] + ($game_party.items.inject([]) { |r, i| r << i if i.is_a?(RPG::Item) }) + [nil]
  9220.   end
  9221.  
  9222.   #--------------------------------------------------------------------------#
  9223.   # * overwrite-method :update_help
  9224.   #--------------------------------------------------------------------------#    
  9225.   def update_help()
  9226.     @help_window.set_text(item.nil?() ? "" : item.description)
  9227.   end
  9228.  
  9229. end
  9230.  
  9231. #==============================================================================#
  9232. # ** YGG::Windows::SkillList
  9233. #==============================================================================#
  9234. class ::YGG::Windows::SkillList < ::YGG::Windows::ActorObjSlots
  9235.  
  9236.   #--------------------------------------------------------------------------#
  9237.   # * new-method :skill
  9238.   #--------------------------------------------------------------------------#    
  9239.   def skill() ; return obj() ; end
  9240.    
  9241.   #--------------------------------------------------------------------------#
  9242.   # * super-method :enabled?
  9243.   #--------------------------------------------------------------------------#    
  9244.   def enabled?( index )
  9245.     return false if @actor.skill_slot_skills.include?( @data[index] )
  9246.     return false if @data[index].cant_equip_slot unless @data[index].nil?()
  9247.     return super( index )
  9248.   end
  9249.  
  9250.   #--------------------------------------------------------------------------#
  9251.   # * overwrite-method :get_objs
  9252.   #--------------------------------------------------------------------------#    
  9253.   def get_objs()
  9254.     return [nil] + @actor.skills() + [nil]
  9255.   end
  9256.  
  9257.   #--------------------------------------------------------------------------#
  9258.   # * overwrite-method :update_help
  9259.   #--------------------------------------------------------------------------#    
  9260.   def update_help()
  9261.     @help_window.set_text(skill.nil?() ? "" : skill.description)
  9262.   end
  9263.  
  9264. end
  9265.  
  9266. #==============================================================================#
  9267. # ** YGG::Windows::ActorItemSlots
  9268. #==============================================================================#
  9269. class ::YGG::Windows::ActorItemSlots < ::YGG::Windows::ActorObjSlots
  9270.  
  9271.   #--------------------------------------------------------------------------#
  9272.   # * new-method :item
  9273.   #--------------------------------------------------------------------------#    
  9274.   def item() ; return obj() ; end
  9275.    
  9276.   #--------------------------------------------------------------------------#
  9277.   # * overwrite-method :get_objs
  9278.   #--------------------------------------------------------------------------#    
  9279.   def get_objs()
  9280.     return @actor.item_slot_items()
  9281.   end
  9282.  
  9283.   #--------------------------------------------------------------------------#
  9284.   # * overwrite-method :update_help
  9285.   #--------------------------------------------------------------------------#    
  9286.   def update_help()
  9287.     @help_window.set_text(item.nil?() ? "" : item.description)
  9288.   end
  9289.  
  9290. end  
  9291.  
  9292. #==============================================================================#
  9293. # ** YGG::Windows::ActorSkillSlots
  9294. #==============================================================================#
  9295. class ::YGG::Windows::ActorSkillSlots < ::YGG::Windows::ActorObjSlots
  9296.  
  9297.   #--------------------------------------------------------------------------#
  9298.   # * new-method :skill
  9299.   #--------------------------------------------------------------------------#    
  9300.   def skill() ; return obj() ; end
  9301.    
  9302.   #--------------------------------------------------------------------------#
  9303.   # * overwrite-method :get_objs
  9304.   #--------------------------------------------------------------------------#    
  9305.   def get_objs()
  9306.     return @actor.skill_slot_skills()
  9307.   end
  9308.  
  9309.   #--------------------------------------------------------------------------#
  9310.   # * overwrite-method :update_help
  9311.   #--------------------------------------------------------------------------#    
  9312.   def update_help()
  9313.     @help_window.set_text(skill.nil?() ? "" : skill.description)
  9314.   end
  9315.  
  9316. end  
  9317.  
  9318. # // Is there a good reason why I haven't super classes these? YES
  9319. #==============================================================================#
  9320. # ** YGG::Scenes::ObjSet
  9321. #==============================================================================#
  9322. class ::YGG::Scenes::ObjSet < ::Scene_Base
  9323.  
  9324.   #--------------------------------------------------------------------------#
  9325.   # * super-method :initialize
  9326.   #--------------------------------------------------------------------------#
  9327.   def initialize( actor, called=:map, return_index=0 )
  9328.     super()
  9329.     # ---------------------------------------------------- #
  9330.     @actor = nil
  9331.     @act_index = 0
  9332.     @index_call = false
  9333.     # ---------------------------------------------------- #
  9334.     if actor.kind_of?( Game_Battler )
  9335.       @actor = actor
  9336.     elsif actor != nil  
  9337.       @actor = $game_party.members[actor]
  9338.       @act_index = actor
  9339.       @index_call = true
  9340.     end
  9341.     @calledfrom = called
  9342.     @return_index = return_index
  9343.   end
  9344.  
  9345.   #--------------------------------------------------------------------------#
  9346.   # * new-method :start
  9347.   #--------------------------------------------------------------------------#
  9348.   def start()
  9349.     super()
  9350.   end
  9351.  
  9352.   #--------------------------------------------------------------------------#
  9353.   # * new-method :return_scene
  9354.   #--------------------------------------------------------------------------#
  9355.   def return_scene()
  9356.     case @calledfrom
  9357.     when :map
  9358.       $scene = Scene_Map.new()
  9359.     when :menu
  9360.       $scene = Scene_Menu.new( @return_index )
  9361.     end  
  9362.   end
  9363.  
  9364.   #--------------------------------------------------------------------------#
  9365.   # * super-method :terminate
  9366.   #--------------------------------------------------------------------------#  
  9367.   def terminate()
  9368.     super()
  9369.     dispose_menu_background()
  9370.     @help_window.dispose() unless @help_window.nil?()     ; @help_window = nil
  9371.     @obj_window.dispose() unless @obj_window.nil?()       ; @obj_window = nil
  9372.     @slot_window.dispose() unless @slot_window.nil?()     ; @slot_window = nil
  9373.     @status_window.dispose() unless @status_window.nil?() ; @status_window = nil
  9374.   end
  9375.  
  9376.   #--------------------------------------------------------------------------#
  9377.   # * super-method :update
  9378.   #--------------------------------------------------------------------------#  
  9379.   def update()
  9380.     super()
  9381.     update_menu_background()
  9382.     @obj_window.update() ; @slot_window.update()
  9383.     # // Basic Update
  9384.     if Input.trigger?( Input::B )
  9385.       command_cancel()
  9386.     elsif Input.trigger?( Input::R ) && @index_call    
  9387.       command_next()
  9388.     elsif Input.trigger?( Input::L ) && @index_call
  9389.       command_prev()
  9390.     # // Actual Input    
  9391.     elsif Input.trigger?( Input::C )
  9392.       command_accept()
  9393.     elsif Input.trigger?( Input::Z )
  9394.       # // Used to pop extended help window, if I ever implement it
  9395.     elsif Input.trigger?( Input::X ) || Input.trigger?( Input::LEFT )  
  9396.       command_prevslot()
  9397.     elsif Input.trigger?( Input::Y ) || Input.trigger?( Input::RIGHT )  
  9398.       command_nextslot()
  9399.     end  
  9400.   end  
  9401.  
  9402.   #--------------------------------------------------------------------------#
  9403.   # * new-method :command_cancel
  9404.   #--------------------------------------------------------------------------#
  9405.   def command_cancel()
  9406.     Sound.play_cancel()
  9407.     return_scene()
  9408.   end
  9409.  
  9410.   #--------------------------------------------------------------------------#
  9411.   # * new-method :command_next
  9412.   #--------------------------------------------------------------------------#
  9413.   def command_next()
  9414.     Sound.play_decision()
  9415.     $scene = self.class.new(
  9416.       (@act_index+1) % $game_party.members.size, @calledfrom, @return_index )
  9417.   end
  9418.  
  9419.   #--------------------------------------------------------------------------#
  9420.   # * new-method :command_prev
  9421.   #--------------------------------------------------------------------------#
  9422.   def command_prev()
  9423.     Sound.play_decision()  
  9424.     $scene = self.class.new(
  9425.       (@act_index-1) % $game_party.members.size, @calledfrom, @return_index )
  9426.   end
  9427.  
  9428.   #--------------------------------------------------------------------------#
  9429.   # * new-method :command_nextslot
  9430.   #--------------------------------------------------------------------------#
  9431.   def command_nextslot()
  9432.     Sound.play_cursor()
  9433.     @slot_window.index = (@slot_window.index + 1) % @slot_window.item_max
  9434.   end
  9435.    
  9436.   #--------------------------------------------------------------------------#
  9437.   # * new-method :command_prevslot
  9438.   #--------------------------------------------------------------------------#
  9439.   def command_prevslot()
  9440.     Sound.play_cursor()
  9441.     @slot_window.index = (@slot_window.index - 1) % @slot_window.item_max
  9442.   end
  9443.    
  9444.   #--------------------------------------------------------------------------#
  9445.   # * new-method :command_accept
  9446.   #--------------------------------------------------------------------------#
  9447.   def command_accept()
  9448.   end
  9449.  
  9450. end  
  9451.  
  9452. #==============================================================================#
  9453. # ** YGG::Scenes::ItemSet
  9454. #==============================================================================#
  9455. class ::YGG::Scenes::ItemSet < ::YGG::Scenes::ObjSet
  9456.  
  9457.   #--------------------------------------------------------------------------#
  9458.   # * super-method :start
  9459.   #--------------------------------------------------------------------------#  
  9460.   def start()
  9461.     super()
  9462.     create_menu_background()
  9463.     @help_window   = ::Window_Help.new()
  9464.     @status_window = ::Window_SkillStatus.new( 0, 56, @actor )
  9465.     @obj_window   = ::YGG::Windows::ItemList.new(
  9466.       @actor,
  9467.       Graphics.width/2, 112,
  9468.       Graphics.width/2, Graphics.height-112 )
  9469.     @obj_window.help_window = @help_window  
  9470.     @slot_window   = ::YGG::Windows::ActorItemSlots.new(
  9471.       @actor,
  9472.       0, 112,
  9473.       Graphics.width/2, Graphics.height-112 )
  9474.     @obj_window.active = true  
  9475.   end
  9476.  
  9477.   #--------------------------------------------------------------------------#
  9478.   # * new-method :command_accept
  9479.   #--------------------------------------------------------------------------#
  9480.   def command_accept()
  9481.     if @obj_window.enabled?( @obj_window.index ) || @obj_window.obj.nil?()
  9482.       Sound.play_decision
  9483.       id = @obj_window.item.nil?() ? 0 : @obj_window.item.id
  9484.       @actor.set_item_slot( @slot_window.index, id )
  9485.       @obj_window.selective_refresh() #.draw_item( @obj_window.index )
  9486.       @slot_window.refresh()
  9487.     else
  9488.       Sound.play_buzzer()
  9489.     end  
  9490.   end
  9491.  
  9492. end
  9493.  
  9494. # // Scene_ItemSet.new( actor, called_from, [return_index)]
  9495. Scene_ItemSet = YGG::Scenes::ItemSet
  9496.  
  9497. #==============================================================================#
  9498. # ** YGG::Scenes::SkillSet
  9499. #==============================================================================#
  9500. class ::YGG::Scenes::SkillSet < ::YGG::Scenes::ObjSet
  9501.  
  9502.   #--------------------------------------------------------------------------#
  9503.   # * super-method :start
  9504.   #--------------------------------------------------------------------------#  
  9505.   def start()
  9506.     super()
  9507.     create_menu_background()
  9508.     @help_window   = ::Window_Help.new()
  9509.     @status_window = ::Window_SkillStatus.new( 0, 56, @actor )
  9510.     @obj_window    = ::YGG::Windows::SkillList.new(
  9511.       @actor,
  9512.       Graphics.width/2, 112,
  9513.       Graphics.width/2, Graphics.height-112 )
  9514.     @obj_window.help_window = @help_window  
  9515.     @slot_window   = ::YGG::Windows::ActorSkillSlots.new(
  9516.       @actor,
  9517.       0, 112,
  9518.       Graphics.width/2, Graphics.height-112 )
  9519.     @obj_window.active = true  
  9520.   end
  9521.    
  9522.   #--------------------------------------------------------------------------#
  9523.   # * new-method :command_accept
  9524.   #--------------------------------------------------------------------------#
  9525.   def command_accept()
  9526.     if @obj_window.enabled?( @obj_window.index ) || @obj_window.obj.nil?()
  9527.       Sound.play_decision
  9528.       id = @obj_window.skill.nil?() ? 0 : @obj_window.skill.id
  9529.       @actor.set_skill_slot( @slot_window.index, id )
  9530.       @obj_window.selective_refresh() #draw_item( @obj_window.index )
  9531.       @slot_window.refresh()
  9532.     else
  9533.       Sound.play_buzzer()
  9534.     end  
  9535.   end
  9536.  
  9537. end  
  9538. # // Scene_SkillSet.new( actor, called_from, [return_index)]
  9539. Scene_SkillSet = YGG::Scenes::SkillSet
  9540.  
  9541. # // (YGG_HudSetting) // #
  9542. module YGG ; end ; module YGG::Handlers ; end
  9543.  
  9544. #==============================================================================#
  9545. # ** YGG::Handlers::HudWrapper
  9546. #==============================================================================#    
  9547. class YGG::Handlers::HudWrapper
  9548.  
  9549.   #--------------------------------------------------------------------------#
  9550.   # * Constant(s)
  9551.   #--------------------------------------------------------------------------#        
  9552.   DEFAULTS = {
  9553.     :hp        => 0,
  9554.     :maxhp     => 1,
  9555.     :mp        => 0,
  9556.     :maxmp     => 1,
  9557.     :shift     => 0,
  9558.     :maxshift  => 1,
  9559.     :charge    => 0,
  9560.     :maxcharge => 1,
  9561.     :exp       => 0,
  9562.     :maxexp    => 1,
  9563.   }
  9564.  
  9565.   POSITIONS = YGG::HUD_POSITION_PROCS
  9566.  
  9567.   DEFAULTS.keys.each { |key| define_method(key) { return @values[key] } }
  9568.  
  9569.   #--------------------------------------------------------------------------#
  9570.   # * Public Instance Variable(s)
  9571.   #--------------------------------------------------------------------------#    
  9572.   attr_reader :actor
  9573.   attr_accessor :need_refresh
  9574.  
  9575.   #--------------------------------------------------------------------------#
  9576.   # * new-method :initialize
  9577.   #--------------------------------------------------------------------------#
  9578.   def initialize()
  9579.     @values = {}
  9580.     @actor  = nil
  9581.     @need_refresh = false
  9582.     load_defaults()
  9583.   end
  9584.  
  9585.   #--------------------------------------------------------------------------#
  9586.   # * new-method :load_defaults
  9587.   #--------------------------------------------------------------------------#
  9588.   def refresh()
  9589.     @need_refresh = false
  9590.   end
  9591.  
  9592.   #--------------------------------------------------------------------------#
  9593.   # * new-method :load_defaults
  9594.   #--------------------------------------------------------------------------#
  9595.   def load_defaults()
  9596.     DEFAULTS.each_pair { |key, value| @values[key] = value }
  9597.   end
  9598.  
  9599.   #--------------------------------------------------------------------------#
  9600.   # * new-method :actor=
  9601.   #--------------------------------------------------------------------------#
  9602.   def actor=( new_actor )
  9603.     if new_actor != @actor ; @actor = new_actor ; update() ; end
  9604.   end
  9605.    
  9606.   #--------------------------------------------------------------------------#
  9607.   # * new-method :update
  9608.   #--------------------------------------------------------------------------#    
  9609.   def update()
  9610.     if @actor != $game_player.ygg_battler
  9611.       @actor = $game_player.ygg_battler ; @need_refresh = true
  9612.     end
  9613.     if @actor.nil?()
  9614.       @values[:hp]        = DEFAULTS[:hp]
  9615.       @values[:maxhp]     = DEFAULTS[:maxhp]
  9616.       @values[:mp]        = DEFAULTS[:mp]
  9617.       @values[:maxmp]     = DEFAULTS[:maxmp]
  9618.       @values[:charge]    = DEFAULTS[:charge]
  9619.       @values[:maxcharge] = DEFAULTS[:maxcharge]
  9620.       @values[:exp]       = DEFAULTS[:exp]
  9621.       @values[:maxexp]    = DEFAULTS[:maxexp]
  9622.     else  
  9623.       @values[:hp]        = @actor.hp
  9624.       @values[:maxhp]     = @actor.maxhp
  9625.       @values[:mp]        = @actor.mp
  9626.       @values[:maxmp]     = @actor.maxmp
  9627.       @values[:charge]    = @actor.cooldown
  9628.       @values[:maxcharge] = @actor.cooldown_max
  9629.       @values[:exp]       = @actor.level_exp
  9630.       @values[:maxexp]    = @actor.next_level_exp
  9631.     end  
  9632.     if shift_valid?()
  9633.       @values[:shift]     = $game_yggdrasil.shift_system.time
  9634.       @values[:maxshift]  = $game_yggdrasil.shift_system.cap
  9635.     else
  9636.       @values[:shift]     = DEFAULTS[:shift]
  9637.       @values[:maxshift]  = DEFAULTS[:maxshift]
  9638.     end  
  9639.   end
  9640.  
  9641.   #--------------------------------------------------------------------------#
  9642.   # * new-method :shift_valid?
  9643.   #--------------------------------------------------------------------------#    
  9644.   def shift_valid?()
  9645.     return ::YGG::USE_SHIFT_SYSTEM
  9646.   end
  9647.    
  9648.   #--------------------------------------------------------------------------#
  9649.   # * new-method :get_obj_xyz
  9650.   #--------------------------------------------------------------------------#
  9651.   def get_obj_xyz( *args )
  9652.     return POSITIONS[args[0]].call( *args.slice( 1, args.size ) )
  9653.   end  
  9654.  
  9655. if ::YGG::HUD_SWITCH.nil?() || ::YGG::HUD_SWITCH == 0
  9656.  
  9657.   #--------------------------------------------------------------------------#
  9658.   # * new-method :hud_visible?
  9659.   #--------------------------------------------------------------------------#  
  9660.   def visible?() ; return true ; end
  9661.  
  9662. else
  9663.  
  9664.   #--------------------------------------------------------------------------#
  9665.   # * new-method :hud_visible?
  9666.   #--------------------------------------------------------------------------#  
  9667.   def visible?()
  9668.     return $game_switches[::YGG::HUD_SWITCH]
  9669.   end
  9670.  
  9671. end
  9672.  
  9673. end  
  9674.  
  9675. #==============================================================================#
  9676. # ** YGG::Handlers::Hud
  9677. #==============================================================================#
  9678. class ::YGG::Handlers::Hud
  9679. #==============================================================================#
  9680. # ** SpriteMix
  9681. #==============================================================================#    
  9682.   module SpriteMix
  9683.   #--------------------------------------------------------------------------#
  9684.   # * Public Instance Variables
  9685.   #--------------------------------------------------------------------------#  
  9686.     attr_accessor :add_x, :add_y, :add_z
  9687.    
  9688.   #--------------------------------------------------------------------------#
  9689.   # * super-method :set_add_xyz
  9690.   #--------------------------------------------------------------------------#    
  9691.     def set_add_xyz( ax, ay, az )
  9692.       @add_x, @add_y, @add_z = ax, ay, az
  9693.     end
  9694.    
  9695.   end  
  9696. #==============================================================================#
  9697. # ** Sprite_Back
  9698. #==============================================================================#  
  9699.   class Sprite_Back < ::Sprite  
  9700.    
  9701.     include SpriteMix
  9702.    
  9703.   #--------------------------------------------------------------------------#
  9704.   # * super-method :initialize
  9705.   #--------------------------------------------------------------------------#      
  9706.     def initialize( viewport )
  9707.       @add_x, @add_y, @add_z = 0, 0, 0
  9708.       super( viewport )
  9709.     end
  9710.    
  9711.   end
  9712.  
  9713. #==============================================================================#
  9714. # ** Sprite_Icon
  9715. #==============================================================================#    
  9716.   class Sprite_Icon < ::Sprite
  9717.    
  9718.     include SpriteMix
  9719.    
  9720.   #--------------------------------------------------------------------------#
  9721.   # * Constant(s)
  9722.   #--------------------------------------------------------------------------#    
  9723.     ICON_SIZE = [24, 24]
  9724.    
  9725.   #--------------------------------------------------------------------------#
  9726.   # * Public Instance Variable(s)
  9727.   #--------------------------------------------------------------------------#  
  9728.     attr_reader :icon_index
  9729.     attr_accessor :active_effect
  9730.    
  9731.   #--------------------------------------------------------------------------#
  9732.   # * super-method :initialize
  9733.   #--------------------------------------------------------------------------#      
  9734.     def initialize( viewport=nil )
  9735.       @add_x, @add_y, @add_z = 0, 0, 0
  9736.       super( viewport )
  9737.       self.bitmap = Cache.system( "Iconset" )
  9738.       self.icon_index = 0
  9739.       @active_effect = "none"
  9740.     end
  9741.  
  9742.   #--------------------------------------------------------------------------#
  9743.   # * new-method :icon_index=
  9744.   #--------------------------------------------------------------------------#  
  9745.     def icon_index=( new_index )
  9746.       return if @icon_index == new_index
  9747.       self.src_rect.set(
  9748.        new_index % 16 * ICON_SIZE[0], new_index / 16 * ICON_SIZE[1],
  9749.        ICON_SIZE[0], ICON_SIZE[1] )
  9750.       @icon_index = new_index
  9751.     end
  9752.    
  9753.   #--------------------------------------------------------------------------#
  9754.   # * overwrite-method :update
  9755.   #--------------------------------------------------------------------------#    
  9756.     def update()
  9757.       case @active_effect
  9758.       when "fadeout"
  9759.         self.opacity -= 255 / 30.0
  9760.         @active_effect = "none" if self.opacity == 0
  9761.       when "fadein"  
  9762.         self.opacity += 255 / 30.0
  9763.         @active_effect = "none" if self.opacity == 255
  9764.       end  
  9765.     end
  9766.    
  9767.   end
  9768.  
  9769. #==============================================================================#
  9770. # ** Sprite_ValueBar
  9771. #==============================================================================#      
  9772.   class Sprite_ValueBar < ::Sprite
  9773.    
  9774.     include SpriteMix
  9775.    
  9776.   #--------------------------------------------------------------------------#
  9777.   # * Public Instance Variables
  9778.   #--------------------------------------------------------------------------#  
  9779.     attr_accessor :value, :max
  9780.    
  9781.   #--------------------------------------------------------------------------#
  9782.   # * super-method :initialize
  9783.   #--------------------------------------------------------------------------#    
  9784.     def initialize( viewport=nil )
  9785.       @add_x, @add_y, @add_z = 0, 0, 0
  9786.       super( viewport )
  9787.       @value = 0 ; @max = 1
  9788.     end
  9789.  
  9790.   #--------------------------------------------------------------------------#
  9791.   # * super-method :update
  9792.   #--------------------------------------------------------------------------#    
  9793.     def update()
  9794.       super()
  9795.       self.src_rect.width = self.bitmap.width * @value / [@max, 1].max unless self.bitmap.nil?()
  9796.     end  
  9797.    
  9798.   end
  9799.  
  9800. #==============================================================================#
  9801. # ** Sprite_TinyPortrait
  9802. #==============================================================================#      
  9803.   class Sprite_TinyPortrait < ::Sprite
  9804.    
  9805.   include SpriteMix
  9806.  
  9807.   #--------------------------------------------------------------------------#
  9808.   # * super-method :initialize
  9809.   #--------------------------------------------------------------------------#
  9810.     def initialize( viewport=nil )
  9811.       @add_x, @add_y, @add_z = 0, 0, 0
  9812.       super( viewport )
  9813.     end
  9814.    
  9815.   #--------------------------------------------------------------------------#
  9816.   # * new-method :refresh
  9817.   #--------------------------------------------------------------------------#  
  9818.     def refresh( character_name, character_index )
  9819.       self.bitmap = Cache.character( character_name )
  9820.       sign = character_name[/^[\!\$]./]
  9821.       if sign != nil and sign.include?('$')
  9822.         cw = bitmap.width / 3
  9823.         ch = bitmap.height / 4
  9824.       else
  9825.         cw = bitmap.width / 12
  9826.         ch = bitmap.height / 8
  9827.       end
  9828.       n = character_index
  9829.       self.src_rect.set( (n%4*3+1)*cw, (n/4*4)*ch, cw, ch )
  9830.     end
  9831.    
  9832.   end
  9833.  
  9834.   #--------------------------------------------------------------------------#
  9835.   # * Public Instance Variables
  9836.   #--------------------------------------------------------------------------#  
  9837.   attr_reader :viewport
  9838.   attr_reader :x, :y, :z
  9839.   attr_reader :visible
  9840.  
  9841.   #--------------------------------------------------------------------------#
  9842.   # * new-method :initialize
  9843.   #--------------------------------------------------------------------------#  
  9844.   def initialize( x=0, y=0, z=0 )
  9845.     @visible = true
  9846.     @disposed = false
  9847.     @x, @y, @z = x, y, z
  9848.     create_all()
  9849.     refresh()
  9850.   end
  9851.  
  9852.   #--------------------------------------------------------------------------#
  9853.   # * new-method :create_all
  9854.   #--------------------------------------------------------------------------#
  9855.   def create_all()
  9856.     @skill_setsize = 5#@actor.skill_slot_size
  9857.     @item_setsize  = 5#@actor.item_slot_size
  9858.     create_skills()
  9859.     create_items()
  9860.     @back_sprite = Sprite_Back.new( self.viewport )
  9861.     @back_sprite.bitmap = Cache.system( "1x6Hud2" )
  9862.     @hp_sprite   = Sprite_ValueBar.new( self.viewport )
  9863.     @hp_sprite.bitmap = Cache.system( "1x6Hud_HpBar" )
  9864.     @mp_sprite   = Sprite_ValueBar.new( self.viewport )
  9865.     @mp_sprite.bitmap = Cache.system( "1x6Hud_MpBar" )
  9866.     # // Extended
  9867.     @exp_sprite   = Sprite_ValueBar.new( self.viewport )
  9868.     @exp_sprite.bitmap = Cache.system( "1x6Hud_ExpBar" )
  9869.     @shift_sprite   = Sprite_ValueBar.new( self.viewport )
  9870.     @shift_sprite.bitmap = Cache.system( "1x6Hud_ShiftBar" )
  9871.     @charge_sprite   = Sprite_ValueBar.new( self.viewport )
  9872.     @charge_sprite.bitmap = Cache.system( "1x6Hud_ChargeBar" )
  9873.     @portrait_sprite = Sprite_TinyPortrait.new( self.viewport )
  9874.     @sprites = [@back_sprite, @hp_sprite, @mp_sprite, @portrait_sprite]
  9875.     @sprites+= [@exp_sprite, @shift_sprite, @charge_sprite]
  9876.     @__hud_wrapper = $game_yggdrasil.hud
  9877.   end
  9878.  
  9879.   #--------------------------------------------------------------------------#
  9880.   # * new-method :disposed?
  9881.   #--------------------------------------------------------------------------#
  9882.   def disposed?() ; return @disposed ; end
  9883.    
  9884.   #--------------------------------------------------------------------------#
  9885.   # * new-method :dispose
  9886.   #--------------------------------------------------------------------------#
  9887.   def dispose()
  9888.     each_sprite { |s| s.dispose() }
  9889.     @back_sprite = nil ; @hp_sprite = nil ; @mp_sprite = nil
  9890.     @skills = nil ; @items = nil
  9891.     @disposed = true
  9892.   end
  9893.  
  9894.   #--------------------------------------------------------------------------#
  9895.   # * new-method :refresh
  9896.   #--------------------------------------------------------------------------#
  9897.   def refresh()
  9898.     @portrait_sprite.refresh(
  9899.       @__hud_wrapper.actor.nil?() ? "" : @__hud_wrapper.actor.character_name,
  9900.       @__hud_wrapper.actor.nil?() ?  0 : @__hud_wrapper.actor.character_index )
  9901.     refresh_add_xyz()
  9902.     refresh_xyz()
  9903.   end
  9904.  
  9905.   #--------------------------------------------------------------------------#
  9906.   # * new-method :create_skills
  9907.   #--------------------------------------------------------------------------#  
  9908.   def create_skills()
  9909.     @skills = Array.new( @skill_setsize ).map! { Sprite_Icon.new( self.viewport ) }
  9910.     for i in 0...@skills.size
  9911.       @skills[i].bush_opacity = 48
  9912.     end  
  9913.   end
  9914.  
  9915.   #--------------------------------------------------------------------------#
  9916.   # * new-method :create_items
  9917.   #--------------------------------------------------------------------------#  
  9918.   def create_items()
  9919.     @items = Array.new( @item_setsize ).map! { Sprite_Icon.new( self.viewport ) }
  9920.     for i in 0...@items.size
  9921.       @items[i].bush_opacity = 48
  9922.     end
  9923.   end
  9924.  
  9925.   #--------------------------------------------------------------------------#
  9926.   # * new-method :each_sprite
  9927.   #--------------------------------------------------------------------------#  
  9928.   def each_sprite()
  9929.     (@sprites+@skills.to_a+@items.to_a).each { |s| yield s unless s.nil?() }
  9930.   end
  9931.  
  9932.   #--------------------------------------------------------------------------#
  9933.   # * new-method :x=
  9934.   #--------------------------------------------------------------------------#  
  9935.   def x=( new_x )
  9936.     @x = new_x ; refresh_x()
  9937.   end
  9938.  
  9939.   #--------------------------------------------------------------------------#
  9940.   # * new-method :visible=
  9941.   #--------------------------------------------------------------------------#  
  9942.   def visible=( new_visible )
  9943.     @visible = new_visible ; refresh_visible()
  9944.   end
  9945.  
  9946.   #--------------------------------------------------------------------------#
  9947.   # * new-method :y=
  9948.   #--------------------------------------------------------------------------#  
  9949.   def y=( new_y )
  9950.     @y = new_y ; refresh_y()
  9951.   end
  9952.  
  9953.   #--------------------------------------------------------------------------#
  9954.   # * new-method :z=
  9955.   #--------------------------------------------------------------------------#  
  9956.   def z=( new_z )
  9957.     @z = new_z ; refresh_z()
  9958.   end
  9959.  
  9960.   #--------------------------------------------------------------------------#
  9961.   # * new-method :viewport=
  9962.   #--------------------------------------------------------------------------#  
  9963.   def viewport=( new_viewport )
  9964.     @viewport = new_viewport
  9965.     each_sprite { |s| s.viewport = @viewport }
  9966.   end
  9967.  
  9968.   #--------------------------------------------------------------------------#
  9969.   # * new-method :refresh_x
  9970.   #--------------------------------------------------------------------------#
  9971.   def refresh_x()
  9972.     each_sprite { |s| s.x = @x + s.add_x }
  9973.   end
  9974.  
  9975.   #--------------------------------------------------------------------------#
  9976.   # * new-method :refresh_y
  9977.   #--------------------------------------------------------------------------#
  9978.   def refresh_y()
  9979.     each_sprite { |s| s.y = @y + s.add_y }
  9980.   end
  9981.  
  9982.   #--------------------------------------------------------------------------#
  9983.   # * new-method :refresh_z
  9984.   #--------------------------------------------------------------------------#
  9985.   def refresh_z()
  9986.     each_sprite { |s| s.z = @z + s.add_z }
  9987.   end
  9988.  
  9989.   #--------------------------------------------------------------------------#
  9990.   # * new-method :refresh_add_xyz
  9991.   #--------------------------------------------------------------------------#
  9992.   def refresh_add_xyz()
  9993.     @back_sprite.set_add_xyz(     *@__hud_wrapper.get_obj_xyz( :back ) )
  9994.     @hp_sprite.set_add_xyz(       *@__hud_wrapper.get_obj_xyz( :hp_bar ) )
  9995.     @mp_sprite.set_add_xyz(       *@__hud_wrapper.get_obj_xyz( :mp_bar ) )
  9996.     @portrait_sprite.set_add_xyz( *@__hud_wrapper.get_obj_xyz( :sprite ) )
  9997.     @exp_sprite.set_add_xyz(      *@__hud_wrapper.get_obj_xyz( :exp_bar ) )
  9998.     @shift_sprite.set_add_xyz(    *@__hud_wrapper.get_obj_xyz( :shift_bar ) )
  9999.     @charge_sprite.set_add_xyz(   *@__hud_wrapper.get_obj_xyz( :charge_bar ) )
  10000.     for i in 0...@skills.size
  10001.       @skills[i].set_add_xyz(     *@__hud_wrapper.get_obj_xyz( :skill_icon, i ) )
  10002.     end  
  10003.     for i in 0...@items.size
  10004.       @items[i].set_add_xyz(      *@__hud_wrapper.get_obj_xyz( :item_icon, i ) )
  10005.     end
  10006.   end
  10007.  
  10008.   #--------------------------------------------------------------------------#
  10009.   # * new-method :refresh_xyz
  10010.   #--------------------------------------------------------------------------#
  10011.   def refresh_xyz()
  10012.     each_sprite { |s| s.x, s.y, s.z = @x + s.add_x, @y + s.add_y, @z + s.add_z }
  10013.   end
  10014.  
  10015.   #--------------------------------------------------------------------------#
  10016.   # * new-method :refresh_visible
  10017.   #--------------------------------------------------------------------------#
  10018.   def refresh_visible()
  10019.     each_sprite { |s| s.visible = @visible }
  10020.   end
  10021.  
  10022.   #--------------------------------------------------------------------------#
  10023.   # * new-method :update
  10024.   #--------------------------------------------------------------------------#
  10025.   def update()
  10026.     if @__hud_wrapper.need_refresh
  10027.       @__hud_wrapper.refresh() ; refresh()
  10028.     end  
  10029.     @hp_sprite.value, @hp_sprite.max = @__hud_wrapper.hp, @__hud_wrapper.maxhp
  10030.     @mp_sprite.value, @mp_sprite.max = @__hud_wrapper.mp, @__hud_wrapper.maxmp
  10031.     @exp_sprite.value, @exp_sprite.max = @__hud_wrapper.exp, @__hud_wrapper.maxexp
  10032.     @shift_sprite.value, @shift_sprite.max = @__hud_wrapper.shift, @__hud_wrapper.maxshift
  10033.     @charge_sprite.value, @charge_sprite.max = @__hud_wrapper.charge, @__hud_wrapper.maxcharge
  10034.     @hp_sprite.update()
  10035.     @mp_sprite.update()
  10036.     @exp_sprite.update()
  10037.     @shift_sprite.update()
  10038.     @charge_sprite.update()
  10039.     unless @__hud_wrapper.actor.nil?()
  10040.       for i in 0...@skills.size
  10041.         obj = @__hud_wrapper.actor.skill_slot( i )
  10042.         hnd = @__hud_wrapper.actor.get_skill_handle( obj.nil?() ? 0 : obj.id )
  10043.         sprite = @skills[i]
  10044.         sprite.tone.gray = 255.0 * hnd.time.to_f / [hnd.cap, 1].max
  10045.         sprite.bush_depth = sprite.height * hnd.time.to_f / [hnd.cap, 1].max
  10046.         icon_index = obj.nil?() ? 0 : obj.icon_index
  10047.         if sprite.icon_index != icon_index
  10048.           if sprite.active_effect == "none" && sprite.opacity == 0
  10049.             sprite.icon_index = icon_index
  10050.             sprite.active_effect = "fadein"
  10051.           elsif sprite.active_effect == "none" && sprite.opacity > 0
  10052.             sprite.opacity = 0 if sprite.icon_index == 0
  10053.             sprite.active_effect = "fadeout"
  10054.           end  
  10055.         end  
  10056.         sprite.update()
  10057.       end
  10058.       for i in 0...@items.size
  10059.         obj = @__hud_wrapper.actor.item_slot( i )
  10060.         hnd = @__hud_wrapper.actor.get_item_handle( obj.nil?() ? 0 : obj.id )
  10061.         sprite = @items[i]
  10062.         sprite.tone.gray = 255.0 * hnd.time.to_f / [hnd.cap, 1].max
  10063.         sprite.bush_depth = sprite.height * hnd.time.to_f / [hnd.cap, 1].max
  10064.         icon_index = obj.nil?() ? 0 : obj.icon_index
  10065.         if sprite.icon_index != icon_index
  10066.           if sprite.active_effect == "none" && sprite.opacity == 0
  10067.             sprite.icon_index = icon_index
  10068.             sprite.active_effect = "fadein"
  10069.           elsif sprite.active_effect == "none" && sprite.opacity > 0
  10070.             sprite.opacity = 0 if sprite.icon_index == 0
  10071.             sprite.active_effect = "fadeout"
  10072.           end  
  10073.         end  
  10074.         sprite.update()
  10075.       end  
  10076.     end  
  10077.   end
  10078.  
  10079. end
  10080.  
  10081. #==============================================================================#
  10082. # ** YGG::System
  10083. #==============================================================================#
  10084. class YGG::System
  10085.  
  10086. if YGG::DROPS_WINDOW_SWITCH.nil?() || YGG::DROPS_WINDOW_SWITCH == 0
  10087.  
  10088.   #--------------------------------------------------------------------------#
  10089.   # * new-method :drops_window_visible?
  10090.   #--------------------------------------------------------------------------#
  10091.   def drops_window_visible?() ; return true ; end
  10092.  
  10093. else
  10094.  
  10095.   #--------------------------------------------------------------------------#
  10096.   # * new-method :drops_window_visible?
  10097.   #--------------------------------------------------------------------------#
  10098.   def drops_window_visible?()
  10099.     return $game_switches[::YGG::DROPS_WINDOW_SWITCH]
  10100.   end
  10101.  
  10102. end
  10103.  
  10104. end
  10105.  
  10106. if YGG::USE_HUD
  10107. #==============================================================================#
  10108. # ** Scene_Map
  10109. #==============================================================================#
  10110. class Scene_Map < Scene_Base
  10111.  
  10112.   #--------------------------------------------------------------------------#
  10113.   # * Class Variable(s)
  10114.   #--------------------------------------------------------------------------#  
  10115.   @@__temp = 0
  10116.  
  10117.   #--------------------------------------------------------------------------#
  10118.   # * alias-method :start
  10119.   #--------------------------------------------------------------------------#
  10120.   alias :ygg1x6_hud_start :start unless $@
  10121.   def start( *args, &block )
  10122.     ygg1x6_hud_start( *args, &block )
  10123.     create_ygg_hud()
  10124.   end
  10125.  
  10126.   #--------------------------------------------------------------------------#
  10127.   # * new-method :create_ygg_hud
  10128.   #--------------------------------------------------------------------------#
  10129.   def create_ygg_hud()
  10130.     @ygg_hud = ::YGG::Handlers::Hud.new( *$game_yggdrasil.hud.get_obj_xyz( :main ) )
  10131.     update_ygg_hud()
  10132.   end
  10133.  
  10134.   #--------------------------------------------------------------------------#
  10135.   # * alias-method :update
  10136.   #--------------------------------------------------------------------------#
  10137.   alias :ygg1x6_hud_update :update unless $@
  10138.   def update( *args, &block )
  10139.     ygg1x6_hud_update( *args, &block )
  10140.     update_ygg_hud()
  10141.   end
  10142.  
  10143.   #--------------------------------------------------------------------------#
  10144.   # * new-method :update_ygg_hud
  10145.   #--------------------------------------------------------------------------#
  10146.   def update_ygg_hud()
  10147.     @@__temp = $game_yggdrasil.hud.visible?()
  10148.     @ygg_hud.visible = @@__temp if @ygg_hud.visible != @@__temp
  10149.     @ygg_hud.update()
  10150.   end
  10151.  
  10152.   #--------------------------------------------------------------------------#
  10153.   # * alias-method :terminate
  10154.   #--------------------------------------------------------------------------#
  10155.   alias :ygg1x6_hud_terminate :terminate unless $@
  10156.   def terminate( *args, &block )
  10157.     ygg1x6_hud_terminate( *args, &block )
  10158.     @ygg_hud.dispose() unless @ygg_hud.nil?() ; @ygg_hud = nil
  10159.   end
  10160.  
  10161. end  
  10162.  
  10163. end
  10164.  
  10165. #==============================================================================#
  10166. # ** YGG::System
  10167. #==============================================================================#
  10168. class YGG::System
  10169.  
  10170.   #--------------------------------------------------------------------------#
  10171.   # * new-method :start_target_selection
  10172.   #--------------------------------------------------------------------------#  
  10173.   def start_target_selection( target_count=1, targets=[] )
  10174.     return [] if targets.empty?()
  10175.     darken_sprite = Sprite.new()
  10176.     darken_sprite.bitmap = Cache.picture( "BlackSheet" )
  10177.     darken_sprite.opacity = 96
  10178.     target_cursor = Sprite.new()
  10179.     target_cursor.bitmap = Cache.picture( "YGG2_Cursor" )
  10180.     target_cursor.ox, target_cursor.oy = 16, 64
  10181.     hold_cursors = [] ; target_index = 0
  10182.     targets.sort! { |a, b| a.screen_x <=> b.screen_x }
  10183.     target = targets[target_index]
  10184.     selected_targets = []
  10185.     target_cursor.x, target_cursor.y = target.screen_x, target.screen_y unless target.nil?()
  10186.     loop do
  10187.       Graphics.update()
  10188.       Input.update()
  10189.       if Input.trigger?( Input::RIGHT ) || Input.trigger?( Input::DOWN )
  10190.         Sound.play_cursor()
  10191.         target_index = (target_index + 1) % [targets.size, 1].max
  10192.         target = targets[target_index]
  10193.       elsif Input.trigger?( Input::LEFT ) || Input.trigger?( Input::UP )
  10194.         Sound.play_cursor()
  10195.         target_index = (target_index - 1) % [targets.size, 1].max
  10196.         target = targets[target_index]
  10197.       end
  10198.       if Input.trigger?( Input::C )
  10199.         Sound.play_decision()
  10200.         selected_targets << target
  10201.         if selected_targets.size == target_count
  10202.           break
  10203.         else
  10204.           sp = Sprite.new()
  10205.           sp.bitmap = Cache.picture( "YGG2_Cursor" )
  10206.           sp.ox, sp.oy = 16, 64
  10207.           sp.zoom_x, sp.zoom_y = 0.75, 0.75
  10208.           sp.x, sp.y = target.screen_x, target.screen_y
  10209.           hold_cursors << sp
  10210.         end  
  10211.       elsif Input.trigger?( Input::B )
  10212.         Sound.play_cancel()
  10213.         selected_targets.pop()
  10214.         sp = hold_cursors.pop() ; sp.dispose() unless sp.nil?()
  10215.         break if selected_targets.empty?()
  10216.       end  
  10217.       unless target.nil?()
  10218.         if target.screen_x > target_cursor.x
  10219.           target_cursor.x = [target_cursor.x + Graphics.width/30.0, target.screen_x].min
  10220.         elsif target.screen_x < target_cursor.x  
  10221.           target_cursor.x = [target_cursor.x - Graphics.width/30.0, target.screen_x].max
  10222.         end  
  10223.         if target.screen_y > target_cursor.y
  10224.           target_cursor.y = [target_cursor.y + Graphics.height/30.0, target.screen_y].min
  10225.         elsif target.screen_y < target_cursor.y
  10226.           target_cursor.y = [target_cursor.y - Graphics.height/30.0, target.screen_y].max
  10227.         end
  10228.       end  
  10229.     end  
  10230.     hold_cursors.each { |s| s.dispose unless s.nil?() } ; hold_cursors = nil
  10231.     target_cursor.dispose() ; darken_sprite.dispose()
  10232.     return selected_targets
  10233.   end
  10234.  
  10235.   #--------------------------------------------------------------------------#
  10236.   # * new-method :start_xy_selection
  10237.   #--------------------------------------------------------------------------#  
  10238.   def start_xy_selection()
  10239.   end
  10240.  
  10241.   #--------------------------------------------------------------------------#
  10242.   # * new-method :gameover_process
  10243.   #--------------------------------------------------------------------------#  
  10244.   def gameover_process()
  10245.     $game_temp.next_scene = "gameover"
  10246.   end
  10247.  
  10248. end  
  10249.  
  10250. #=*==========================================================================*=#
  10251. # ** END OF FILE
  10252. #=*==========================================================================*=#
  10253.