Advertisement
IceDragon200

Yggdrasil 1.6c

Mar 17th, 2012
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 411.90 KB | None | 0 0
  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/03/2011
  9. # ** Version       : 1.6c
  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. #                         You can make certain skills and items guardable (can be guarded against)
  91. #                         <guardable>
  92. #                     CLEAN:
  93. #                       Rewrote Introduction
  94. #                       Removed unused constants
  95. # 12/03/2011 - V1.6c  Added 2 new features, fixed 4 bug, 2 changes
  96. #                     NEW:
  97. #                       Added Equipment icons for enemies
  98. #                         <use equipment> Very important
  99. #                         <equip icon x: wep y>
  100. #                         <equip icon x: arm y>
  101. #                         <equip icon x: skill y>
  102. #                         <equip icon x: item y>
  103. #                         <equip icon x: y>
  104. #                       Added "AFFECTED" target type for "TARGET" action
  105. #                         This returns a list of the targets that where last
  106. #                         affected, by a _effect
  107. #                
  108. #                     BUGS:
  109. #                       Marshalling errors when you tried to save the game, while a poptext was present
  110. #                       target_selection would malfunction on game reload
  111. #                       Fixed multiple referencing errors that would occur on game reload
  112. #                       roam_xy had an error in it resulting only 1 event being sent back
  113. #                     CHANGES:
  114. #                       Handles are now refreshed on game load to fix some errors
  115. #                       Equipment handles have been stripped of there parents
  116. #
  117. #------------------------------------------------------------------------------#
  118. #==============================================================================#
  119. # ** KNOWN ISSUES
  120. #------------------------------------------------------------------------------#
  121. #  Becareful when using:
  122. #  <action n>
  123. #  </action>
  124. #  It is very sensitive (even whitespace can destroy your action) D:
  125. #  If you aren't confident stick to the <action n= string> method
  126. #
  127. #  Due to the size of the script, any error that occurs in the script MAY
  128. #  not be located on the correct line.
  129. #  I will split the script (AGAIN) later, to fix this problem.
  130. #
  131. #------------------------------------------------------------------------------#
  132. #==============================================================================#  
  133. # ** YGG
  134. #==============================================================================#
  135. module YGG
  136. #==============================================================================#
  137. #                           Start Customization
  138. #------------------------------------------------------------------------------#
  139. #==============================================================================#
  140.   #--------------------------------------------------------------------------#
  141.   # * ABS_SYSTEM_SWITCH
  142.   #--------------------------------------------------------------------------#
  143.   # This is the switch which controls Yggdrasil
  144.   # If you set this constant to nil, Yggdrasil will always be active.
  145.   #--------------------------------------------------------------------------#
  146.     ABS_SYSTEM_SWITCH = 2
  147.  
  148.   #--------------------------------------------------------------------------#
  149.   # * ITEM_MAP
  150.   #--------------------------------------------------------------------------#
  151.   # Currently this is not used for 1.6, but its still nice to have it
  152.   # just in case XD
  153.   #--------------------------------------------------------------------------#
  154.     ITEM_MAP = 2
  155.        
  156.   #--------------------------------------------------------------------------#
  157.   # * DONT_SCAN_EVENTS
  158.   #--------------------------------------------------------------------------#
  159.   # Because events can either be allies or enemies, this tends to be a
  160.   # bit slow for each event, you can disable event scanning,
  161.   # so the events can only target the player.
  162.   #--------------------------------------------------------------------------#  
  163.     DONT_SCAN_EVENTS = true
  164.  
  165.   #--------------------------------------------------------------------------#
  166.   # * FULL_FIELD_SCAN
  167.   #--------------------------------------------------------------------------#
  168.   # *Warning this may cause Lag*
  169.   # Events will scan all around them for targets
  170.   # That means infront, behind, and beside
  171.   #--------------------------------------------------------------------------#  
  172.     FULL_FIELD_SCAN = true
  173.    
  174.   #--------------------------------------------------------------------------#
  175.   # * DIE_WAIT_TIME
  176.   #--------------------------------------------------------------------------#
  177.   # Time in frames for events to die.
  178.   # Default is 30
  179.   #--------------------------------------------------------------------------#  
  180.     DIE_WAIT_TIME = 30
  181.  
  182.   #--------------------------------------------------------------------------#
  183.   # * DRAW_RANGES
  184.   #--------------------------------------------------------------------------#
  185.   # Should the ranges for attacks/skills/etc be drawn?
  186.   #--------------------------------------------------------------------------#  
  187.     DRAW_RANGES = false
  188.    
  189.   #--------------------------------------------------------------------------#
  190.   # * ALL_DEAD_GAMEOVER
  191.   #--------------------------------------------------------------------------#
  192.   # >.> Quite Obviously you will set this to true..
  193.   # I don't even know why I made a constant for it anyway...
  194.   # When this is true, if all party members are dead, the Gameover will
  195.   # be triggered.
  196.   #--------------------------------------------------------------------------#  
  197.     ALL_DEAD_GAMEOVER = true  
  198.            
  199.   #--------------------------------------------------------------------------#
  200.   # * TOTAL_WILD_ANIMS
  201.   #--------------------------------------------------------------------------#
  202.   # In addition to each characters own animations, Yggdrasil has a wild anim
  203.   # set, where these animations are stand alone and can be triggered from
  204.   # anywhere on the map.
  205.   # Note greater numbers means more anims that can be shown at a time
  206.   # This will increase the number of updates and may result in Lagging.
  207.   # I reccomend keeping it around 8 to 16
  208.   #--------------------------------------------------------------------------#  
  209.     TOTAL_WILD_ANIMS = 16
  210.  
  211.   #--------------------------------------------------------------------------#
  212.   # * STATE_TURN_COUNTER
  213.   #--------------------------------------------------------------------------#
  214.   # This is used for state turns, in other words how many frames make a turn
  215.   # Default is 240
  216.   #--------------------------------------------------------------------------#
  217.     STATE_TURN_COUNTER = 480 #240
  218.  
  219.   #--------------------------------------------------------------------------#
  220.   # * SLIP_DAMAGE_FREQUENCY
  221.   #--------------------------------------------------------------------------#
  222.   # How often should slip damage occur
  223.   #--------------------------------------------------------------------------#
  224.     SLIP_DAMAGE_FREQUENCY = 5
  225.    
  226.   #--------------------------------------------------------------------------#
  227.   # * ACTION_BUTTONS
  228.   #--------------------------------------------------------------------------#
  229.   # Yggdrasil 1x6 uses unlimited buttons instead of 3 ( 1.0..1.5 series )
  230.   #--------------------------------------------------------------------------#
  231.     # // Jump to (YGG_PlayerInputConfig)
  232.    
  233.   #--------------------------------------------------------------------------#
  234.   # * TEXT_POP
  235.   #--------------------------------------------------------------------------#
  236.   # As of 1.6 TEXT POP is now built into the main script.
  237.   #--------------------------------------------------------------------------#  
  238.     USE_TEXT_POP = true
  239.     # Copied from BEM So you can recycle
  240.     POPUP_SETTINGS = {
  241.       :hp_dmg     => "%s",        # SprintF for HP damage.
  242.       :hp_heal    => "+%s",       # SprintF for HP healing.
  243.       :mp_dmg     => "%s SP",     # SprintF for MP damage.
  244.       :mp_heal    => "+%s SP",    # SprintF for MP healing.
  245.       :critical   => "CRITICAL!", # Text display for critical hit.
  246.       :missed     => "MISS",      # Text display for missed attack.
  247.       :evaded     => "EVADE!",    # Text display for evaded attack.
  248.       :nulled     => "NULLED",    # Text display for nulled attack.
  249.       :add_state  => "+%s",       # SprintF for added states.
  250.       :rem_state  => "-%s",       # SprintF for removed states.
  251.      
  252.       :exp_pop    => "Exp: %s",   # SprintF for Exp Pops.
  253.       :lvl_pop    => "Level %s",  # SprintF for Level Pops.
  254.       :guard      => "Guard!!!",
  255.     } # Do Not Remove
  256.    
  257.   #--------------------------------------------------------------------------#
  258.   # * POPUP_RULES
  259.   #--------------------------------------------------------------------------#
  260.   # Text Properties
  261.   # "Bold"      = Pop will be drawn Bold
  262.   # "Italic"    = Pop will be drawn with Italics
  263.   # "Shadow"    = Pop will be drawn with Shadows
  264.   # "No Bold"   = Pop will not be drawn Bold
  265.   # "No Italic" = Pop will not be drawn with Italics
  266.   # "No Shadow" = Pop will not be drawn with Shadow
  267.   #
  268.   # Font names is an array of font names (If the first one isn't present on
  269.   # the system, the next one is used, if non are present from the array
  270.   # the default is used)
  271.   #--------------------------------------------------------------------------#
  272.     COLOR_SETS = {#Ally                      Damage
  273.       :hp_no_dmg => [Color.new(180, 205, 180), Color.new(180, 205, 180)],
  274.       :hp_dmg    => [Color.new(128, 128, 240), Color.new(240, 128, 128)],
  275.       :hp_heal   => [Color.new(144, 238, 144), Color.new(198, 238, 144)],
  276.    
  277.       :mp_no_dmg => [Color.new(180, 180, 205), Color.new(180, 180, 205)],
  278.       :mp_dmg    => [Color.new(199, 21 , 112), Color.new(199, 21 , 112)],
  279.       :mp_heal   => [Color.new(173, 216, 230), Color.new(173, 216, 230)],
  280.     }
  281.    
  282.     POPUP_RULES = {
  283.     #                        
  284.    #"something"=> [fontsize, [color, color], [text_properties], [font_names]]
  285.       "HP_NO_DMG"=> [16, COLOR_SETS[:hp_no_dmg]  , [           ], [          ]],
  286.       "HP_DMG"   => [21, COLOR_SETS[:hp_dmg]     , [           ], [          ]],
  287.       "HP_HEAL"  => [21, COLOR_SETS[:hp_heal]    , ["Italic"   ], [          ]],
  288.    
  289.       "MP_NO_DMG"=> [16, COLOR_SETS[:mp_no_dmg]  , [           ], [          ]],
  290.       "MP_DMG"   => [21, COLOR_SETS[:mp_dmg]     , [           ], [          ]],
  291.       "MP_HEAL"  => [21, COLOR_SETS[:mp_heal]    , ["Italic"   ], [          ]],
  292.    
  293.       "MISSED"   => [19, Color.new(176, 196, 222), ["Italic"   ], [          ]],
  294.       "EVADED"   => [19, Color.new(198, 198, 198), ["Italic"   ], [          ]],
  295.       "NULLED"   => [19, Color.new(255, 160, 122), ["Bold"     ], [          ]],
  296.    
  297.       "ADD_STATE"=> [26, Color.new(255, 255, 224), ["No Shadow"], [          ]],
  298.       "REM_STATE"=> [26, Color.new(250, 250, 210), ["No Shadow"], [          ]],
  299.    
  300.       "EXP_POP"  => [18, Color.new(255, 215, 0  ), [           ], [          ]],
  301.       "LVL_POP"  => [21, Color.new(180, 215, 255), [           ], [          ]],
  302.    
  303.       "CRITICAL" => [24, Color.new(220, 20 , 60 ), ["Bold"     ], [          ]],
  304.      
  305.       "GUARD"    => [21, Color.new(198, 198, 202), ["Bold"     ], [          ]],
  306.     } # Do Not Remove
  307.    
  308.   #--------------------------------------------------------------------------#
  309.   # * CRITICAL_FONTSIZE_ADD
  310.   #--------------------------------------------------------------------------#
  311.   # When a critcial is done how much should be added to the Damage pop's
  312.   # font size
  313.   #--------------------------------------------------------------------------#
  314.     CRITICAL_FONTSIZE_ADD = 4
  315.    
  316.   #--------------------------------------------------------------------------#
  317.   # * SHOW_CRITICAL
  318.   #--------------------------------------------------------------------------#
  319.   # Should the "Critical" text be drawn when it is done?
  320.   #--------------------------------------------------------------------------#  
  321.     SHOW_CRITICAL = true
  322.  
  323.   #--------------------------------------------------------------------------#
  324.   # * SHOW_GUARD
  325.   #--------------------------------------------------------------------------#
  326.   # Should the "Guard" text be drawn when it is done?
  327.   #--------------------------------------------------------------------------#  
  328.     SHOW_GUARD = true
  329.    
  330.   #--------------------------------------------------------------------------#
  331.   # * LEVEL_UP_ALERT
  332.   #--------------------------------------------------------------------------#
  333.   # Should something happen on level up?
  334.   #--------------------------------------------------------------------------#
  335.     LEVEL_UP_ALERT = false
  336.    
  337.   #--------------------------------------------------------------------------#
  338.   # * ANIM_ON_LEVEL
  339.   #--------------------------------------------------------------------------#
  340.   # Animation used for level up. If set to 0, no anim is played
  341.   # This is disabled if LEVEL_UP_ALERT = false
  342.   #--------------------------------------------------------------------------#  
  343.     ANIM_ON_LEVEL = 0 # 257
  344.    
  345.   #--------------------------------------------------------------------------#
  346.   # * POP_LEVEL_UP
  347.   #--------------------------------------------------------------------------#
  348.   # Should a text pop with Level Up be used?
  349.   # This is disabled if LEVEL_UP_ALERT = false
  350.   #--------------------------------------------------------------------------#  
  351.     POP_LEVEL_UP = false
  352.  
  353.   #--------------------------------------------------------------------------#
  354.   # * POP_EXP
  355.   #--------------------------------------------------------------------------#
  356.   # Should a text pop be used for EXP?
  357.   #--------------------------------------------------------------------------#  
  358.     POP_EXP = true
  359.  
  360.   #--------------------------------------------------------------------------#
  361.   # * EXP_GAINING_METHOD
  362.   #--------------------------------------------------------------------------#
  363.   # 0 Dead   - When the target is defeated the character gains EXP
  364.   # 1 Per Hit- On every successful hit, exp is gained
  365.   #--------------------------------------------------------------------------#  
  366.     EXP_GAINING_METHOD = 0
  367.    
  368.   #--------------------------------------------------------------------------#
  369.   # * EXP_PER_HIT_FORMULA
  370.   #--------------------------------------------------------------------------#
  371.   # If you have no idea about scripting, don't touch this.
  372.   #--------------------------------------------------------------------------#  
  373.     EXP_PER_HIT_FORMULA = Proc.new { |damage, atker, defer| defer.exp * damage / defer.maxhp}
  374.    
  375.   #--------------------------------------------------------------------------#
  376.   # * EXP_SAHRE_METHOD
  377.   #--------------------------------------------------------------------------#
  378.   # 0 Active Member Only - Only the active member gains EXP
  379.   # 1 All Members Equal  - All members gain EXP
  380.   # 2 All Members Split  - The EXP is split amongst all Members
  381.   #--------------------------------------------------------------------------#  
  382.     # 0 Only Active Member, 1 All Members Equal, 2 All Members Spilt
  383.     EXP_SAHRE_METHOD = 1
  384.  
  385.   #--------------------------------------------------------------------------#
  386.   # * GOLD_DROP_ICON
  387.   #--------------------------------------------------------------------------#
  388.   # This is the icon that is used for gold drops
  389.   #--------------------------------------------------------------------------#
  390.     GOLD_DROP_ICON = 147
  391.    
  392.   #--------------------------------------------------------------------------#
  393.   # * DROP_SCATTER_DISTANCE
  394.   #--------------------------------------------------------------------------#
  395.   # This is how far a drop can be placed from its origin
  396.   #--------------------------------------------------------------------------#    
  397.     DROP_SCATTER_DISTANCE = 3
  398.    
  399.   #--------------------------------------------------------------------------#
  400.   # * ITEM_FADE_TIME
  401.   #--------------------------------------------------------------------------#
  402.   # How long, in frames until an item drop fades out
  403.   #--------------------------------------------------------------------------#    
  404.     ITEM_FADE_TIME = 480
  405.    
  406.   #--------------------------------------------------------------------------#
  407.   # * GOLD_FADE_TIME
  408.   #--------------------------------------------------------------------------#
  409.   # How long, in frames until an gold drop fades out
  410.   #--------------------------------------------------------------------------#    
  411.     GOLD_FADE_TIME = 640
  412.    
  413.   #--------------------------------------------------------------------------#
  414.   # * DROP_FADE_THRESHOLD
  415.   #--------------------------------------------------------------------------#
  416.   # When this frame is reached the drop will begin to fade out
  417.   #--------------------------------------------------------------------------#  
  418.     DROP_FADE_THRESHOLD = 60
  419.   #--------------------------------------------------------------------------#
  420.   # * USE_SHIFT_SYSTEM (YGG_ShiftSystem)
  421.   #--------------------------------------------------------------------------#
  422.   # Unlike its predecessors, 1.6 has a built-in Shift System
  423.   # This simply allows the quick changing between characters
  424.   #--------------------------------------------------------------------------#
  425.     USE_SHIFT_SYSTEM = false
  426.  
  427.   #--------------------------------------------------------------------------#
  428.   # * HUD
  429.   #--------------------------------------------------------------------------#
  430.   # Options for HUD
  431.   #--------------------------------------------------------------------------#
  432.     USE_HUD = true
  433.     HUD_SWITCH = 1
  434.    
  435.     HUD_POSITION_PROCS = {
  436.     # :symbol     => Proc.new { [   x,   y,   z] },
  437.       :main       => Proc.new { [ -12, Graphics.height-48, 1000] },
  438.       :back       => Proc.new { [   0,   0,   0] },
  439.       :hp_bar     => Proc.new { [ 232,  12,   3] },
  440.       :mp_bar     => Proc.new { [ 232,  28,   3] },
  441.       :exp_bar    => Proc.new { [  40,   9,   3] },
  442.       :shift_bar  => Proc.new { [ 384,   9,   3] },
  443.       :charge_bar => Proc.new { [ 472,   9,   3] },
  444.       :sprite     => Proc.new { [ 196,   8,   3] },
  445.       :skill_icon => Proc.new { |i| [  36 + i * 32,  16,   3] },
  446.       :item_icon  => Proc.new { |i| [ 376 + i * 32,  16,   3] }
  447.     }
  448.  
  449.   #--------------------------------------------------------------------------#
  450.   # * HP/MP Bars
  451.   #--------------------------------------------------------------------------#
  452.   # Options for HP/MP Bars
  453.   #--------------------------------------------------------------------------#
  454.     USE_STAT_BARS = true # // Use Bars?
  455.     USE_HPBAR     = true  
  456.     USE_MPBAR     = false
  457.  
  458.   #--------------------------------------------------------------------------#
  459.   # * DROPS_WINDOW (YGG_DropsWindow)
  460.   #--------------------------------------------------------------------------#
  461.   # Options for drops window
  462.   #--------------------------------------------------------------------------#
  463.     USE_DROPS_WINDOW    = true
  464.     # //                  [ x, y, z, width ]
  465.     DROPS_WINDOW_SIZE   = [ 544-164, 416-72, 200, 160 ]
  466.     DROPS_WINDOW_SWITCH = 1 # // Currently Linked with Hud
  467.    
  468.   #--------------------------------------------------------------------------#
  469.   # * DROPS_SFX (Special Thanks to Nicke (Niclas) for the idea)
  470.   #--------------------------------------------------------------------------#
  471.   # Options for SFX when a drop is taken up
  472.   # (You can override this using: <pickup sfx: filename, vol, pitch>)
  473.   #--------------------------------------------------------------------------#
  474.   # // Set any of these to nil to disable it                              // #
  475.     SOUND_MONEY = RPG::SE.new( "SYS-Shop002", 60, 100 )    # // Sound effect for acquiring money.
  476.     SOUND_ITEM  = RPG::SE.new( "XINFX-Pickup02", 50, 100 ) # // Sound effect for acquiring items.
  477.    
  478.   #--------------------------------------------------------------------------#
  479.   # * USE_LEVEL_UP_WINDOW (YGG_LevelUpWindow)
  480.   #--------------------------------------------------------------------------#
  481.   # 0 - No Window (OFF), 1 - Small Strip, 2 - Stop Frame Full Info
  482.   #--------------------------------------------------------------------------#
  483.     USE_LEVEL_UP_WINDOW = 0
  484.    
  485.   #--------------------------------------------------------------------------#
  486.   # * FULL_INTEGRATION
  487.   #--------------------------------------------------------------------------#
  488.   # Allow Yggdrasil to overwrite many core methods, to optimize is performance
  489.   #--------------------------------------------------------------------------#
  490.   # // Enabling this may cause normal battle operations to malfunction
  491.   # // This option is reccommend for a strict YGG game
  492.   #--------------------------------------------------------------------------#
  493.     FULL_INTEGRATION = true
  494.    
  495. # oo========================================================================oo #    
  496. # // Actions \\                                                             // #
  497. # oo========================================================================oo #
  498.   ACTION_LIST = {}
  499. # oo========================================================================oo #    
  500. # // Default Actions \\ DO NOT MESS WITH THESE                              // #
  501. # oo========================================================================oo #
  502.  
  503. # oo========================================================================oo #    
  504.   ACTION_LIST["HIT_ANIM"] = [
  505.     ["TARGET"       , ["AFFECTED"]                    ],
  506.     ["ANIMATION"    , [171, "TARGETS", "WILD"]        ]
  507.   ]
  508. # // Normal Attack # For Default
  509.   ACTION_LIST["NULL_ACTION"] = []
  510.  
  511.   ACTION_LIST["NORMAL_ATTACK"] = [
  512.     ["RANGE"        , ["ADD", 0, 1]                   ],
  513.     ["TARGET"       , ["RANGE"]                       ],
  514.     ["SUBTARGET"    , ["ALLIES"]                      ],
  515.     ["ANIMATION"    , ["ATTACK", "POS", "WILD", 0, 1] ],
  516.     ["ATTACK EFFECT", ["USER", "TARGETS"]             ],
  517.     ["ACTION"       , ["HIT_ANIM"]                    ]
  518.   ]
  519.  
  520.   ACTION_LIST["GUARD_ACTION"] = [
  521.     ["ANIMATION"    , [85, "USER", "WILD"]            ],
  522.     ["GUARD"    , [3]                                 ], # // Set Guard for 3 frames
  523.   ]
  524.  
  525.   ACTION_LIST["ESCAPE_ACTION"] = [
  526.   ]
  527.  
  528.   ACTION_LIST["WAIT_ACTION"] = [
  529.     ["PARENT WAIT"  , [20]                            ]
  530.   ]
  531.  
  532. # oo========================================================================oo #    
  533. # // Normal Attack # For Enemies  
  534.   ACTION_LIST["NULL_ACTION_EN"] = [] # // Unused D:
  535.  
  536.   ACTION_LIST["NORMAL_ATTACK_EN"] = [
  537.     ["RANGE"        , ["ADD", 0, 1]                   ],
  538.     ["TARGET"       , ["RANGE"]                       ],
  539.     ["SUBTARGET"    , ["ALLIES"]                      ],
  540.     ["ANIMATION"    , ["ATTACK", "POS", "WILD", 0, 1] ],
  541.     ["ATTACK EFFECT", ["USER", "TARGETS"]             ],
  542.     ["ACTION"       , ["HIT_ANIM"]                    ]
  543.   ]
  544.  
  545.   ACTION_LIST["GUARD_ACTION_EN"] = [
  546.     ["GUARD"    , [3]                                 ], # // Set Guard for 3 frames
  547.   ]
  548.  
  549.   ACTION_LIST["ESCAPE_ACTION_EN"] = [
  550.   ]
  551.  
  552.   ACTION_LIST["WAIT_ACTION_EN"] = [
  553.     ["PARENT WAIT"  , [20]                            ]
  554.   ]
  555. # oo========================================================================oo #    
  556. # // Skill Scopes                                                           // #
  557.   # // None Scope Skill
  558.   ACTION_LIST["NORMAL_OBJ0"] = [
  559.     ["TARGET"      , ["USER"]                      ],
  560.     ["ANIMATION"   , ["OBJ", "POS", "WILD", 0, 0]  ],
  561.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  562.   ]
  563.  
  564.   # // User Skill
  565.   ACTION_LIST["NORMAL_OBJ1"] = [
  566.     ["TARGET"      , ["USER"]                      ],
  567.     ["ANIMATION"   , ["OBJ", "POS", "WILD", 0, 0]  ],
  568.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  569.   ]
  570.  
  571.   # // Enemy Skill Single
  572.   ACTION_LIST["NORMAL_OBJ2_1"] = [
  573.     ["RANGE"       , ["ADD", 0, 1]                 ],
  574.     ["TARGET"      , ["RANGE"]                     ],
  575.     ["SUBTARGET"   , ["ALLIES"]                    ],
  576.     ["ANIMATION"   , ["OBJ", "POS", "WILD", 0, 1]  ],
  577.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  578.   ]
  579.  
  580.   # // Enemy Skill Dual
  581.   ACTION_LIST["NORMAL_OBJ2_2"] = [
  582.     ["RANGE"       , ["ADD", 0, 1]                 ],
  583.     ["TARGET"      , ["RANGE"]                     ],
  584.     ["SUBTARGET"   , ["ALLIES"]                    ],
  585.     ["ANIMATION"   , ["OBJ", "POS", "WILD", 0, 1]  ],
  586.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  587.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  588.   ]
  589.  
  590.   # // Enemy Skill Triple
  591.   ACTION_LIST["NORMAL_OBJ2_3"] = [
  592.     ["RANGE"       , ["ADD", 0, 1]                 ],
  593.     ["TARGET"      , ["RANGE"]                     ],
  594.     ["SUBTARGET"   , ["ALLIES"]                    ],
  595.     ["ANIMATION"   , ["OBJ", "POS", "WILD", 0, 1]  ],
  596.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  597.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  598.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  599.   ]
  600.  
  601.   # // Enemy Skill Random 1
  602.   ACTION_LIST["NORMAL_OBJ2_R1"] = [
  603.     ["TARGET"      , ["SCREEN"]                    ],
  604.     ["SUBTARGET"   , ["ALLIES"]                    ],
  605.     ["TARGET"      , ["RANDTARGET"]                ],
  606.     ["ANIMATION"   , ["OBJ", "TARGET", "WILD"]     ],
  607.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  608.   ]
  609.  
  610.   # // Enemy Skill Random 2
  611.   ACTION_LIST["NORMAL_OBJ2_R2"] = [
  612.     ["ACTION", ["NORMAL_OBJ2_R1"] ],
  613.     ["ACTION", ["NORMAL_OBJ2_R1"] ]
  614.   ]
  615.  
  616.   # // Enemy Skill Random 3
  617.   ACTION_LIST["NORMAL_OBJ2_R3"] = [
  618.     ["ACTION", ["NORMAL_OBJ2_R1"] ],
  619.     ["ACTION", ["NORMAL_OBJ2_R1"] ],
  620.     ["ACTION", ["NORMAL_OBJ2_R1"] ]
  621.   ]
  622.  
  623.   # // Ally Skill
  624.   ACTION_LIST["NORMAL_OBJ3_1"] = [
  625.     ["RANGE"       , ["ADD", 0, 1]                 ],
  626.     ["TARGET"      , ["RANGE"]                     ],
  627.     ["SUBTARGET"   , ["ENEMIES"]                   ],
  628.     ["ANIMATION"   , ["OBJ", "POS", "WILD", 0, 1]  ],
  629.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  630.   ]
  631.  
  632.   # // Ally Skill Dual
  633.   ACTION_LIST["NORMAL_OBJ3_2"] = [
  634.     ["RANGE"       , ["ADD", 0, 1]                 ],
  635.     ["TARGET"      , ["RANGE"]                     ],
  636.     ["SUBTARGET"   , ["ENEMIES"]                   ],
  637.     ["ANIMATION"   , ["OBJ", "POS", "WILD", 0, 1]  ],
  638.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  639.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  640.   ]
  641.  
  642.   # // Ally Skill Triple
  643.   ACTION_LIST["NORMAL_OBJ3_3"] = [
  644.     ["RANGE"       , ["ADD", 0, 1]                 ],
  645.     ["TARGET"      , ["RANGE"]                     ],
  646.     ["SUBTARGET"   , ["ENEMIES"]                   ],
  647.     ["ANIMATION"   , ["OBJ", "POS", "WILD", 0, 1]  ],
  648.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  649.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  650.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  651.   ]
  652.  
  653.   # // Ally Skill Random 1
  654.   ACTION_LIST["NORMAL_OBJ3_R1"] = [
  655.     ["TARGET"      , ["SCREEN"]                    ],
  656.     ["SUBTARGET"   , ["ENEMIES"]                   ],
  657.     ["TARGET"      , ["RANDTARGET"]                ],
  658.     ["ANIMATION"   , ["OBJ", "TARGET", "WILD"]     ],
  659.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  660.   ]
  661.  
  662.   # // Ally Obj Random 2
  663.   ACTION_LIST["NORMAL_OBJ3_R2"] = [
  664.     ["ACTION", ["NORMAL_OBJ3_R1"] ],
  665.     ["ACTION", ["NORMAL_OBJ3_R1"] ],
  666.   ]
  667.  
  668.   # // Enemy Obj Random 3
  669.   ACTION_LIST["NORMAL_OBJ3_R3"] = [
  670.     ["ACTION", ["NORMAL_OBJ3_R1"] ],
  671.     ["ACTION", ["NORMAL_OBJ3_R1"] ],
  672.     ["ACTION", ["NORMAL_OBJ3_R1"] ],
  673.   ]
  674.  
  675.   # // All Enemies
  676.   ACTION_LIST["NORMAL_OBJ4"] = [
  677.     ["TARGET"      , ["SCREEN"]                    ],
  678.     ["SUBTARGET"   , ["ALLIES"]                    ],
  679.     ["ANIMATION"   , ["OBJ", "TARGETS", "WILD"]    ],
  680.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  681.   ]
  682.  
  683.   # // All Allies
  684.   ACTION_LIST["NORMAL_OBJ5"] = [
  685.     ["TARGET"      , ["SCREEN"]                    ],
  686.     ["SUBTARGET"   , ["ENEMIES"]                   ],
  687.     ["ANIMATION"   , ["OBJ", "TARGETS", "WILD"]    ],
  688.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  689.   ]
  690.  
  691.   # // Target Enemy Skill Single
  692.   ACTION_LIST["NORMAL_OBJ2_T1"] = [
  693.     ["TARGET"      , ["SCREEN"]                    ],
  694.     ["SUBTARGET"   , ["ALLIES"]                    ],
  695.     ["TARGET SELECT",[1, "TARGETS"]                ],
  696.     ["ANIMATION"   , ["OBJ", "TARGETS", "WILD"]    ],
  697.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  698.   ]
  699.  
  700.   # // Target Enemy Skill Dual
  701.   ACTION_LIST["NORMAL_OBJ2_T2"] = [
  702.     ["TARGET"      , ["SCREEN"]                    ],
  703.     ["SUBTARGET"   , ["ALLIES"]                    ],
  704.     ["TARGET SELECT",[1, "TARGETS"]                ],
  705.     ["ANIMATION"   , ["OBJ", "TARGETS", "WILD"]    ],
  706.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  707.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  708.   ]
  709.  
  710.   # // Target Enemy Skill Triple
  711.   ACTION_LIST["NORMAL_OBJ2_T3"] = [
  712.     ["TARGET"      , ["SCREEN"]                    ],
  713.     ["SUBTARGET"   , ["ALLIES"]                    ],
  714.     ["TARGET SELECT",[1, "TARGETS"]                ],
  715.     ["ANIMATION"   , ["OBJ", "TARGETS", "WILD"]    ],
  716.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  717.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  718.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  719.   ]
  720.  
  721.   # // Target Ally Skill
  722.   ACTION_LIST["NORMAL_OBJ3_T1"] = [
  723.     ["TARGET"      , ["SCREEN"]                    ],
  724.     ["SUBTARGET"   , ["ENEMIES"]                   ],
  725.     ["TARGET SELECT",[1, "TARGETS"]                ],
  726.     ["ANIMATION"   , ["OBJ", "TARGETS", "WILD"]    ],
  727.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  728.   ]
  729.  
  730.   # // Target Ally Skill Dual
  731.   ACTION_LIST["NORMAL_OBJ3_T2"] = [
  732.     ["TARGET"      , ["SCREEN"]                    ],
  733.     ["SUBTARGET"   , ["ENEMIES"]                   ],
  734.     ["TARGET SELECT",[1, "TARGETS"]                ],
  735.     ["ANIMATION"   , ["OBJ", "TARGETS", "WILD"]    ],
  736.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  737.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  738.   ]
  739.  
  740.   # // Target Ally Skill Triple
  741.   ACTION_LIST["NORMAL_OBJ3_T3"] = [
  742.     ["TARGET"      , ["SCREEN"]                    ],
  743.     ["SUBTARGET"   , ["ENEMIES"]                   ],
  744.     ["TARGET SELECT",[1, "TARGETS"]                ],
  745.     ["ANIMATION"   , ["OBJ", "TARGETS", "WILD"]    ],
  746.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  747.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  748.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  749.   ]
  750.  
  751.   # // Breath all targets in range
  752.   ACTION_LIST["BREATH_ATTACK1"] = [
  753.     ["RANGE"       , ["CREATE", 3, 0, 3, 2]        ], # // Point Range downward
  754.     ["TARGET"      , ["RANGE"]                     ], # // Get all targets within range
  755.     ["ANIMATION"   , ["OBJ", "POS", 0, 1]          ], # // Show animation infront
  756.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ], # // Object Damage
  757.   ]
  758.  
  759. # oo========================================================================oo #    
  760. # \\ End Default Actions //                                                 // #
  761. # oo========================================================================oo #
  762. #==============================================================================#
  763. #                           End Customization
  764. #------------------------------------------------------------------------------#
  765. #==============================================================================#  
  766. end
  767. #==============================================================================#
  768. # ** YGG # // Forward Declarations
  769. #==============================================================================#
  770. module YGG
  771. #==============================================================================#
  772. # ** Handlers
  773. #==============================================================================#
  774.   module Handlers   ; end
  775. #==============================================================================#
  776. # ** Containers
  777. #==============================================================================#    
  778.   module Containers ; end
  779. #==============================================================================#
  780. # ** MixIns
  781. #==============================================================================#    
  782.   module MixIns     ; end
  783. #==============================================================================#
  784. # ** Objects
  785. #==============================================================================#        
  786.   module Objects    ; end      
  787. #==============================================================================#
  788. # ** Scenes
  789. #==============================================================================#            
  790.   module Scenes     ; end  
  791. #==============================================================================#
  792. # ** Sprites
  793. #==============================================================================#        
  794.   module Sprites    ; end  
  795. #==============================================================================#
  796. # ** REGEXP
  797. #==============================================================================#            
  798.   module REGEXP     ; end
  799. #==============================================================================#
  800. # ** Windows
  801. #==============================================================================#                
  802.   module Windows    ; end  
  803. #==============================================================================#
  804. # ** Pos
  805. #==============================================================================#                
  806.   class Pos ; end
  807. #==============================================================================#
  808. # ** Handlers::Screen
  809. #==============================================================================#    
  810.   class Handlers::Screen < Pos ; end
  811. #==============================================================================#
  812. # ** Objects::Projectiles
  813. #==============================================================================#      
  814.   module Objects::Projectiles ; end
  815. #==============================================================================#
  816. # ** Random
  817. #==============================================================================#
  818.   module Random
  819.    
  820.   #--------------------------------------------------------------------------#
  821.   # * new-method :min_max
  822.   #--------------------------------------------------------------------------#      
  823.     def self.min_max( min, max )
  824.       return min + rand( max - min )
  825.     end
  826.    
  827.   #--------------------------------------------------------------------------#
  828.   # * new-method :variation
  829.   #--------------------------------------------------------------------------#        
  830.     def self.variation( value, percent )
  831.       new_value = rand(Integer(value * percent / 100.0))
  832.       new_value = value + (rand(2) == 0 ? new_value : -new_value)
  833.       return new_value
  834.     end
  835.    
  836.   end
  837. end    
  838.  
  839. #==============================================================================#  
  840. # ** Color
  841. #==============================================================================#
  842. class Color
  843.  
  844.   #--------------------------------------------------------------------------#
  845.   # * overwrite-method :to_a
  846.   #--------------------------------------------------------------------------#  
  847.   def to_a()
  848.     return self.red, self.green, self.blue, self.alpha
  849.   end
  850.  
  851. end
  852.  
  853. #==============================================================================#  
  854. # ** YGG
  855. #==============================================================================#
  856. module YGG
  857.  
  858.   #--------------------------------------------------------------------------#
  859.   # * new-method :__dump_font
  860.   #--------------------------------------------------------------------------#  
  861.   def self.__dump_font( font )
  862.     color = Color.new( 0, 0, 0 )
  863.     color.set( *font.color.to_a )
  864.     shad_color = Color.new( 0, 0, 0 )
  865.     shad_color.set( *font.shadow_color.to_a )
  866.     return Marshal.dump(
  867.     {
  868.       :color        => color,
  869.       :shad_color   => shad_color,
  870.       :name         => font.name.to_a.clone,
  871.       :size         => font.size.to_i,
  872.       :bold         => font.bold,
  873.       :italic       => font.italic,
  874.       :shadow       => font.shadow,
  875.     } )
  876.   end
  877.  
  878. end  
  879.  
  880. #==============================================================================#  
  881. # ** Font
  882. #==============================================================================#
  883. class Font
  884.  
  885.   #--------------------------------------------------------------------------#
  886.   # * Public Instance Variable(s)
  887.   #--------------------------------------------------------------------------#    
  888.   attr_writer :shadow_color
  889.  
  890.   #--------------------------------------------------------------------------#
  891.   # * new-method :shadow_color
  892.   #--------------------------------------------------------------------------#  
  893.   def shadow_color()
  894.     @shadow_color ||= Color.new( 0, 0, 0 )
  895.     return @shadow_color
  896.   end
  897.  
  898.   #--------------------------------------------------------------------------#
  899.   # * new-method :_dump
  900.   #--------------------------------------------------------------------------#  
  901.   def _dump( depth )
  902.     return YGG.__dump_font( self )
  903.   end
  904.  
  905.   #--------------------------------------------------------------------------#
  906.   # * new-class-method :_load
  907.   #--------------------------------------------------------------------------#
  908.   def self._load( str )
  909.     settings          = Marshal.load( str )
  910.     font              = ::Font.new()
  911.     font.color        = settings[:color]
  912.     font.shadow_color = settings[:shad_color]
  913.     font.name         = settings[:name]
  914.     font.size         = settings[:size]
  915.     font.bold         = settings[:bold]
  916.     font.italic       = settings[:italic]
  917.     font.shadow       = settings[:shadow]
  918.     return font
  919.   end
  920.  
  921. end
  922.  
  923. #==============================================================================#  
  924. # ** Input # // DONT MESS WITH THIS
  925. #==============================================================================#
  926. module Input
  927.   #--------------------------------------------------------------------------#
  928.   # * Constants - Created by OriginalWij and Yanfly
  929.   #--------------------------------------------------------------------------#
  930.   LETTERS = {}        
  931.   LETTERS['A'] = 65; LETTERS['B'] = 66; LETTERS['C'] = 67; LETTERS['D'] = 68
  932.   LETTERS['E'] = 69; LETTERS['F'] = 70; LETTERS['G'] = 71; LETTERS['H'] = 72
  933.   LETTERS['I'] = 73; LETTERS['J'] = 74; LETTERS['K'] = 75; LETTERS['L'] = 76
  934.   LETTERS['M'] = 77; LETTERS['N'] = 78; LETTERS['O'] = 79; LETTERS['P'] = 80
  935.   LETTERS['Q'] = 81; LETTERS['R'] = 82; LETTERS['S'] = 83; LETTERS['T'] = 84
  936.   LETTERS['U'] = 85; LETTERS['V'] = 86; LETTERS['W'] = 87; LETTERS['X'] = 88
  937.   LETTERS['Y'] = 89; LETTERS['Z'] = 90
  938.   NUMBERS = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57]
  939.   NUMPAD = [96, 97, 98, 99, 100, 101, 102, 103, 104, 105]
  940.   BACK   = 138; ENTER  = 143; SPACE  = 32;  SCOLON = 186; ESC    = 157
  941.   QUOTE  = 222; EQUALS = 187; COMMA  = 188; USCORE = 189; PERIOD = 190
  942.   SLASH  = 191; LBRACE = 219; RBRACE = 221; BSLASH = 220; TILDE  = 192
  943.   F10    = 121; F11    = 122; CAPS   = 20;  NMUL   = 106; NPLUS  = 107
  944.   NSEP   = 108; NMINUS = 109; NDECI  = 110; NDIV   = 111; Extras =
  945.   [USCORE, EQUALS, LBRACE, RBRACE, BSLASH, SCOLON, QUOTE, COMMA, PERIOD, SLASH,
  946.    NMUL, NPLUS, NSEP, NMINUS, NDECI, NDIV]
  947. end
  948.  
  949. #==============================================================================#
  950. # ** YGG::MixIns::Player (YGG_PlayerInputConfig)
  951. #==============================================================================#
  952. module YGG::MixIns::Player
  953.  
  954.   #--------------------------------------------------------------------------#
  955.   # * new-method :get_obj_actions
  956.   #--------------------------------------------------------------------------#  
  957.   def get_obj_actions( obj, id )
  958.     return [],[] if obj.nil?()
  959.     return obj.ygg_actions[id].to_a(), obj.ygg_pre_actions[id].to_a()
  960.   end
  961.  
  962.   #--------------------------------------------------------------------------#
  963.   # * new-method :ygg_attack_input
  964.   #--------------------------------------------------------------------------#
  965.   def ygg_attack_input()
  966.     #return unless ygg_can_attack?()
  967.     return if $game_map.interpreter.running?()
  968.     return if ygg_battler.nil?()
  969.     if @guard_time > 0
  970.       @guard_time += 1 if Input.press?( Input::LETTERS["D"] )
  971.       return
  972.     end  
  973.     return if @action_handle.busy?()
  974.     acthand_ret = ygg_attack_input1()              # // ASD Input
  975.     acthand_ret = ygg_attack_input2( acthand_ret ) # // Skill Input 1..5
  976.     ygg_attack_input3( acthand_ret )               # // Item Input 6..9 and 0
  977.   end
  978.  
  979.   #--------------------------------------------------------------------------#
  980.   # * new-method :ygg_attack_input1
  981.   #--------------------------------------------------------------------------#
  982.   def ygg_attack_input1()
  983.     act, pact = nil, nil
  984.     obj = nil
  985.     if Input.trigger?( Input::LETTERS["A"] )
  986.       return 0 unless ygg_battler.ygg_can_attack?()
  987.       obj = ygg_battler.weapons[0]
  988.       act, pact = *get_obj_actions( obj, 1 )
  989.     elsif Input.trigger?( Input::LETTERS["S"] ) && ygg_battler.two_swords_style  
  990.       return 0 unless ygg_battler.ygg_can_attack?()
  991.       obj = ygg_battler.weapons[1]
  992.       act, pact = *get_obj_actions( obj, 1 )
  993.     elsif Input.press?( Input::LETTERS["D"] ) && !ygg_battler.two_swords_style  
  994.       return 0 unless ygg_battler.ygg_can_attack?()
  995.       obj = ygg_battler.armors[0]
  996.       act, pact = *get_obj_actions( obj, 0 )
  997.     end  
  998.     return 0 if act.nil?() || pact.nil?()
  999.     return 0 if act.empty?() && pact.empty?()
  1000.     if pact.empty?()
  1001.       @action_handle.setup( act )
  1002.     else  
  1003.       @action_handle.list_stack << act
  1004.       @action_handle.setup( pact )
  1005.     end  
  1006.     @action_handle.execute( self )
  1007.     ygg_battler.cooldown += obj.user_charge_cap
  1008.     return 1
  1009.   end
  1010.  
  1011.   #--------------------------------------------------------------------------#
  1012.   # * new-method :ygg_attack_input2
  1013.   #--------------------------------------------------------------------------#
  1014.   def ygg_attack_input2( acthand_ret )
  1015.     for i in 1..5
  1016.       act, pact, obj = nil, nil, nil
  1017.       if Input.trigger?( Input::NUMBERS[i] )
  1018.         slot_id = i-1
  1019.         obj = ygg_battler.skill_slot( slot_id )
  1020.         next unless ygg_battler.ygg_skill_can_use?( obj )
  1021.         act, pact = *get_obj_actions( obj, 0 )
  1022.       end
  1023.       next if act.nil?() || pact.nil?() || obj.nil?()
  1024.       next if act.empty?() && pact.empty?()
  1025.       next unless skill_can_use?( obj )
  1026.       if pact.empty?()
  1027.         hnd = ::YGG::Handlers::Action.new( self, [] ) ; hnd.setup( act )
  1028.         hnd.execute( self, [], { :skill_id => obj.id } )
  1029.         @free_act_handles << hnd
  1030.       else  
  1031.         next if acthand_ret == 1
  1032.         @action_handle.list_stack << act
  1033.         @action_handle.setup( pact )
  1034.         @action_handle.execute( self, [], { :skill_id => obj.id } )
  1035.         acthand_ret = 1
  1036.       end  
  1037.       ygg_battler.get_skill_handle( obj.id ).reset_time()
  1038.       ygg_battler.cooldown += obj.user_charge_cap
  1039.       ygg_battler.ygg_use_skill( obj )
  1040.     end  
  1041.     return acthand_ret
  1042.   end
  1043.  
  1044.   #--------------------------------------------------------------------------#
  1045.   # * new-method :ygg_attack_input3
  1046.   #--------------------------------------------------------------------------#
  1047.   def ygg_attack_input3( acthand_ret )
  1048.     for i in (6..9).to_a+[0]
  1049.       act, pact, obj = nil, nil, nil
  1050.       if Input.trigger?( Input::NUMBERS[i] )
  1051.         slot_id = i==0 ? 10-6 : i-6
  1052.         obj = ygg_battler.item_slot( slot_id )
  1053.         next unless ygg_battler.ygg_item_can_use?( obj )
  1054.         act, pact = *get_obj_actions( obj, 0 )
  1055.       end
  1056.       next if act.nil?() || pact.nil?() || obj.nil?()
  1057.       next if act.empty?() && pact.empty?()
  1058.       next unless item_can_use?( obj )
  1059.       if pact.empty?()
  1060.         hnd = ::YGG::Handlers::Action.new( self, [] ) ; hnd.setup( act )
  1061.         hnd.execute( self, [], { :item_id => obj.id } )
  1062.         @free_act_handles << hnd
  1063.       else  
  1064.         next if acthand_ret == 1
  1065.         @action_handle.list_stack << act
  1066.         @action_handle.setup( pact )
  1067.         @action_handle.execute( self, [], { :item_id => obj.id } )
  1068.         acthand_ret = 1
  1069.       end  
  1070.       ygg_battler.get_item_handle( obj.id ).reset_time()
  1071.       ygg_battler.cooldown += obj.user_charge_cap
  1072.       ygg_battler.ygg_use_item( obj )
  1073.     end  
  1074.     return acthand_ret
  1075.   end
  1076.  
  1077.   #--------------------------------------------------------------------------#
  1078.   # * new-method :skill_can_use?
  1079.   #--------------------------------------------------------------------------#  
  1080.   def skill_can_use?( obj )
  1081.     return false if obj.nil?()
  1082.     return false if ygg_battler.nil?()
  1083.     return ygg_battler.skill_can_use?( obj )
  1084.   end
  1085.  
  1086.   #--------------------------------------------------------------------------#
  1087.   # * new-method :item_can_use?
  1088.   #--------------------------------------------------------------------------#  
  1089.   def item_can_use?( obj )
  1090.     return false if obj.nil?()
  1091.     return false if ygg_battler.nil?()
  1092.     return $game_party.item_can_use?( obj )
  1093.   end
  1094.  
  1095. end  
  1096.  
  1097. # // (YGG_AIEngine_Setup)
  1098. #==============================================================================#
  1099. # ** YGG::Handlers::AIEngines
  1100. #==============================================================================#
  1101. module YGG::Handlers::AIEngines
  1102. #==============================================================================#
  1103. # ** Base (Forward Declaration)
  1104. #==============================================================================#  
  1105.   class Base           ; end
  1106. #==============================================================================#
  1107. # ** Default (Forward Declaration)
  1108. #==============================================================================#      
  1109.   class Default < Base ; end
  1110. #==============================================================================#
  1111. # ** Guard (Forward Declaration)
  1112. #==============================================================================#      
  1113.   class Guard < Base   ; end
  1114. #==============================================================================#
  1115. # ** Wall (Forward Declaration)
  1116. #==============================================================================#      
  1117.   class Wall < Base    ; end  
  1118. #==============================================================================#
  1119. # ** ImmortalVarBoss (Forward Declaration)
  1120. #==============================================================================#          
  1121.   class ImmortalVarBoss < Base  ; end
  1122.    
  1123.   #--------------------------------------------------------------------------#
  1124.   # * ENGINES
  1125.   #--------------------------------------------------------------------------#
  1126.   # This hash contains references to the Engine's Class, NOT AN INSTANCE
  1127.   # of the class.
  1128.   #--------------------------------------------------------------------------#  
  1129.   ENGINES = {
  1130.     # // Default AI that uses the Game_Battler's make_action
  1131.     # // to attack
  1132.     "default" => Default,         # // Default (Make Action) AI
  1133.     # // An AI that only attacks/moves/acts when an enemy enters its field
  1134.     "guard"   => Guard,           # // Specialized AI
  1135.     # // An AI that does nothing, but its HP slowly depletes
  1136.     "wall"    => Wall,            
  1137.     # // An invincible boss, thats hp is controlled by a variable
  1138.     # // This is a 2nd level subclass
  1139.     "ivboss"  => ImmortalVarBoss,
  1140.   }
  1141.  
  1142. end
  1143.  
  1144. #==============================================================================#
  1145. # ** YGG::AI_ENGINES
  1146. #==============================================================================#
  1147. YGG::AI_ENGINES = YGG::Handlers::AIEngines::ENGINES
  1148.  
  1149. #==============================================================================#
  1150. # ** YGG::Handlers::AIEngines::Base
  1151. #==============================================================================#
  1152. class YGG::Handlers::AIEngines::Base
  1153.  
  1154.   #--------------------------------------------------------------------------#
  1155.   # * Public Instance Variables
  1156.   #--------------------------------------------------------------------------#  
  1157.   attr_accessor :parent
  1158.  
  1159.   #--------------------------------------------------------------------------#
  1160.   # * new-method :initialize
  1161.   #--------------------------------------------------------------------------#  
  1162.   def initialize( parent, setup_data={} )
  1163.     @parent = parent
  1164.     @update_time = 0
  1165.   end
  1166.  
  1167.   #--------------------------------------------------------------------------#
  1168.   # * new-method :pause
  1169.   #--------------------------------------------------------------------------#  
  1170.   def pause()
  1171.     @paused = true
  1172.   end
  1173.  
  1174.   #--------------------------------------------------------------------------#
  1175.   # * new-method :unpause
  1176.   #--------------------------------------------------------------------------#  
  1177.   def unpause()
  1178.     @paused = false
  1179.   end
  1180.  
  1181.   #--------------------------------------------------------------------------#
  1182.   # * new-method :update
  1183.   #--------------------------------------------------------------------------#  
  1184.   def update()
  1185.     return if @paused
  1186.     return if @parent.guard_time > 0
  1187.     @update_time = [@update_time - 1, 0].max
  1188.     ai_update() if @update_time == 0
  1189.   end
  1190.  
  1191. end  
  1192.  
  1193. #==============================================================================#
  1194. # ** YGG::Handlers::AIEngines::Default
  1195. #==============================================================================#
  1196. class YGG::Handlers::AIEngines::Default
  1197.  
  1198.   #--------------------------------------------------------------------------#
  1199.   # * super-method :initialize
  1200.   #--------------------------------------------------------------------------#
  1201.   def initialize( parent, setup_data={} )
  1202.     super( parent, setup_data )
  1203.     @update_time_cap = (setup_data["update_time"] || 90).to_i
  1204.   end
  1205.  
  1206.   #--------------------------------------------------------------------------#
  1207.   # * new-method :ai_update
  1208.   #--------------------------------------------------------------------------#  
  1209.   def ai_update()
  1210.     #return # // Remove this later
  1211.     return if @parent.ygg_battler.cooldown > 0
  1212.     return if @parent.ygg_battler.nil?()  
  1213.     @parent.ygg_battler.make_action()
  1214.     case @parent.ygg_battler.action.kind
  1215.     when 0 # // Basic
  1216.       case @parent.ygg_battler.action.basic
  1217.       when 0 # // Attack      
  1218.         @update_time = @update_time_cap / 3
  1219.         t = @parent.get_targets_nearby( 1, @parent.ygg_correct_target( "ENEMY" ) )
  1220.         return @update_time = @update_time_cap / 4 if t[0].nil?()
  1221.         @parent.turn_to_coord( t[0].x, t[0].y )
  1222.         @parent.action_handle.setup( @parent.ygg_battler.get_action_by_id( 0 ) )
  1223.         @parent.action_handle.execute( @parent )
  1224.       when 1 # // Guard
  1225.         @parent.action_handle.setup( @parent.ygg_battler.get_action_by_id( 1 ) )
  1226.         @parent.action_handle.execute( @parent )
  1227.       when 2 # // Escape
  1228.         @parent.action_handle.setup( @parent.ygg_battler.get_action_by_id( 2 ) )
  1229.         @parent.action_handle.execute( @parent )
  1230.       when 3 # // Wait  
  1231.         @parent.action_handle.setup( @parent.ygg_battler.get_action_by_id( 3 ) )
  1232.         @parent.action_handle.execute( @parent )
  1233.       end  
  1234.     when 1 # // Skill
  1235.       obj = $data_skills[@parent.ygg_battler.action.skill_id]
  1236.       next unless @parent.ygg_battler.ygg_skill_can_use?( obj )
  1237.       if obj.for_opponent?()
  1238.         t = @parent.get_targets_nearby( 1, @parent.ygg_correct_target( "ENEMY" ) )
  1239.       elsif obj.for_friend?()  
  1240.         t = @parent.get_targets_nearby( 1, @parent.ygg_correct_target( "ALLY" ) )
  1241.       else  
  1242.         t = @parent.get_targets_nearby( 1, "ALL" )
  1243.       end  
  1244.       return @update_time = @update_time_cap / 4 if t[0].nil?()
  1245.       @parent.ygg_battler.ygg_use_skill( obj )
  1246.       @parent.turn_to_coord( t[0].x, t[0].y )
  1247.       @parent.action_handle.setup( obj.ygg_actions[0] )
  1248.       @parent.action_handle.execute( @parent, [],
  1249.         { :skill_id=> @parent.ygg_battler.action.skill_id } )
  1250.     when 2 # // Item Enemies cant use items
  1251.     end  
  1252.     @update_time = @update_time_cap
  1253.   end
  1254.  
  1255. end  
  1256.  
  1257. #==============================================================================#
  1258. # ** YGG::Handlers::AIEngines::Guard
  1259. #==============================================================================#
  1260. class YGG::Handlers::AIEngines::Guard
  1261.  
  1262.   #--------------------------------------------------------------------------#
  1263.   # * super-method :initialize
  1264.   #--------------------------------------------------------------------------#  
  1265.   def initialize( parent, setup_data={} )
  1266.     sd = setup_data
  1267.     super( parent, sd )
  1268.     setup_area( sd )
  1269.     @update_time_cap = (sd["update_time"] || 90).to_i
  1270.     @__temprect = []
  1271.   end
  1272.  
  1273.   #--------------------------------------------------------------------------#
  1274.   # * new-method :setup_area
  1275.   #--------------------------------------------------------------------------#  
  1276.   def setup_area( setup_data={} )
  1277.     # // area_id (id)
  1278.     @prox = setup_data["proxy_area"].to_i == 1
  1279.     if !setup_data["area_id"].nil?()
  1280.       @guard_area = Rect.new( *$data_areas[setup_data["area_id"].to_i].rect.to_a )
  1281.     # // area_x (center), area_y (center), area_range (center, relative side)
  1282.     elsif !setup_data["area_range"].nil?()
  1283.       ax  = (!setup_data["area_x"].nil?()) ? setup_data["area_x"].to_i : 0
  1284.       ay  = (!setup_data["area_y"].nil?()) ? setup_data["area_y"].to_i : 0
  1285.       rng = (!setup_data["area_range"].nil?()) ? setup_data["area_range"].to_i : 0
  1286.       @guard_area = Rect.new( ax-rng, ay-rng, rng*2, rng*2 )
  1287.     # // area_x (left), area_y (left), area_width (left), area_height (left)    
  1288.     else  
  1289.       @guard_area = Rect.new(
  1290.         (!setup_data["area_x"].nil?()) ? setup_data["area_x"].to_i : 0,
  1291.         (!setup_data["area_y"].nil?()) ? setup_data["area_y"].to_i : 0,
  1292.         (!setup_data["area_width"].nil?()) ? setup_data["area_width"].to_i : 0,
  1293.         (!setup_data["area_height"].nil?()) ? setup_data["area_height"].to_i : 0
  1294.       )
  1295.     end
  1296.     @__guardarea_data ||= {} ; @__guardarea_data.clear()
  1297.     @__guardarea_data["proxy_area"]  = setup_data["proxy_area"]
  1298.     @__guardarea_data["area_id"]     = setup_data["area_id"]
  1299.     @__guardarea_data["area_range"]  = setup_data["area_range"]
  1300.     @__guardarea_data["area_x"]      = setup_data["area_x"]
  1301.     @__guardarea_data["area_y"]      = setup_data["area_y"]
  1302.     @__guardarea_data["area_width"]  = setup_data["area_width"]
  1303.     @__guardarea_data["area_height"] = setup_data["area_height"]
  1304.   end
  1305.  
  1306.   #--------------------------------------------------------------------------#
  1307.   # * new-method :reset_area
  1308.   #--------------------------------------------------------------------------#  
  1309.   def reset_area()
  1310.     setup_area( @__guardarea_data )
  1311.   end
  1312.  
  1313.   #--------------------------------------------------------------------------#
  1314.   # * new-method :ai_update
  1315.   #--------------------------------------------------------------------------#  
  1316.   def ai_update()
  1317.     return if @parent.ygg_battler.nil?()
  1318.     @__temprect = @guard_area.to_vector4_a()
  1319.     @__temprect[0] += @prox ? @parent.x : 0
  1320.     @__temprect[1] += @prox ? @parent.y : 0
  1321.     @__temprect[2] += @prox ? @parent.x : 0
  1322.     @__temprect[3] += @prox ? @parent.y : 0
  1323.     bats = $game_yggdrasil.battlers_range( *@__temprect )  
  1324.     unless bats.empty?()
  1325.       bats -= [@parent]
  1326.       unless bats.empty?()
  1327.         @parent.balloon_id = 1
  1328.         pro = Projectiles::Homing.new( @parent,
  1329.           ::YGG::PROJETILE_SETUP["ProjectileTest"].merge(
  1330.             { :target => bats[rand(bats.size)] } )
  1331.         )    
  1332.         pro.moveto( @parent.x, @parent.y ) ; pro.set_direction( @parent.direction )
  1333.         $game_yggdrasil.add_projectile( pro )
  1334.       end  
  1335.     end  
  1336.     @update_time = @update_time_cap
  1337.   end
  1338.  
  1339. end  
  1340.  
  1341. #==============================================================================#
  1342. # ** YGG::Handlers::AIEngines::Wall
  1343. #==============================================================================#
  1344. class YGG::Handlers::AIEngines::Wall
  1345.  
  1346.   #--------------------------------------------------------------------------#
  1347.   # * super-method :initialize
  1348.   #--------------------------------------------------------------------------#
  1349.   def initialize( parent, setup_data={} )
  1350.     super( parent, setup_data )
  1351.     @burn_time = @burn_cap = setup_data["burn_cap"].to_i
  1352.     @death_anim = (setup_data["death_anim"] || 0).to_i
  1353.   end
  1354.  
  1355.   #--------------------------------------------------------------------------#
  1356.   # * overwrite-method :ai_update
  1357.   #--------------------------------------------------------------------------#
  1358.   def ai_update()
  1359.     return if @parent.ygg_battler.nil?()
  1360.     @burn_time = [@burn_time - 1, 0].max
  1361.     @parent.ygg_battler.hp -= [Integer(@parent.ygg_battler.maxhp / @burn_cap.to_f), 1].max + [@burn_time, 0].min.abs
  1362.     @parent.ygg_engage.engage( 300 )
  1363.     if @parent.ygg_battler.dead?()
  1364.       @parent.ygg_anims << @death_anim if @death_anim > 0
  1365.       $game_map.remove_event( @parent.id )
  1366.     end  
  1367.   end
  1368.  
  1369. end  
  1370.  
  1371. #==============================================================================#
  1372. # ** YGG::Handlers::AIEngines::Wall
  1373. #==============================================================================#
  1374. class YGG::Handlers::AIEngines::ImmortalVarBoss
  1375.  
  1376.   #--------------------------------------------------------------------------#
  1377.   # * super-method :initialize
  1378.   #--------------------------------------------------------------------------#  
  1379.   def initialize( parent, setup_data )
  1380.     super( parent, setup_data )
  1381.     @hp_var    = setup_data["hp_var"].to_i
  1382.     @maxhp_var = setup_data["maxhp_var"].to_i
  1383.     @mp_var    = setup_data["mp_var"].nil?() ? nil : setup_data["mp_var"].to_i
  1384.     @maxmp_var = setup_data["maxmp_var"].nil?() ? nil : setup_data["maxmp_var"].to_i
  1385.     @parent.ygg_invincible = true
  1386.     set_variables()
  1387.   end
  1388.  
  1389.   #--------------------------------------------------------------------------#
  1390.   # * new-method :set_variables
  1391.   #--------------------------------------------------------------------------#  
  1392.   def set_variables()
  1393.     return if @parent.ygg_battler.nil?()
  1394.     $game_variables[@hp_var] = @parent.ygg_battler.hp
  1395.     $game_variables[@maxhp_var] = @parent.ygg_battler.maxhp
  1396.     $game_variables[@mp_var] = @parent.ygg_battler.mp unless @mp_var.nil?()
  1397.     $game_variables[@maxmp_var] = @parent.ygg_battler.maxmp unless @maxmp_var.nil?()
  1398.   end
  1399.  
  1400.   #--------------------------------------------------------------------------#
  1401.   # * overwrite-method :ai_update
  1402.   #--------------------------------------------------------------------------#  
  1403.   def ai_update()
  1404.     return if @parent.ygg_battler.nil?()
  1405.     @parent.ygg_battler.hp = $game_variables[@hp_var]
  1406.     $game_variables[@maxhp_var] = @parent.ygg_battler.maxhp
  1407.     $game_variables[@mp_var] = @parent.ygg_battler.mp unless @mp_var.nil?()
  1408.     $game_variables[@maxmp_var] = @parent.ygg_battler.maxmp unless @maxmp_var.nil?()
  1409.   end
  1410.  
  1411. end  
  1412.  
  1413. # // (YGG_Projectiles)
  1414. Projectiles = YGG::Objects::Projectiles
  1415. #==============================================================================#
  1416. # ** YGG::Objects::Projectiles::Base
  1417. #==============================================================================#
  1418. class YGG::Objects::Projectiles::Base < ::Game_Character
  1419.  
  1420.   #--------------------------------------------------------------------------#
  1421.   # * Public Instance Variables
  1422.   #--------------------------------------------------------------------------#  
  1423.   attr_accessor :character_name
  1424.   attr_accessor :character_index
  1425.  
  1426.   attr_accessor :through
  1427.   attr_accessor :action_name
  1428.   attr_accessor :direction
  1429.   attr_accessor :detonate_cap
  1430.   attr_accessor :move_cap
  1431.   attr_accessor :target_type
  1432.  
  1433.   attr_accessor :registered
  1434.   attr_accessor :action
  1435.  
  1436.   #--------------------------------------------------------------------------#
  1437.   # * new-method :initialize
  1438.   #--------------------------------------------------------------------------#  
  1439.   def initialize( parent, assignments )
  1440.     @parent          = parent
  1441.     super()
  1442.     # // Main Properties
  1443.     @character_name  = assignments[:character_name] || ""
  1444.     @character_index = (assignments[:character_index] || 0).to_i
  1445.     @through         = assignments[:through].nil?() ? true : assignments[:through]
  1446.     @move_speed      = (assignments[:move_speed] || 5).to_i
  1447.    
  1448.     # // Projectile Properties
  1449.     @detonate_cap    = (assignments[:detonate_cap] || -1).to_i
  1450.     @move_cap        = (assignments[:move_cap] || 5).to_i
  1451.     @target_type     = assignments[:target_type] || ""
  1452.    
  1453.     @terminated      = false
  1454.     @detonate_count  = 0
  1455.     @move_count      = 0
  1456.    
  1457.     @action_name     = assignments[:action_name] || ""
  1458.     @action          = assignments[:action] || ::YGG.get_action_list( @action_name )
  1459.    
  1460.     @affect_passage  = assignments[:affect_passage].nil?() ? false : assignments[:affect_passage]
  1461.    
  1462.     @registered      = false
  1463.    
  1464.     #assignments.keys.each { |key| self.send( key.to_s+"=", assignments[key] ) }
  1465.   end
  1466.  
  1467.   #--------------------------------------------------------------------------#
  1468.   # * new-method :trigger
  1469.   #--------------------------------------------------------------------------#
  1470.   def trigger() ; return nil ; end
  1471.  
  1472.   #--------------------------------------------------------------------------#
  1473.   # * new-method :hp_visible?
  1474.   #--------------------------------------------------------------------------#
  1475.   def hp_visible?() ; return false ; end
  1476.    
  1477.   #--------------------------------------------------------------------------#
  1478.   # * new-method :mp_visible?
  1479.   #--------------------------------------------------------------------------#
  1480.   def mp_visible?() ; return false ; end
  1481.  
  1482.   #--------------------------------------------------------------------------#
  1483.   # * new-method :__reload
  1484.   #--------------------------------------------------------------------------#
  1485.   def __reload()
  1486.     if registered?()
  1487.       pro_unregister() ; pro_register()
  1488.     end  
  1489.   end
  1490.  
  1491.   #--------------------------------------------------------------------------#
  1492.   # * new-method :registered?
  1493.   #--------------------------------------------------------------------------#
  1494.   def registered?()
  1495.     return @registered
  1496.   end
  1497.  
  1498.   #--------------------------------------------------------------------------#
  1499.   # * new-method :pro_register
  1500.   #--------------------------------------------------------------------------#
  1501.   def pro_register()
  1502.     @registered = true ; $game_yggdrasil.add_passage_obj( self ) if @affect_passage
  1503.   end
  1504.  
  1505.   #--------------------------------------------------------------------------#
  1506.   # * new-method :pro_unregister
  1507.   #--------------------------------------------------------------------------#
  1508.   def pro_unregister()
  1509.     @registered = false ; $game_yggdrasil.remove_passage_obj( self )
  1510.   end
  1511.  
  1512.   #--------------------------------------------------------------------------#
  1513.   # * new-method :ygg_register
  1514.   #--------------------------------------------------------------------------#
  1515.   def ygg_register()
  1516.     @ygg_registered = true
  1517.   end  
  1518.  
  1519.   #--------------------------------------------------------------------------#
  1520.   # * new-method :ygg_unregister
  1521.   #--------------------------------------------------------------------------#
  1522.   def ygg_unregister()
  1523.     $game_yggdrasil.remove_battler( self )
  1524.     @ygg_registered = false
  1525.   end
  1526.  
  1527.   #--------------------------------------------------------------------------#
  1528.   # * new-method :ygg_attacker
  1529.   #--------------------------------------------------------------------------#  
  1530.   def ygg_attacker()
  1531.     return @parent.ygg_attacker
  1532.   end
  1533.  
  1534.   #--------------------------------------------------------------------------#
  1535.   # * new-method :ygg_boss
  1536.   #--------------------------------------------------------------------------#  
  1537.   def ygg_boss?() ; return false ; end
  1538.  
  1539.   #--------------------------------------------------------------------------#
  1540.   # * new-method :ygg_ally?
  1541.   #--------------------------------------------------------------------------#  
  1542.   def ygg_ally?()
  1543.     return @parent.ygg_ally?()
  1544.   end
  1545.  
  1546.   #--------------------------------------------------------------------------#
  1547.   # * new-method :ygg_enemy?
  1548.   #--------------------------------------------------------------------------#  
  1549.   def ygg_enemy?()
  1550.     return @parent.ygg_enemy?()
  1551.   end
  1552.  
  1553.   #--------------------------------------------------------------------------#
  1554.   # * new-method :passable?
  1555.   #--------------------------------------------------------------------------#  
  1556.   def passable?( x, y )
  1557.     x = $game_map.round_x(x)                        
  1558.     y = $game_map.round_y(y)                        
  1559.     return false unless $game_map.valid?(x, y)      
  1560.     return true if @through or debug_through?      
  1561.     return false unless map_passable?( x, y )          
  1562.     return true                                    
  1563.   end
  1564.  
  1565.   #--------------------------------------------------------------------------#
  1566.   # * overwrite-method :check_event_trigger_touch
  1567.   #--------------------------------------------------------------------------#  
  1568.   def check_event_trigger_touch( *args, &block ) ; end
  1569.  
  1570.   #--------------------------------------------------------------------------#
  1571.   # * super-method :update
  1572.   #--------------------------------------------------------------------------#  
  1573.   def update()
  1574.     update_projectile() unless @wait_count > 0
  1575.     super()
  1576.   end
  1577.  
  1578.   #--------------------------------------------------------------------------#
  1579.   # * overwrite-method :update_states
  1580.   #--------------------------------------------------------------------------#  
  1581.   def update_states() ; end
  1582.  
  1583.   #--------------------------------------------------------------------------#
  1584.   # * overwrite-method :move_speed
  1585.   #--------------------------------------------------------------------------#  
  1586.   def move_speed() ; return @move_speed ; end
  1587.    
  1588.   #--------------------------------------------------------------------------#
  1589.   # * new-method :update_projectile
  1590.   #--------------------------------------------------------------------------#  
  1591.   def update_projectile()
  1592.     process_move() if can_move?()
  1593.     process_detonate() if can_detonate?()
  1594.     process_terminate() if can_terminate?()
  1595.   end
  1596.  
  1597.   #--------------------------------------------------------------------------#
  1598.   # * new-method :actual_*x/y
  1599.   #--------------------------------------------------------------------------#  
  1600.   def actual_x() ; return @real_x / 256 ; end
  1601.   def actual_y() ; return @real_y / 256 ; end
  1602.  
  1603.   #--------------------------------------------------------------------------#
  1604.   # * new-method :pos?
  1605.   #--------------------------------------------------------------------------#  
  1606.   def pos?( x, y )  
  1607.     return (actual_x == x && actual_y == y)
  1608.   end
  1609.  
  1610.   #--------------------------------------------------------------------------#
  1611.   # * new-method :target_xy?
  1612.   #--------------------------------------------------------------------------#  
  1613.   def target_xy?( x, y )
  1614.     return !ygg_get_targets( x, y, ygg_correct_target( @target_type ), true ).empty?()
  1615.   end
  1616.  
  1617.   #--------------------------------------------------------------------------#
  1618.   # * new-method :terminated?
  1619.   #--------------------------------------------------------------------------#  
  1620.   def terminated?()
  1621.     return @terminated
  1622.   end
  1623.  
  1624.   #--------------------------------------------------------------------------#
  1625.   # * new-method :can_move?
  1626.   #--------------------------------------------------------------------------#  
  1627.   def can_move?()
  1628.     return false if self.terminated?()
  1629.     return false if jumping?()
  1630.     return false if moving?()
  1631.     return false if (@move_cap > 0 && @move_count >= @move_cap)
  1632.     return true
  1633.   end
  1634.  
  1635.   #--------------------------------------------------------------------------#
  1636.   # * new-method :can_detonate?
  1637.   #--------------------------------------------------------------------------#  
  1638.   def can_detonate?()
  1639.     return false if self.terminated?()
  1640.     return false if (@detonate_cap > 0 && @detonate_count >= @detonate_cap)
  1641.     return target_xy?( self.actual_x, self.actual_y )
  1642.   end
  1643.  
  1644.   #--------------------------------------------------------------------------#
  1645.   # * new-method :can_terminate?
  1646.   #--------------------------------------------------------------------------#  
  1647.   def can_terminate?()
  1648.     return false if self.terminated?()
  1649.     return true if (@detonate_cap > 0 && @detonate_count >= @detonate_cap )
  1650.     return (@move_cap > 0 && @move_count >= @move_cap && !moving?())  
  1651.   end
  1652.  
  1653.   #--------------------------------------------------------------------------#
  1654.   # * new-method :process_move
  1655.   #--------------------------------------------------------------------------#  
  1656.   def process_move()
  1657.     @move_count += 1
  1658.   end
  1659.  
  1660.   #--------------------------------------------------------------------------#
  1661.   # * new-method :process_detonate
  1662.   #--------------------------------------------------------------------------#  
  1663.   def process_detonate()
  1664.     @detonate_count += 1
  1665.     @action_handle.setup( @action )
  1666.     @action_handle.execute( self )
  1667.   end
  1668.  
  1669.   #--------------------------------------------------------------------------#
  1670.   # * new-method :process_terminate
  1671.   #--------------------------------------------------------------------------#  
  1672.   def process_terminate()
  1673.     @terminated = true ; ygg_unregister()
  1674.   end
  1675.  
  1676.   #--------------------------------------------------------------------------#
  1677.   # * new-method :force_terminate
  1678.   #--------------------------------------------------------------------------#  
  1679.   def force_terminate()
  1680.     @terminated = true
  1681.   end
  1682.  
  1683. end
  1684.  
  1685. #==============================================================================#
  1686. # ** YGG::Objects::Projectiles::Linear
  1687. #==============================================================================#
  1688. class YGG::Objects::Projectiles::Linear < ::YGG::Objects::Projectiles::Base
  1689.  
  1690.   #--------------------------------------------------------------------------#
  1691.   # * super-method :initialize
  1692.   #--------------------------------------------------------------------------#  
  1693.   def initialize( parent, assignments )
  1694.     super( parent, assignments )
  1695.   end
  1696.  
  1697.   #--------------------------------------------------------------------------#
  1698.   # * super-method :process_move
  1699.   #--------------------------------------------------------------------------#  
  1700.   def process_move()
  1701.     move_forward()
  1702.     super()
  1703.   end
  1704.  
  1705. end
  1706.  
  1707. #==============================================================================#
  1708. # ** YGG::Objects::Projectiles::Hopping
  1709. #==============================================================================#
  1710. class YGG::Objects::Projectiles::Hopping < ::YGG::Objects::Projectiles::Base
  1711.  
  1712.   #--------------------------------------------------------------------------#
  1713.   # * Public Instance Variables
  1714.   #--------------------------------------------------------------------------#
  1715.   attr_accessor :jump_amount
  1716.  
  1717.   #--------------------------------------------------------------------------#
  1718.   # * super-method :initialize
  1719.   #--------------------------------------------------------------------------#  
  1720.   def initialize( parent, assignments )
  1721.     @jump_amount = (assignments[:jump_amount] || 1).to_i
  1722.     super( parent, assignments )
  1723.   end
  1724.  
  1725.   #--------------------------------------------------------------------------#
  1726.   # * super-method :process_move
  1727.   #--------------------------------------------------------------------------#  
  1728.   def process_move()
  1729.     jump_forward( @jump_amount, 0 )
  1730.     super()
  1731.   end
  1732.  
  1733. end
  1734.  
  1735. #==============================================================================#
  1736. # ** YGG::Objects::Projectiles::Homing
  1737. #==============================================================================#
  1738. class YGG::Objects::Projectiles::Homing < ::YGG::Objects::Projectiles::Base
  1739.  
  1740.   #--------------------------------------------------------------------------#
  1741.   # * Public Instance Variables
  1742.   #--------------------------------------------------------------------------#
  1743.   attr_accessor :target
  1744.   attr_accessor :homing_range
  1745.  
  1746.   #--------------------------------------------------------------------------#
  1747.   # * super-method :initialize
  1748.   #--------------------------------------------------------------------------#  
  1749.   def initialize( parent, assignments )
  1750.     @homing_range = (assignments[:homing_range] || 5).to_i
  1751.     @target = assignments[:target]
  1752.     super( parent, assignments )
  1753.     set_target() if @target.nil?()
  1754.   end
  1755.  
  1756.   #--------------------------------------------------------------------------#
  1757.   # * new-method :target_xy?
  1758.   #--------------------------------------------------------------------------#  
  1759.   def target_xy?( x, y )
  1760.     self.pos?( @target.x, @target.y )
  1761.   end
  1762.  
  1763.   #--------------------------------------------------------------------------#
  1764.   # * new-method :set_target
  1765.   #--------------------------------------------------------------------------#  
  1766.   def set_target()
  1767.     @target = get_targets_nearby( @homing_range, ygg_correct_target( @target_type ) )[0]
  1768.   end
  1769.  
  1770.   #--------------------------------------------------------------------------#
  1771.   # * new-method :target_oor? # // target_out_of_range?
  1772.   #--------------------------------------------------------------------------#  
  1773.   def target_oor?()
  1774.     return @homing_range == -1 ? false : (@target.distance_from( self ) > @homing_range)
  1775.   end
  1776.  
  1777.   #--------------------------------------------------------------------------#
  1778.   # * super-method :process_move
  1779.   #--------------------------------------------------------------------------#  
  1780.   def process_move()
  1781.     move_toward_char( @target )
  1782.     super()
  1783.   end
  1784.  
  1785.   #--------------------------------------------------------------------------#
  1786.   # * super-method :can_terminate?
  1787.   #--------------------------------------------------------------------------#
  1788.   def can_terminate?()
  1789.     return true if target_oor?()
  1790.     super()
  1791.   end
  1792.    
  1793. end
  1794.  
  1795. #==============================================================================#
  1796. # ** YGG::Objects::Projectiles::Bomb
  1797. #==============================================================================#
  1798. class YGG::Objects::Projectiles::Bomb < ::YGG::Objects::Projectiles::Base
  1799.  
  1800.   #--------------------------------------------------------------------------#
  1801.   # * Public Instance Variables
  1802.   #--------------------------------------------------------------------------#  
  1803.   attr_accessor :time
  1804.  
  1805.   #--------------------------------------------------------------------------#
  1806.   # * super-method :initialize
  1807.   #--------------------------------------------------------------------------#  
  1808.   def initialize( parent, assignments )
  1809.     @time = (assignments[:time] || 60).to_i
  1810.     super( parent, assignments )
  1811.   end
  1812.  
  1813.   #--------------------------------------------------------------------------#
  1814.   # * overwrite-method :target_xy?
  1815.   #--------------------------------------------------------------------------#  
  1816.   def target_xy?( x, y )
  1817.     return true
  1818.   end
  1819.  
  1820.   #--------------------------------------------------------------------------#
  1821.   # * super-method :update_projectile
  1822.   #--------------------------------------------------------------------------#  
  1823.   def update_projectile()
  1824.     @time = [@time-1, 0].max
  1825.     super()
  1826.   end
  1827.  
  1828.   #--------------------------------------------------------------------------#
  1829.   # * super-method :can_detonate?
  1830.   #--------------------------------------------------------------------------#  
  1831.   def can_detonate?()
  1832.     return false unless super()
  1833.     return true if @time == 0
  1834.     return false
  1835.   end
  1836.  
  1837. end
  1838.  
  1839. #==============================================================================#
  1840. # ** YGG::Objects::Projectiles::GhostBullet
  1841. #==============================================================================#
  1842. class YGG::Objects::Projectiles::GhostBullet < ::YGG::Objects::Projectiles::Base
  1843.  
  1844.   #--------------------------------------------------------------------------#
  1845.   # * super-method :initialize
  1846.   #--------------------------------------------------------------------------#  
  1847.   def initialize( parent, assignments )
  1848.     super( parent, assignments )
  1849.   end
  1850.  
  1851. end
  1852.  
  1853. #==============================================================================#
  1854. # ** YGG::Objects::Projectiles::ActionPilot
  1855. #==============================================================================#
  1856. class YGG::Objects::Projectiles::ActionPilot < ::YGG::Objects::Projectiles::Base
  1857.  
  1858.   #--------------------------------------------------------------------------#
  1859.   # * Public Instance Variables
  1860.   #--------------------------------------------------------------------------#  
  1861.   attr_accessor :pilot_list
  1862.  
  1863.   #--------------------------------------------------------------------------#
  1864.   # * super-method :update_projectile
  1865.   #--------------------------------------------------------------------------#  
  1866.   def initialize( parent, assignments )
  1867.     @pilot_list = assignments[:pilot_list] || []
  1868.     super( parent, assignments )
  1869.     @pilot_index = 0
  1870.   end
  1871.  
  1872.   #--------------------------------------------------------------------------#
  1873.   # * new-method :update_projectile
  1874.   #--------------------------------------------------------------------------#  
  1875.   def update_projectile()
  1876.     @sleep_count = [@sleep_count - 1, 0].max
  1877.     return unless @sleep_count == 0
  1878.     while @pilot_index < @pilot_list.size
  1879.       act_set     = @pilot_list[@pilot_index]
  1880.       @action     = act_set[0]
  1881.       @parameters = act_set[1]
  1882.       for i in 0...@parameters.size() ; @parameters[i] = @parameters[i].to_s() ; end
  1883.       act_result = -1
  1884.       case @action.upcase()
  1885.       when "MOVE"
  1886.         act_result = pilot_move( @action, @parameters )
  1887.       when "DETONATE"  
  1888.         act_result = pilot_detonate( @action, @parameters )
  1889.       when "TERMINATE"  
  1890.         act_result = pilot_terminate( @action, @parameters )
  1891.       when "SEND"  
  1892.         act_result = pilot_send( @action, @parameters )
  1893.       when "SLEEP"  
  1894.         act_result = pilot_sleep( @action, @parameters )
  1895.       when "SCRIPT"  
  1896.         act_result = pilot_script( @action, @parameters )
  1897.       when "WAIT"  
  1898.         act_result = pilot_wait( @action, @parameters )
  1899.       end
  1900.       if act_result == -1
  1901.         puts "ERROR: -1 returned for pilot action #{self}"
  1902.       else
  1903.         puts "BING: #{act_result} returned for pilot action #{self}"
  1904.       end if YGG.debug_mode?
  1905.       @pilot_index += 1
  1906.       break if act_result == 1
  1907.     end  
  1908.     return
  1909.   end
  1910.  
  1911.   #--------------------------------------------------------------------------#
  1912.   # * new-method :pilot_move
  1913.   #--------------------------------------------------------------------------#  
  1914.   def pilot_move( action, parameters )
  1915.     character = self
  1916.     case parameters[0].upcase
  1917.     when "FORWARD"
  1918.       character.move_forward()
  1919.     when "BACKWARD"
  1920.       character.move_backward()  
  1921.     when "UP"
  1922.       character.move_up()
  1923.     when "DOWN"
  1924.       character.move_down()
  1925.     when "LEFT"
  1926.       character.move_left()
  1927.     when "RIGHT"
  1928.       character.move_right()
  1929.     when "TURNUP", "TURN_UP", "TURN UP"
  1930.       character.turn_up()
  1931.     when "TURNDOWN", "TURN_DOWN", "TURN DOWN"
  1932.       character.turn_down()
  1933.     when "TURNLEFT", "TURN_LEFT", "TURN LEFT"
  1934.       character.turn_left()
  1935.     when "TURNRIGHT", "TURN_RIGHT", "TURN RIGHT"
  1936.       character.turn_right()
  1937.     when "TURNRIGHT90", "TURN_RIGHT_90", "TURN RIGHT 90"
  1938.       character.turn_right_90()
  1939.     when "TURNLEFT90", "TURN_LEFT_90", "TURN LEFT 90"
  1940.       character.turn_left_90()  
  1941.     when "TURN180", "TURN_180", "TURN 180"
  1942.       character.turn_180()
  1943.     when "TURNTO", "TURN_TO", "TURN TO"
  1944.       target = nil
  1945.       character.turn_to_coord( target.x, target.y ) unless target.nil?()
  1946.     end
  1947.     return 0
  1948.   end
  1949.  
  1950.   #--------------------------------------------------------------------------#
  1951.   # * new-method :pilot_send
  1952.   #--------------------------------------------------------------------------#  
  1953.   def pilot_send( action, parameters )
  1954.     case parameters[0]
  1955.     when "ONLY"
  1956.       self.send( parameters[1] )
  1957.     when "SET"  
  1958.       self.send( parameters[1], *parameters.slice( 2, parameters.size ) )
  1959.     end  
  1960.     return 0
  1961.   end
  1962.  
  1963.   #--------------------------------------------------------------------------#
  1964.   # * new-method :pilot_detonate
  1965.   #--------------------------------------------------------------------------#  
  1966.   def pilot_detonate( action, parameters )
  1967.     process_detonate()
  1968.     return 0
  1969.   end
  1970.  
  1971.   #--------------------------------------------------------------------------#
  1972.   # * new-method :pilot_terminate
  1973.   #--------------------------------------------------------------------------#  
  1974.   def pilot_terminate( action, parameters )
  1975.     process_terminate()
  1976.     return 0
  1977.   end
  1978.  
  1979.   #--------------------------------------------------------------------------#
  1980.   # * new-method :pilot_terminate
  1981.   #--------------------------------------------------------------------------#  
  1982.   def pilot_script( action, parameters )
  1983.     eval( parameters.to_s )
  1984.     return 0
  1985.   end
  1986.  
  1987.   #--------------------------------------------------------------------------#
  1988.   # * new-method :pilot_sleep
  1989.   #--------------------------------------------------------------------------#  
  1990.   def pilot_sleep( action, parameters )
  1991.     @sleep_count = parameters[0].to_i
  1992.     return 1
  1993.   end
  1994.  
  1995.   #--------------------------------------------------------------------------#
  1996.   # * new-method :pilot_wait
  1997.   #--------------------------------------------------------------------------#  
  1998.   def pilot_wait( action, parameters )
  1999.     @wait_count = parameters[0].to_i
  2000.     return 0
  2001.   end
  2002.  
  2003. end  
  2004.  
  2005. #==============================================================================#
  2006. # ** YGG
  2007. #==============================================================================#
  2008. module YGG
  2009.  
  2010.   PROJECTILE_MAP = {
  2011.     "linear"  => YGG::Objects::Projectiles::Linear,
  2012.     "hopping" => YGG::Objects::Projectiles::Hopping,
  2013.     "homing"  => YGG::Objects::Projectiles::Homing,
  2014.     "bomb"    => YGG::Objects::Projectiles::Bomb,
  2015.     "ghost"   => YGG::Objects::Projectiles::GhostBullet,
  2016.     "action"  => YGG::Objects::Projectiles::ActionPilot,
  2017.   }  
  2018.  
  2019.   PROJETILE_SETUP = {}
  2020.  
  2021. end
  2022.  
  2023. #==============================================================================#
  2024. # ** YGG::Handlers::Equip
  2025. #==============================================================================#
  2026. class YGG::Handlers::Equip < YGG::Pos
  2027.  
  2028.   #--------------------------------------------------------------------------#
  2029.   # * Class Method(s)
  2030.   #--------------------------------------------------------------------------#
  2031.  
  2032.   #--------------------------------------------------------------------------#
  2033.   # * new-method :angle_change_list
  2034.   #--------------------------------------------------------------------------#
  2035.   def self.angle_change_list( start, add_target, wait, maxspeed=1, shorten=0 )
  2036.     result = []
  2037.     target = start + add_target
  2038.     rate = add_target.to_f / wait.to_f ; accel = 0
  2039.     ang = start
  2040.     (wait-shorten).times { |i|
  2041.       accel = maxspeed.to_f * i.to_f / wait.to_f
  2042.       if ang < target
  2043.         ang += rate.abs
  2044.         ang += accel ; ang = [ang, target].min
  2045.       elsif ang > target
  2046.         ang -= rate.abs
  2047.         ang -= accel ; ang = [ang, target].max
  2048.       else ; ang = target  
  2049.       end  
  2050.       result += [["CHANGE ANGLE", (ang)%360], ["WAIT", 1]]
  2051.     }  
  2052.     return result
  2053.   end
  2054.  
  2055.   #--------------------------------------------------------------------------#
  2056.   # * new-method :move_to_list
  2057.   #--------------------------------------------------------------------------#
  2058.   def self.move_to_list( start, add_target, wait, axis, maxspeed=1, shorten=0 )
  2059.     result = []
  2060.     target = start + add_target
  2061.     rate = add_target.to_f / wait.to_f ; accel = 0
  2062.     pos = start
  2063.     (wait-shorten).times { |i|
  2064.       accel = maxspeed.to_f * i.to_f / wait.to_f
  2065.       if pos < target
  2066.         pos += rate.abs
  2067.         pos += accel ; pos = [pos, target].min
  2068.       elsif pos > target
  2069.         pos -= rate.abs
  2070.         pos -= accel ; pos = [pos, target].max
  2071.       else ; pos = target  
  2072.       end  
  2073.       result += [["MOVE", axis.upcase, pos], ["WAIT", 1]]
  2074.     }  
  2075.     return result
  2076.   end
  2077.  
  2078.   #--------------------------------------------------------------------------#
  2079.   # * new-method :alternate_mix
  2080.   #--------------------------------------------------------------------------#  
  2081.   def self.alternate_mix( *args )
  2082.     aresult = [] ; sizes = args.inject([]) { |result, array| result << array.size }
  2083.     sizes.max.times { |i| args.each { |array| aresult << array[i] unless array[i].nil?() } }
  2084.     return aresult
  2085.   end
  2086.  
  2087.   #--------------------------------------------------------------------------#
  2088.   # * Constant(s)
  2089.   #--------------------------------------------------------------------------#
  2090.   ACTIONS = {}
  2091.   # // Swing
  2092.   t  = 0
  2093.   at = 78
  2094.   ACTIONS["Swing1"]  = [["RESET"], ["SHOW"]]
  2095.   ACTIONS["Swing1"] += angle_change_list( t, at, 12 )
  2096.   ACTIONS["Swing1"] += [["HIDE"]]
  2097.   # // Swing + Return Swing
  2098.   ACTIONS["Swing2"]  = [["RESET"], ["SHOW"]]
  2099.   ACTIONS["Swing2"] += angle_change_list( t, at, 11, 24, 2 )
  2100.   ACTIONS["Swing2"] += angle_change_list( t+at, t-at, 11, 24, 2 )
  2101.   ACTIONS["Swing2"] += [["HIDE"]]
  2102.   # // Swing + Pull
  2103.   ACTIONS["Swing3"]  = [["RESET"], ["SHOW"]]
  2104.   ACTIONS["Swing3"] += angle_change_list( t, at, 11, 24, 2 )
  2105.   ACTIONS["Swing3"] += move_to_list( 0, -14, 8, "Y" )
  2106.   ACTIONS["Swing3"] += [["HIDE"]]
  2107.  
  2108.   # // Stab
  2109.   ACTIONS["Stab1"]   = [["RESET"], ["SHOW"]]
  2110.   ACTIONS["Stab1"]  += [["CHANGE ANGLE", 40]]
  2111.   ACTIONS["Stab1"]  += [["MOVE", "X", -5]]
  2112.   ACTIONS["Stab1"]  += move_to_list( 0,  -4, 5, "Y" )
  2113.   ACTIONS["Stab1"]  += move_to_list( -4, 8, 8, "Y" )
  2114.   ACTIONS["Stab1"]  += [["HIDE"]]
  2115.  
  2116.   ACTIONS["GRise1"] = [["RESET"], ["SHOW"]]
  2117.   ACTIONS["GRise1"] += move_to_list( 0, -8, 8, "Y" )
  2118.   ACTIONS["GRise1"] += [["WAIT FOR GUARD"]]
  2119.   ACTIONS["GRise1"] += move_to_list( 0, 8, 8, "Y" )
  2120.   ACTIONS["GRise1"] += [["HIDE"]]
  2121.  
  2122. end  
  2123.  
  2124. #==============================================================================#
  2125. ($imported ||= {})["Yggdrasil_1x6_ABS"] = true
  2126. #==============================================================================#
  2127. # ** YGG
  2128. #==============================================================================#
  2129. module YGG    
  2130.  
  2131.   module_function()
  2132.  
  2133.   #--------------------------------------------------------------------------#
  2134.   # * new-method :silent_error?
  2135.   #--------------------------------------------------------------------------#  
  2136.   def silent_error?() ; return false ; end
  2137.   def debug_mode?()   ; return false ; end
  2138.    
  2139.   #--------------------------------------------------------------------------#
  2140.   # * new-method :get_action_list
  2141.   #--------------------------------------------------------------------------#
  2142.   def get_action_list( action_name )
  2143.     unless YGG::ACTION_LIST.has_key?( action_name )  
  2144.       return [] if silent_error?() # // Silent Error
  2145.       raise "Action List #{action_name} does not exist"
  2146.       exit
  2147.     end  
  2148.     return ACTION_LIST[action_name]
  2149.   end
  2150.  
  2151.   # // User Functions  
  2152.  
  2153.   #--------------------------------------------------------------------------#
  2154.   # * new-method :create_range_data
  2155.   #--------------------------------------------------------------------------#
  2156.   # If the range was done before, it is simply reloaded
  2157.   # rng    - Maximum Range
  2158.   # minrng - Minimum Range
  2159.   # type:
  2160.   #   0 - Diamond   < >
  2161.   #   1 - Cross      +
  2162.   #   2 - X          x
  2163.   #   3 - Breath     <
  2164.   #   4 - SnowFlake  *
  2165.   #   5 - Block     [ ]
  2166.   #   6 - Linear    ->
  2167.   # direction:
  2168.   #   2 - Down
  2169.   #   4 - Left
  2170.   #   6 - Right
  2171.   #   8 - Up
  2172.   #--------------------------------------------------------------------------#
  2173.   def create_range_data( rng, minrng=0, type=0, direction=2 )  
  2174.     return Handlers::Range.createRange( rng, minrng, type, direction )
  2175.   end
  2176.  
  2177.   #--------------------------------------------------------------------------#
  2178.   # * new-method :offset_xy_list
  2179.   #--------------------------------------------------------------------------#  
  2180.   def offset_xy_list( ox, oy, xy_list, direction=2 )
  2181.     return xy_list.inject([]) { |result, coords|
  2182.       result.push( offset_xy( ox, oy, coords, direction ) ) }
  2183.   end
  2184.  
  2185.   #--------------------------------------------------------------------------#
  2186.   # * new-method :offset_xy
  2187.   #--------------------------------------------------------------------------#  
  2188.   def offset_xy( ox, oy, coords, direction=2 )
  2189.     result = []
  2190.     case direction
  2191.     when 2
  2192.       result = [ ox + coords[0], oy + coords[1] ]
  2193.     when 4
  2194.       result = [ ox - coords[1], oy - coords[0] ]
  2195.     when 6
  2196.       result = [ ox + coords[1], oy + coords[0] ]
  2197.     when 8
  2198.       result = [ ox - coords[0], oy - coords[1] ]
  2199.     end
  2200.     return result
  2201.   end
  2202.  
  2203.   #--------------------------------------------------------------------------#
  2204.   # * new-method :parse_event_list
  2205.   #--------------------------------------------------------------------------#  
  2206.   def parse_event_list( list )
  2207.     return list
  2208.     # // Skip Parsing
  2209.     final_list = []
  2210.     list.each { |command|
  2211.       new_command = command.clone
  2212.       if [108, 408].include?( command.code )
  2213.         new_command = RPG::EventCommand.new
  2214.         new_command.indent = command.indent
  2215.         case command.parameters.to_s.upcase
  2216.         when "DETONATE"
  2217.           new_command.code = 1000
  2218.         end
  2219.       end  
  2220.       final_list << new_command
  2221.     }  
  2222.     return final_list
  2223.   end
  2224.  
  2225. #==============================================================================#
  2226. # // Main Classes
  2227. #==============================================================================#
  2228. # ** Pos  
  2229. #==============================================================================#
  2230.   class Pos  
  2231.    
  2232.     #--------------------------------------------------------------------------#
  2233.     # * Public Instance Variable(s)
  2234.     #--------------------------------------------------------------------------#  
  2235.     attr_accessor :x, :y, :z # // X, Y, Z
  2236.    
  2237.     #--------------------------------------------------------------------------#
  2238.     # * new-method :initialize
  2239.     #--------------------------------------------------------------------------#
  2240.     def initialize( x, y, z=0 ) ; set( x, y, z ) end
  2241.      
  2242.     #--------------------------------------------------------------------------#
  2243.     # * new-method :set
  2244.     #--------------------------------------------------------------------------#
  2245.     def set( x, y, z=@z ) ; @x = x ; @y = y ; @z = z ; end
  2246.      
  2247.     #--------------------------------------------------------------------------#
  2248.     # * super-method :==
  2249.     #--------------------------------------------------------------------------#  
  2250.     def ==( obj )
  2251.       return ( @x == obj.x &&
  2252.         @y == obj.y &&
  2253.         @z == obj.z ) if obj.kind_of?( self.class )
  2254.       return super( obj )  
  2255.     end
  2256.    
  2257.   end
  2258.  
  2259. #==============================================================================#
  2260. # ** YGG::Handlers::Screen
  2261. #==============================================================================#
  2262.   class Handlers::Screen < Pos
  2263.    
  2264.     #--------------------------------------------------------------------------#
  2265.     # * Public Instance Variable(s)
  2266.     #--------------------------------------------------------------------------#  
  2267.     attr_accessor :real_x, :real_y
  2268.    
  2269.     #--------------------------------------------------------------------------#
  2270.     # * super-method :initialize
  2271.     #--------------------------------------------------------------------------#
  2272.     def initialize( x, y, z=200 ) ; super( x, y, z ) ; moveto( x, y, z ) ; end
  2273.    
  2274.     #--------------------------------------------------------------------------#
  2275.     # * new-method :moveto
  2276.     #--------------------------------------------------------------------------#
  2277.     def moveto( x, y, z=@z )
  2278.       set( x % $game_map.width, y % $game_map.height, z )
  2279.       @real_x = @x * 256 ; @real_y = @y * 256
  2280.     end
  2281.    
  2282.     #--------------------------------------------------------------------------#
  2283.     # * new-method :screen_x
  2284.     #--------------------------------------------------------------------------#  
  2285.     def screen_x()
  2286.       return ($game_map.adjust_x(@real_x) + 8007) / 8 - 1000 + 16
  2287.     end
  2288.    
  2289.     #--------------------------------------------------------------------------#
  2290.     # * new-method :screen_y
  2291.     #--------------------------------------------------------------------------#  
  2292.     def screen_y()
  2293.       return ($game_map.adjust_y(@real_y) + 8007) / 8 - 1000 + 32
  2294.     end
  2295.    
  2296.     #--------------------------------------------------------------------------#
  2297.     # * new-method :screen_z
  2298.     #--------------------------------------------------------------------------#  
  2299.     def screen_z() ; return @z ; end
  2300.    
  2301.   end
  2302.  
  2303. #==============================================================================#
  2304. # ** Handlers::CharPos
  2305. #==============================================================================#
  2306.   class Handlers::CharPos < Handlers::Screen
  2307.    
  2308.     #--------------------------------------------------------------------------#
  2309.     # * Public Instance Variable(s)
  2310.     #--------------------------------------------------------------------------#
  2311.     attr_accessor :fade_amount
  2312.     attr_accessor :fade_max
  2313.    
  2314.     #--------------------------------------------------------------------------#
  2315.     # * super-method :initialize
  2316.     #--------------------------------------------------------------------------#
  2317.     def initialize( x=0, y=0, z=0, fade_out=0, fade_amt=0 )
  2318.       super( x, y, z )
  2319.       @fade_out    = fade_out
  2320.       @fade_amount = @fade_max = fade_amt
  2321.     end
  2322.    
  2323.     #--------------------------------------------------------------------------#
  2324.     # * new-method :fader_type
  2325.     #--------------------------------------------------------------------------#
  2326.     def fader_type() ; return @fade_out ; end
  2327.    
  2328.     #--------------------------------------------------------------------------#
  2329.     # * new-method :setup_pos
  2330.     #--------------------------------------------------------------------------#
  2331.     def setup_pos( x, y ) ; moveto( @x, @y ) ; end
  2332.    
  2333.   end  
  2334.    
  2335. #==============================================================================#
  2336. # ** Handlers::Range
  2337. #==============================================================================#
  2338.   class Handlers::Range  
  2339.    
  2340.     #--------------------------------------------------------------------------#
  2341.     # * Class Variable
  2342.     #--------------------------------------------------------------------------#
  2343.     @@_recorded_ranges = { }
  2344.    
  2345.     #--------------------------------------------------------------------------#
  2346.     # * class-method :createRange
  2347.     #--------------------------------------------------------------------------#
  2348.     def self.createRange( rng, minrng=0, type=0, direction=2 )
  2349.       datarray = [ rng, minrng, type, direction ]
  2350.       unless @@_recorded_ranges.has_key?( datarray )
  2351.         result   = []
  2352.         case type
  2353.         when 0 # // Normal - Diamond <>
  2354.           for x in 0..rng
  2355.             for y in 0..rng
  2356.               next if x+y > rng
  2357.               next if x+y < minrng
  2358.               result << [ x,  y] ; result << [-x,  y]
  2359.               result << [ x, -y] ; result << [-x, -y]
  2360.             end
  2361.           end
  2362.         when 1 # // Cross +
  2363.           for x in 0..rng
  2364.             for y in 0..rng
  2365.               next if x+y > rng
  2366.               next if x+y < minrng
  2367.               result << [ x,  0] ; result << [-x,  0]
  2368.               result << [ 0, -y] ; result << [ 0,  y]
  2369.             end
  2370.           end
  2371.         when 2 # // X - x
  2372.           for x in 0..rng
  2373.             for y in 0..rng
  2374.               next if x+y > rng
  2375.               next if x+y < minrng
  2376.               result << [ x,  x] ; result << [-x, -x]
  2377.               result << [-y,  y] ; result << [ y, -y]
  2378.             end
  2379.           end
  2380.         when 3 # // Breath <
  2381.           for x in 0..rng
  2382.             for y in 0..rng
  2383.               next if x+y > rng
  2384.               next if x+y < minrng
  2385.               case direction
  2386.               when 2 ; result << [ x,  y] ; result << [-x,  y]
  2387.               when 4 ; result << [-x,  y] ; result << [-x, -y]
  2388.               when 6 ; result << [ x,  y] ; result << [ x, -y]
  2389.               when 8 ; result << [ x, -y] ; result << [-x, -y]
  2390.               end  
  2391.             end
  2392.           end
  2393.         when 4 # // Snow Flake *
  2394.           for x in 0..rng
  2395.             next if x < minrng
  2396.             result << [ 0,  x] ; result << [ x,  0]
  2397.             result << [ 0, -x] ; result << [-x,  0]
  2398.             result << [ x,  x] ; result << [-x,  x]
  2399.             result << [ x, -x] ; result << [-x, -x]
  2400.           end  
  2401.         when 5 # // Block []
  2402.           for x in 0..rng
  2403.             for y in 0..rng
  2404.               next if x < minrng && y < minrng
  2405.               result << [ x,  y] ; result << [-x,  y]
  2406.               result << [ x, -y] ; result << [-x, -y]
  2407.             end
  2408.           end  
  2409.         when 6 # // Linear <-
  2410.           for x in 0..rng
  2411.             for y in 0..rng
  2412.               next if x+y > rng
  2413.               next if x+y < minrng
  2414.               case direction
  2415.               when 2 ; result << [ 0,  y]
  2416.               when 4 ; result << [-x,  0]
  2417.               when 6 ; result << [ x,  0]
  2418.               when 8 ; result << [ 0, -y]
  2419.               end  
  2420.             end
  2421.           end
  2422.         end
  2423.         @@_recorded_ranges[datarray] = result.compact.uniq
  2424.       end  
  2425.       return @@_recorded_ranges[datarray]
  2426.     end
  2427.    
  2428.   end
  2429.  
  2430. #==============================================================================#
  2431. # // YGG Construction
  2432. #==============================================================================#
  2433. # ** REGEXP
  2434. #==============================================================================#  
  2435.   module REGEXP
  2436. #==============================================================================#
  2437. # ** EVENT
  2438. #==============================================================================#
  2439.     module EVENT
  2440.       # Event Tags
  2441.       ABS_ALLY         = /<(?:ABS_ALLY|abs ally):[ ]*(\d+)>/i
  2442.       ABS_ENEMY        = /<(?:ABS_ENEMY|abs enemy):[ ]*(\d+)>/i
  2443.       ABS_SET_AS_ALLY  = /<(?:SET_AS_ALLY|SET AS ALLY)>/i
  2444.       ABS_SET_AS_ENEMY = /<(?:SET_AS_ENEMY|SET AS ENEMY)>/i
  2445.       ABS_BOSS         = /<(?:ABS_BOSS|abs boss)>/i
  2446.       SELF_SWITCH      = /<(?:DEAD_SELF_SWITCH|dead self switch):[ ]*(\w+)>/i
  2447.       SWITCH           = /<(?:DEAD_SWITCH|dead switch):[ ]*(\d+)[ ]*,[ ]*(\w+)>/i
  2448.       NO_FADE_DEATH    = /<(?:NO_FADE_DEATH|no fade death)>/i
  2449.       INSTANT_DEATH    = /<(?:INSTANT_DEATH|instant death)>/i
  2450.       DEATH_ANIM       = /<(?:DEATH_ANIMATION_ID|death animation id|death anim|DEATH_ANIM):[ ]*(\d+)>/i
  2451.       INVINCIBLE       = /<(?:INVINCIBLE|IMMORTAL)>/i
  2452.      
  2453.       AI_ENGINE1       = /<(?:AI_ENGINE|AI ENGINE):[ ](.*)>/i
  2454.       AI_ENGINE2       = /<\/(?:AI_ENGINE|AI ENGINE)>/i
  2455.       ENABLE_POP       = /<(?:ENABLE_POP|ENABLE POP|ENABLEPOP)>/i
  2456.       DISABLE_POP      = /<(?:DISABLE_POP|DISABLE POP|DISABLEPOP|NO POP|NO_POP|NOPOP)>/i
  2457.       SHOW_HP_BAR      = /<(?:SHOW_HP_BAR|SHOW HP BAR|SHOWHPBAR)>/i
  2458.       HIDE_HP_BAR      = /<(?:HIDE_HP_BAR|HIDE HP BAR|HIDEHPBAR)>/i
  2459.       SHOW_MP_BAR      = /<(?:SHOW_MP_BAR|SHOW MP BAR|SHOWMPBAR)>/i
  2460.       HIDE_MP_BAR      = /<(?:HIDE_MP_BAR|HIDE MP BAR|HIDEMPBAR)>/i
  2461.      
  2462.       ONDEATH1         = /<(?:ON_DEATH|ON DEATH|ONDEATH):[ ](.*)>/i
  2463.       ONDEATH2         = /<\/(?:ON_DEATH|ON DEATH|ONDEATH)>/i
  2464.     end # // EVENT
  2465. #==============================================================================#
  2466. # ** BASE_ITEM
  2467. #==============================================================================#
  2468.     module BASE_ITEM
  2469.       # Equipment Tags
  2470.       ACTION_OPEN   = /<ACTION[ ]*(\d+)>/i
  2471.       ACTION_CLOSE  = /<\/ACTION>/i
  2472.       ACTION_ASSIGN = /<ACTION[ ]*(\d+)[ ]*\=[ ]*(.*)>/i
  2473.      
  2474.       PREACTION_OPEN   = /<PREACTION[ ]*(\d+)>/i
  2475.       PREACTION_CLOSE  = /<\/PREACTION>/i
  2476.       PREACTION_ASSIGN = /<PREACTION[ ]*(\d+)[ ]*\=[ ]*(.*)>/i
  2477.      
  2478.       ACTION_6      = /(.*):[ ](.*),[ ](.*),[ ](.*),[ ](.*),[ ](.*),[ ](.*)/i
  2479.       ACTION_5      = /(.*):[ ](.*),[ ](.*),[ ](.*),[ ](.*),[ ](.*)/i
  2480.       ACTION_4      = /(.*):[ ](.*),[ ](.*),[ ](.*),[ ](.*)/i
  2481.       ACTION_3      = /(.*):[ ](.*),[ ](.*),[ ](.*)/i
  2482.       ACTION_2      = /(.*):[ ](.*),[ ](.*)/i
  2483.       ACTION_1      = /(.*):[ ](.*)/i
  2484.      
  2485.       DROPS_ATTRACT = /<(?:ATTRACT_DROP|attract drop)s?>/i
  2486.      
  2487.       CHARGE_CAP    = /<(?:CHARGE_CAP|CHARGE CAP|COOLDOWN):[ ]*(\d+)>/i
  2488.     USER_CHARGE_CAP = /<(?:USER_CHARGE_CAP|USER CHARGE CAP|USER_COOLDOWN|USER COOLDOWN):[ ]*(\d+)>/i
  2489.    
  2490.       CANT_EQUIP    = /<(?:CANT_EQUIP_SLOT|CANT EQUIP SLOT)>/i  
  2491.      
  2492.       PICKUP_SFX    = /<(?:PICKUP_SFX|PICKUP SFX|PKSFX):[ ](.*),[ ](\d+),[ ](\d+)>/i
  2493.     end
  2494. #==============================================================================#
  2495. # ** SKILL
  2496. #==============================================================================#      
  2497.     module SKILL
  2498.       UTARGET_SELECT= /<(?:USE_TARGET_SELECT|USE TARGET SELECT)>/i
  2499.       GUARDABLE     = /<(?:GUARDABLE)>/i
  2500.       NOT_GUARDABLE = /<(?:NOT_GUARDABLE|NOT GUARDABLE|NOTGUARDABLE)>/i
  2501.     end # // BASE_ITEM
  2502. #==============================================================================#
  2503. # ** STATE
  2504. #==============================================================================#    
  2505.     module STATE
  2506.       HOLD_TICKS = /<(?:HOLDTICKS|HOLD_TICKS|HOLD TICKS):[ ](\d+)>/i
  2507.       TONE       = /<TONE:[ ]([\+\-]?\d+),[ ]*([\+\-]?\d+),[ ]*([\+\-]?\d+),[ ]*(\d+)>/i
  2508.       MOVE_MOD   = /<(?:MOVEMOD|MOVE_MOD|MOVE MOD):[ ]([\+\-]\d+)>/i
  2509.       SLIP_FREQ  = /<(?:SLIPFREQ|SLIP_FREQ|SLIP FREQ):[ ](\d+)>/i
  2510.     end # // STATE
  2511. #==============================================================================#
  2512. # ** ENEMY
  2513. #==============================================================================#        
  2514.     module ENEMY
  2515.       ATK_ANIMATION_ID = /<(?:ATK_ANIMATION_ID|ATK ANIMATION ID):[ ](\d+)>/i
  2516.       DROP_ITEM1       = /<(?:DROP_ITEM|DROP ITEM|DROPITEM)[ ](\d+)>/i
  2517.       DROP_ITEM2       = /<\/(?:DROP_ITEM|DROP ITEM|DROPITEM)>/i
  2518.       DROP_CLEAR       = /<(?:DROPS_CLEAR|DROPS CLEAR|DROPSCLEAR)>/i
  2519.       GOLD_VARI        = /<(?:GOLD_VARIATION|GOLD VARIATION):[ ](\d+)>/i
  2520.       EQUIP_ICONS      = /<(?:EQUIP_ICON|EQUIP ICON|EQUIPICON)s?[ ](\d+):[ ](.*)>/i
  2521.       USE_EQUIPMENT    = /<(?:USE_EQUIPMENT|USE EQUIPMENT|USEEQUIPMENT)>/i
  2522.       NO_EQUIPMENT     = /<(?:NO_EQUIPMENT|NO EQUIPMENT|NOEQUIPMENT)>/i
  2523.     end  
  2524.   end # // REGEXP
  2525. end # // YGG
  2526.  
  2527. #==============================================================================#
  2528. #
  2529. # OriginalWij and Yanfly Collaboration - Keyboard Input
  2530. # Last Date Updated: 2010.06.12
  2531. #
  2532. #==============================================================================#
  2533. # Updates
  2534. # -----------------------------------------------------------------------------#
  2535. # o 2010.06.12 - Started and Finished Script.
  2536. #==============================================================================#
  2537. unless $imported["KeyboardInput"]
  2538. ($imported ||= {})["KeyboardInput"] = true
  2539. #==============================================================================#
  2540. # ** Input
  2541. #==============================================================================#
  2542. class << Input  
  2543.   #--------------------------------------------------------------------------#
  2544.   # Aliases (Mods - Linked to Module) - Created by OriginalWij
  2545.   #--------------------------------------------------------------------------#
  2546.   alias ow_dt_i_press press? unless $@
  2547.   alias ow_dt_i_trigger trigger? unless $@
  2548.   alias ow_dt_i_repeat repeat? unless $@
  2549.   alias ow_dt_i_update update unless $@
  2550. end
  2551.  
  2552. module Input
  2553.  
  2554.   #--------------------------------------------------------------------------
  2555.   # * initial module settings - Created by OriginalWij and Yanfly
  2556.   #--------------------------------------------------------------------------
  2557.   GetKeyState = Win32API.new( "user32", "GetAsyncKeyState", "i", "i" )
  2558.   GetCapState = Win32API.new( "user32", "GetKeyState", "i", "i" )
  2559.   KeyRepeatCounter = {}
  2560.  
  2561.   module_function()
  2562.   #--------------------------------------------------------------------------
  2563.   # * alias-method :update - Created by OriginalWij
  2564.   #--------------------------------------------------------------------------
  2565.   def update()
  2566.     ow_dt_i_update()
  2567.     for key in KeyRepeatCounter.keys
  2568.       if (GetKeyState.call(key).abs & 0x8000 == 0x8000)
  2569.         KeyRepeatCounter[key] += 1
  2570.       else
  2571.         KeyRepeatCounter.delete(key)
  2572.       end
  2573.     end
  2574.   end
  2575.  
  2576.   #--------------------------------------------------------------------------
  2577.   # * alias-method :press? - Created by OriginalWij
  2578.   #--------------------------------------------------------------------------
  2579.   def press?( key )
  2580.     return ow_dt_i_press(key) if key < 30
  2581.     adjusted_key = adjust_key(key)
  2582.     return true unless KeyRepeatCounter[adjusted_key].nil?
  2583.     return key_pressed?(adjusted_key)
  2584.   end
  2585.  
  2586.   #--------------------------------------------------------------------------
  2587.   # * alias-method :trigger? - Created by OriginalWij
  2588.   #--------------------------------------------------------------------------
  2589.   def trigger?(key)
  2590.     return ow_dt_i_trigger(key) if key < 30
  2591.     adjusted_key = adjust_key(key)
  2592.     count = KeyRepeatCounter[adjusted_key]
  2593.     return ((count == 0) or (count.nil? ? key_pressed?(adjusted_key) : false))
  2594.   end
  2595.  
  2596.   #--------------------------------------------------------------------------
  2597.   # * alias-method :repeat? - Created by OriginalWij
  2598.   #--------------------------------------------------------------------------
  2599.   def repeat?(key)
  2600.     return ow_dt_i_repeat(key) if key < 30
  2601.     adjusted_key = adjust_key(key)
  2602.     count = KeyRepeatCounter[adjusted_key]
  2603.     return true if count == 0
  2604.     if count.nil?
  2605.       return key_pressed?(adjusted_key)
  2606.     else
  2607.       return (count >= 23 and (count - 23) % 6 == 0)
  2608.     end
  2609.   end
  2610.  
  2611.   #--------------------------------------------------------------------------
  2612.   # * new-method :adjust_key - Created by OriginalWij
  2613.   #--------------------------------------------------------------------------
  2614.   def adjust_key(key)
  2615.     key -= 130 if key.between?(130, 158)
  2616.     return key
  2617.   end
  2618.  
  2619.   #--------------------------------------------------------------------------
  2620.   # * new-method :key_pressed? - Created by OriginalWij
  2621.   #--------------------------------------------------------------------------
  2622.   def key_pressed?(key)
  2623.     if (GetKeyState.call(key).abs & 0x8000 == 0x8000)
  2624.       KeyRepeatCounter[key] = 0
  2625.       return true
  2626.     end
  2627.     return false
  2628.   end
  2629.  
  2630.   #--------------------------------------------------------------------------
  2631.   # * new-method :typing? - Created by Yanfly
  2632.   #--------------------------------------------------------------------------
  2633.   def typing?
  2634.     return true if repeat?(SPACE)
  2635.     for i in 'A'..'Z'
  2636.       return true if repeat?(LETTERS[i])
  2637.     end
  2638.     for i in 0...NUMBERS.size
  2639.       return true if repeat?(NUMBERS[i])
  2640.       return true if repeat?(NUMPAD[i])
  2641.     end
  2642.     for key in Extras
  2643.       return true if repeat?(key)
  2644.     end
  2645.     return false
  2646.   end
  2647.  
  2648.   #--------------------------------------------------------------------------
  2649.   # * new-method :key_type - Created by Yanfly
  2650.   #--------------------------------------------------------------------------
  2651.   def key_type()
  2652.     return " " if repeat?(SPACE)
  2653.     for i in 'A'..'Z'
  2654.       next unless repeat?(LETTERS[i])
  2655.       return upcase? ? i.upcase : i.downcase
  2656.     end
  2657.     for i in 0...NUMBERS.size
  2658.       return i.to_s if repeat?(NUMPAD[i])
  2659.       if !press?(SHIFT)
  2660.         return i.to_s if repeat?(NUMBERS[i])
  2661.       elsif repeat?(NUMBERS[i])
  2662.         case i
  2663.         when 1; return "!"
  2664.         when 2; return "@"
  2665.         when 3; return "#"
  2666.         when 4; return "$"
  2667.         when 5; return "%"
  2668.         when 6; return "^"
  2669.         when 7; return "&"
  2670.         when 8; return "*"
  2671.         when 9; return "("
  2672.         when 0; return ")"
  2673.         end
  2674.       end
  2675.     end
  2676.     for key in Extras
  2677.       next unless repeat?(key)
  2678.       case key
  2679.       when USCORE; return press?(SHIFT) ? "_" : "-"
  2680.       when EQUALS; return press?(SHIFT) ? "+" : "="
  2681.       when LBRACE; return press?(SHIFT) ? "{" : "["
  2682.       when RBRACE; return press?(SHIFT) ? "}" : "]"
  2683.       when BSLASH; return press?(SHIFT) ? "|" : "\\"
  2684.       when SCOLON; return press?(SHIFT) ? ":" : ";"
  2685.       when QUOTE;  return press?(SHIFT) ? '"' : "'"
  2686.       when COMMA;  return press?(SHIFT) ? "<" : ","
  2687.       when PERIOD; return press?(SHIFT) ? ">" : "."
  2688.       when SLASH;  return press?(SHIFT) ? "?" : "/"
  2689.       when NMUL;   return "*"
  2690.       when NPLUS;  return "+"
  2691.       when NSEP;   return ","
  2692.       when NMINUS; return "-"
  2693.       when NDECI;  return "."
  2694.       when NDIV;   return "/"
  2695.       end
  2696.     end
  2697.     return ""
  2698.   end
  2699.  
  2700.   #--------------------------------------------------------------------------
  2701.   # * new-method :upcase? - Created by Yanfly
  2702.   #--------------------------------------------------------------------------
  2703.   def upcase?()
  2704.     return !press?(SHIFT) if GetCapState.call(CAPS) == 1
  2705.     return true if press?(SHIFT)
  2706.     return false
  2707.   end
  2708.  
  2709. end # Input
  2710. end
  2711.  
  2712. #==============================================================================#
  2713. # ** Vocab
  2714. #==============================================================================#
  2715. module Vocab
  2716.  
  2717.   #--------------------------------------------------------------------------#
  2718.   # * new-method :maxhp
  2719.   #--------------------------------------------------------------------------#
  2720.   def self.maxhp ; return self.hp ; end
  2721.    
  2722.   #--------------------------------------------------------------------------#
  2723.   # * new-method :maxmp
  2724.   #--------------------------------------------------------------------------#  
  2725.   def self.maxmp ; return self.mp ; end
  2726.    
  2727. end
  2728.  
  2729. #==============================================================================#
  2730. # ** Array
  2731. #==============================================================================#
  2732. class Array
  2733.  
  2734.   #--------------------------------------------------------------------------#
  2735.   # * new-method :rotate
  2736.   #--------------------------------------------------------------------------#  
  2737.   def rotate( n=1 ) ; dup.rotate!( n ) ; end unless method_defined? :rotate
  2738.  
  2739.   #--------------------------------------------------------------------------#
  2740.   # * new-method :rotate!
  2741.   #--------------------------------------------------------------------------#
  2742.   def rotate!( n=1 )
  2743.     return self if empty?
  2744.     n %= size
  2745.     concat( slice!( 0, n ) )
  2746.   end unless method_defined? :rotate!
  2747.  
  2748. end
  2749.  
  2750. #==============================================================================#
  2751. # ** Rect
  2752. #==============================================================================#
  2753. class Rect
  2754.  
  2755.   #--------------------------------------------------------------------------#
  2756.   # * new-method :to_a
  2757.   #--------------------------------------------------------------------------#  
  2758.   def to_a() ; return self.x, self.y, self.width, self.height ; end
  2759.  
  2760.   #--------------------------------------------------------------------------#
  2761.   # * new-method :to_vector4_a
  2762.   #--------------------------------------------------------------------------#  
  2763.   def to_vector4_a()
  2764.     return self.x, self.y, self.x + self.width, self.y + self.height
  2765.   end
  2766.  
  2767. end
  2768.  
  2769. #==============================================================================#
  2770. # ** YGG
  2771. #==============================================================================#
  2772. module YGG
  2773.  
  2774.   #--------------------------------------------------------------------------#
  2775.   # * new-method :get_action_from_line
  2776.   #--------------------------------------------------------------------------#  
  2777.   def self.get_action_from_line( line )
  2778.     case line
  2779.     # // Exception
  2780.     when /SCRIPT:[ ](.*)/i
  2781.       result = [ "SCRIPT", [$1]               ]
  2782.     # // Regular Actions            
  2783.     when ::YGG::REGEXP::BASE_ITEM::ACTION_6
  2784.       result = [ $1, [$2, $3, $4, $5, $6, $7] ]
  2785.     when ::YGG::REGEXP::BASE_ITEM::ACTION_5
  2786.       result = [ $1, [$2, $3, $4, $5, $6]     ]
  2787.     when ::YGG::REGEXP::BASE_ITEM::ACTION_4
  2788.       result = [ $1, [$2, $3, $4, $5]         ]  
  2789.     when ::YGG::REGEXP::BASE_ITEM::ACTION_3
  2790.       result = [ $1, [$2, $3, $4]             ]
  2791.     when ::YGG::REGEXP::BASE_ITEM::ACTION_2
  2792.       result = [ $1, [$2, $3]                 ]  
  2793.     when ::YGG::REGEXP::BASE_ITEM::ACTION_1
  2794.       result = [ $1, [$2]                     ]  
  2795.     else
  2796.       result = [ line, []                     ]
  2797.     end # // case line
  2798.     return result
  2799.   end
  2800.  
  2801. end
  2802.  
  2803. #==============================================================================#
  2804. # ** YGG::Caches1x6
  2805. #==============================================================================#
  2806. module YGG::Caches1x6
  2807.  
  2808.   #--------------------------------------------------------------------------#
  2809.   # * Public Instance Variable(s)
  2810.   #--------------------------------------------------------------------------#  
  2811.   attr_accessor :ygg_actions, :ygg_pre_actions
  2812.   attr_accessor :ygg_target_range
  2813.   attr_accessor :drops_attraction
  2814.   attr_accessor :atk_act_name, :grd_act_name
  2815.   attr_accessor :charge_cap
  2816.   attr_accessor :user_charge_cap
  2817.   attr_accessor :cant_equip_slot
  2818.  
  2819.   #--------------------------------------------------------------------------#
  2820.   # * new-method :ygg_add_to_cache
  2821.   #--------------------------------------------------------------------------#
  2822.   def ygg_add_to_cache( array )
  2823.     unless @__pre_action
  2824.       @ygg_actions[@__current_action].push( array )
  2825.     else  
  2826.       @ygg_pre_actions[@__current_action].push( array )
  2827.     end  
  2828.   end
  2829.  
  2830.   #--------------------------------------------------------------------------#
  2831.   # * new-method :yggdrasil_1x6_cache
  2832.   #--------------------------------------------------------------------------#
  2833.   def yggdrasil_1x6_cache()
  2834.     yggdrasil_1x6_cache_start()
  2835.     self.note.split(/[\r\n]+/).each { |line| yggdrasil_1x6_cache_check( line ) }
  2836.     yggdrasil_1x6_cache_end()
  2837.   end
  2838.  
  2839.   #--------------------------------------------------------------------------#
  2840.   # * new-method :yggdrasil_1x6_cache_start
  2841.   #--------------------------------------------------------------------------#
  2842.   def yggdrasil_1x6_cache_start()
  2843.     @charge_cap      = 0
  2844.     @user_charge_cap = 0
  2845.     @atk_act_name    = ""
  2846.     @grd_act_name    = ""
  2847.     case self
  2848.     when RPG::Item
  2849.       # // Yeah ....
  2850.     when RPG::Weapon
  2851.       @atk_act_name = "Swing1"
  2852.     when RPG::Armor  
  2853.       @grd_act_name = "GRise1"
  2854.     end  
  2855.     @ygg_actions      = {}
  2856.     @ygg_pre_actions  = {}
  2857.     @ygg_target_range = 0
  2858.     @drops_attraction = false
  2859.     @__current_action = -1
  2860.     @__pre_action     = false
  2861.     @cant_equip_slot  = false
  2862.   end
  2863.  
  2864.   #--------------------------------------------------------------------------#
  2865.   # * new-method :yggdrasil_1x6_cache_check
  2866.   #--------------------------------------------------------------------------#
  2867.   def yggdrasil_1x6_cache_check( line )
  2868.     case line
  2869.     # // Action  
  2870.     when ::YGG::REGEXP::BASE_ITEM::ACTION_OPEN
  2871.       @__current_action = $1.to_i
  2872.       @ygg_actions[@__current_action] = []
  2873.       @__pre_action = false
  2874.     when ::YGG::REGEXP::BASE_ITEM::ACTION_CLOSE  
  2875.       @__pre_action = false
  2876.       @__current_action = -1
  2877.     when ::YGG::REGEXP::BASE_ITEM::ACTION_ASSIGN
  2878.       @ygg_actions[$1.to_i] = ::YGG.get_action_list( $2 )
  2879.     # // Pre Action  
  2880.     when ::YGG::REGEXP::BASE_ITEM::PREACTION_OPEN
  2881.       @__current_action = $1.to_i
  2882.       @ygg_pre_actions[@__current_action] = []
  2883.       @__pre_action = true
  2884.     when ::YGG::REGEXP::BASE_ITEM::PREACTION_CLOSE  
  2885.       @__current_action = -1
  2886.       @__pre_action = false
  2887.     when ::YGG::REGEXP::BASE_ITEM::PREACTION_ASSIGN
  2888.       @ygg_pre_actions[$1.to_i] = ::YGG.get_action_list( $2 )  
  2889.      
  2890.     when ::YGG::REGEXP::BASE_ITEM::DROPS_ATTRACT  
  2891.       @drops_attraction = true
  2892.     when ::YGG::REGEXP::BASE_ITEM::CHARGE_CAP  
  2893.       @charge_cap = $1.to_i
  2894.     when ::YGG::REGEXP::BASE_ITEM::USER_CHARGE_CAP  
  2895.       @user_charge_cap = $1.to_i
  2896.      
  2897.     when ::YGG::REGEXP::BASE_ITEM::CANT_EQUIP
  2898.       @cant_equip_slot = true
  2899.     else
  2900.       if @__current_action > -1
  2901.         ygg_add_to_cache( ::YGG.get_action_from_line( line ) )
  2902.       end # // if current_action > -1
  2903.     end # // case line
  2904.   end
  2905.  
  2906.   #--------------------------------------------------------------------------#
  2907.   # * new-method :yggdrasil_1x6_cache_end
  2908.   #--------------------------------------------------------------------------#
  2909.   def yggdrasil_1x6_cache_end()
  2910.     @__current_action = nil ; @__pre_action = nil
  2911.   end
  2912.  
  2913. end  
  2914.  
  2915. #==============================================================================#
  2916. # ** YGG::Containers::GoldItem  
  2917. #==============================================================================#
  2918. class YGG::Containers::GoldItem
  2919.  
  2920.   #--------------------------------------------------------------------------#
  2921.   # * Public Instance Variable(s)
  2922.   #--------------------------------------------------------------------------#  
  2923.   attr_accessor :name
  2924.   attr_accessor :gold_amount
  2925.   attr_accessor :icon_index
  2926.   attr_accessor :pickup_sfx
  2927.  
  2928.   #--------------------------------------------------------------------------#
  2929.   # * new-method :initialize
  2930.   #--------------------------------------------------------------------------#
  2931.   def initialize( amt )
  2932.     @name        = ::Vocab.gold
  2933.     @gold_amount = amt
  2934.     @icon_index  = ::YGG::GOLD_DROP_ICON
  2935.     @pickup_sfx  = ::YGG::SOUND_MONEY
  2936.   end
  2937.  
  2938. end
  2939.  
  2940. #==============================================================================#
  2941. # ** YGG::Handlers::Engage
  2942. #==============================================================================#
  2943. class YGG::Handlers::Engage
  2944.  
  2945.   #--------------------------------------------------------------------------#
  2946.   # * Public Instance Variable(s)
  2947.   #--------------------------------------------------------------------------#
  2948.   attr_accessor :parent
  2949.   attr_accessor :bar_opacity
  2950.  
  2951.   #--------------------------------------------------------------------------#
  2952.   # * new-method :initialize
  2953.   #--------------------------------------------------------------------------#
  2954.   def initialize( parent )
  2955.     @parent      = parent
  2956.     @cool_down   = 0
  2957.     @bar_opacity = 255
  2958.   end
  2959.  
  2960.   #--------------------------------------------------------------------------#
  2961.   # * new-method :engage
  2962.   #--------------------------------------------------------------------------#
  2963.   def engage( cool_down )
  2964.     @cool_down   = cool_down
  2965.     @bar_opacity = 255
  2966.   end
  2967.  
  2968.   #--------------------------------------------------------------------------#
  2969.   # * new-method :engaged?
  2970.   #--------------------------------------------------------------------------#
  2971.   def engaged? ; return @cool_down > 0 ; end
  2972.  
  2973.   #--------------------------------------------------------------------------#
  2974.   # * new-method :update
  2975.   #--------------------------------------------------------------------------#
  2976.   def update()
  2977.     update_cool_down()
  2978.     update_bar_opacity()
  2979.   end
  2980.  
  2981.   #--------------------------------------------------------------------------#
  2982.   # * new-method :update_cool_down
  2983.   #--------------------------------------------------------------------------#
  2984.   def update_cool_down()
  2985.     @cool_down = [@cool_down-1, 0].max
  2986.   end
  2987.  
  2988.   #--------------------------------------------------------------------------#
  2989.   # * new-method :update_bar_opacity
  2990.   #--------------------------------------------------------------------------#
  2991.   def update_bar_opacity()
  2992.     if engaged?()
  2993.       @bar_opacity = [@bar_opacity+(255/60.0), 255].min
  2994.     else
  2995.       @bar_opacity = [@bar_opacity-(255/60.0), 0].max
  2996.     end  
  2997.   end
  2998.  
  2999. end
  3000.  
  3001. #==============================================================================#
  3002. # ** YGG::Handlers::Equip
  3003. #==============================================================================#
  3004. class YGG::Handlers::Equip < YGG::Pos
  3005.  
  3006.   #--------------------------------------------------------------------------#
  3007.   # * Public Instance Variable(s)
  3008.   #--------------------------------------------------------------------------#
  3009.   #attr_accessor :parent
  3010.   attr_accessor :icon_index
  3011.   attr_accessor :eq_id
  3012.   attr_accessor :mirror
  3013.   attr_accessor :opacity, :visible
  3014.   attr_accessor :sox, :soy # // Sprite Offset
  3015.   attr_accessor :attack_action, :guard_action
  3016.   attr_accessor :direction
  3017.   attr_accessor :guard_time
  3018.  
  3019.   attr_writer   :angle
  3020.  
  3021.   #--------------------------------------------------------------------------#
  3022.   # * new-method :angle_debug # // DEBUG
  3023.   #--------------------------------------------------------------------------#  
  3024.   def angle_debug()
  3025.     #@angle = (@angle + 1) % 360 if @eq_id == 0
  3026.     if Input.trigger?(Input::NUMBERS[1])
  3027.       @sox += 1
  3028.       puts @sox
  3029.     elsif Input.trigger?(Input::NUMBERS[2])
  3030.       @sox -= 1
  3031.       puts @sox
  3032.     elsif Input.trigger?(Input::NUMBERS[3])  
  3033.       @soy += 1
  3034.       puts @soy
  3035.     elsif Input.trigger?(Input::NUMBERS[4])  
  3036.       @soy -= 1
  3037.       puts @soy
  3038.     elsif Input.trigger?(Input::NUMBERS[5])  
  3039.       @sox = 0
  3040.       puts @sox  
  3041.     elsif Input.trigger?(Input::NUMBERS[6])  
  3042.       @soy = 0
  3043.       puts @soy
  3044.     end if @parent.is_a?(Game_Player) if @eq_id == 0
  3045.   end
  3046.  
  3047.   #--------------------------------------------------------------------------#
  3048.   # * new-method :initialize
  3049.   #--------------------------------------------------------------------------#
  3050.   def initialize( eq_id )
  3051.     super( 0, 0, 0 )
  3052.     #@parent       = parent
  3053.     @eq_id        = eq_id
  3054.     @icon_index   = 0 #@parent.equip_icon( @eq_id )
  3055.     @list         = []
  3056.     @list_index   = 0
  3057.     @sox, @soy    = 20, 20
  3058.     @visible      = false
  3059.     @mirror       = false
  3060.     @angle_offset = 0
  3061.     @angle_mult   = 1
  3062.     @attack_action= ""
  3063.     @guard_action = ""
  3064.     @guard_time   = 0
  3065.     reset()
  3066.   end
  3067.  
  3068.   #--------------------------------------------------------------------------#
  3069.   # * new-method :refresh
  3070.   #--------------------------------------------------------------------------#
  3071.   def refresh()
  3072.     #@icon_index   = @parent.equip_icon( @eq_id )
  3073.   end
  3074.  
  3075.   #--------------------------------------------------------------------------#
  3076.   # * new-method :angle
  3077.   #--------------------------------------------------------------------------#
  3078.   def angle ; return (@angle * @angle_mult) + @angle_offset ; end
  3079.    
  3080.   #--------------------------------------------------------------------------#
  3081.   # * new-method :reset
  3082.   #--------------------------------------------------------------------------#
  3083.   def reset()
  3084.     @wait_count   = 0
  3085.     @opacity      = 255
  3086.     @ox, @oy, @oz = 0, 0, 0
  3087.     @angle        = 0
  3088.   end
  3089.  
  3090.   #--------------------------------------------------------------------------#
  3091.   # * new-method :ox
  3092.   #--------------------------------------------------------------------------#
  3093.   def ox ; return @x + @ox + @sox ; end
  3094.   #--------------------------------------------------------------------------#
  3095.   # * new-method :oy
  3096.   #--------------------------------------------------------------------------#
  3097.   def oy ; return @y + @oy + @soy ; end
  3098.   #--------------------------------------------------------------------------#
  3099.   # * new-method :oz
  3100.   #--------------------------------------------------------------------------#  
  3101.   def oz ; return @z + @oz ; end
  3102.  
  3103.   #--------------------------------------------------------------------------#
  3104.   # * new-method :update
  3105.   #--------------------------------------------------------------------------#  
  3106.   def update()
  3107.     update_list()
  3108.     update_position()
  3109.   end
  3110.  
  3111.   #--------------------------------------------------------------------------#
  3112.   # * new-method :do_action
  3113.   #--------------------------------------------------------------------------#  
  3114.   def do_action( name )
  3115.     #@icon_index    = @parent.equip_icon( @eq_id )    
  3116.     @list = ACTIONS[name].clone ; @list_index = 0
  3117.   end
  3118.  
  3119.   #--------------------------------------------------------------------------#
  3120.   # * new-method :do_attack
  3121.   #--------------------------------------------------------------------------#  
  3122.   def do_attack()
  3123.     #@attack_action = @parent.equip_atk_act_name( @eq_id )
  3124.     do_action( @attack_action ) unless @attack_action == ""
  3125.   end
  3126.  
  3127.   #--------------------------------------------------------------------------#
  3128.   # * new-method :do_guard
  3129.   #--------------------------------------------------------------------------#  
  3130.   def do_guard()
  3131.     #@guard_action  = @parent.equip_grd_act_name( @eq_id )
  3132.     do_action( @guard_action ) unless @guard_action == ""
  3133.   end
  3134.  
  3135.   #--------------------------------------------------------------------------#
  3136.   # * new-method :update_position
  3137.   #--------------------------------------------------------------------------#  
  3138.   def update_position()
  3139.     #self.angle_debug()
  3140.     case @eq_id
  3141.     when 0 # // Weapon
  3142.       oox, ooy = @ox, @oy
  3143.       case @direction #@parent.direction
  3144.       when 1 # // Down-Left
  3145.       when 2 # // Down
  3146.         @x, @y, @z = -28, -28, 20
  3147.         @sox, @soy    = 20, 20
  3148.         @ox, @oy = oox, ooy
  3149.         #@angle_offset = 0
  3150.         @angle_mult   = 1
  3151.         @mirror = false
  3152.       when 3 # // Down-Right  
  3153.       when 4 # // Left
  3154.         @x, @y, @z = -24, -28, -20
  3155.         @sox, @soy    = 20, 20
  3156.         @ox, @oy = -ooy, -oox
  3157.         #@angle_offset = 0
  3158.         @angle_mult   = 1
  3159.         @mirror = false
  3160.       when 6 # // Right
  3161.         @x, @y, @z = -4, -28, 20
  3162.         @sox, @soy    = 5, 20
  3163.         @ox, @oy = ooy, oox
  3164.         #@angle_offset = 0
  3165.         @angle_mult   = -1
  3166.         @mirror = true
  3167.       when 7 # // Up-Left  
  3168.       when 8 # // Up
  3169.         @x, @y, @z = 4, -28, -20
  3170.         @sox, @soy    = 5, 20
  3171.         @ox, @oy = -oox, ooy
  3172.         #@angle_offset = 0
  3173.         @angle_mult   = -1
  3174.         @mirror = true
  3175.       when 9 # // Up-Right
  3176.       end  
  3177.     when 1 # // Shield
  3178.       case @direction #@parent.direction
  3179.       when 1 # // Down-Left
  3180.       when 2 # // Down
  3181.         @x, @y, @z = 0, -24, 20
  3182.         @mirror = true
  3183.       when 3 # // Down-Right  
  3184.       when 4 # // Left
  3185.         @x, @y, @z = -16, -24, 20
  3186.         @mirror = false
  3187.       when 6 # // Right
  3188.         @x, @y, @z = -4, -28, -20
  3189.         @mirror = true
  3190.       when 7 # // Up-Left  
  3191.       when 8 # // Up
  3192.         @x, @y, @z = -24, -24, -20
  3193.         @mirror = false
  3194.       when 9 # // Up-Right
  3195.       end  
  3196.     end  
  3197.   end
  3198.  
  3199.   #--------------------------------------------------------------------------#
  3200.   # * new-method :update_list
  3201.   #--------------------------------------------------------------------------#  
  3202.   def update_list()
  3203.     @wait_count = [@wait_count - 1, 0].max
  3204.     return unless @wait_count == 0
  3205.     while @list_index < @list.size
  3206.       ret_value = -1
  3207.       act = @list[@list_index]
  3208.       case act[0].upcase
  3209.       when "MOVE"
  3210.         case act[1].upcase
  3211.         when "X" ; @ox = act[2]
  3212.         when "Y" ; @oy = act[2]
  3213.         when "Z" ; @oz = act[2] # // For whatever reason
  3214.         end  
  3215.         ret_value = 0
  3216.       when "CHANGEANGLE", "CHANGE_ANGLE", "CHANGE ANGLE"
  3217.         @angle = act[1]
  3218.         ret_value = 0
  3219.       when "RESET"
  3220.         reset()
  3221.         ret_value = 0
  3222.       when "CHANGEOPACITY", "CHANGE_OPACITY", "CHANGE OPACITY"  
  3223.         @opacity = act[1]
  3224.         ret_value = 0
  3225.       when "SHOW"  
  3226.         @visible = true
  3227.         ret_value = 0
  3228.       when "HIDE"  
  3229.         @visible = false
  3230.         ret_value = 0
  3231.       when "WAIT FOR GUARD"  
  3232.         return if @guard_time > 0
  3233.         ret_value = 0
  3234.       when "WAIT"  
  3235.         @wait_count = act[1]
  3236.         ret_value = 1
  3237.       end  
  3238.       @list_index += 1
  3239.       return if ret_value == 1
  3240.     end  
  3241.   end
  3242.  
  3243. end
  3244.  
  3245. #==============================================================================#
  3246. # ** YGG::Handlers::BattleObj
  3247. #==============================================================================#
  3248. class YGG::Handlers::BattleObj
  3249.  
  3250.   #--------------------------------------------------------------------------#
  3251.   # * Public Instance Variable(s)
  3252.   #--------------------------------------------------------------------------#  
  3253.   attr_accessor :obj_id
  3254.   attr_accessor :type
  3255.  
  3256.   #--------------------------------------------------------------------------#
  3257.   # * new-method :initialize
  3258.   #--------------------------------------------------------------------------#  
  3259.   def initialize( id, type )
  3260.     @obj_id, @type = id, type ; @charge_time = 0 ;
  3261.     @dummy_obj = RPG::BaseItem.new() ; @dummy_obj.yggdrasil_1x6_cache()
  3262.   end
  3263.  
  3264.   #--------------------------------------------------------------------------#
  3265.   # * new-method :skill
  3266.   #--------------------------------------------------------------------------#  
  3267.   def skill()
  3268.     return @type == :skill ? $data_skills[@obj_id] : nil
  3269.   end
  3270.  
  3271.   #--------------------------------------------------------------------------#
  3272.   # * new-method :item
  3273.   #--------------------------------------------------------------------------#
  3274.   def item()
  3275.     return @type == :item ? $data_items[@obj_id] : nil
  3276.   end
  3277.  
  3278.   #--------------------------------------------------------------------------#
  3279.   # * new-method :obj
  3280.   #--------------------------------------------------------------------------#  
  3281.   def obj()
  3282.     return item() || skill() || @dummy_obj
  3283.   end
  3284.  
  3285.   #--------------------------------------------------------------------------#
  3286.   # * new-method :reset_time
  3287.   #--------------------------------------------------------------------------#  
  3288.   def reset_time()
  3289.     @charge_time = cap
  3290.   end
  3291.  
  3292.   #--------------------------------------------------------------------------#
  3293.   # * new-method :time
  3294.   #--------------------------------------------------------------------------#  
  3295.   def time()
  3296.     return @charge_time
  3297.   end
  3298.  
  3299.   #--------------------------------------------------------------------------#
  3300.   # * new-method :cap
  3301.   #--------------------------------------------------------------------------#  
  3302.   def cap()
  3303.     return obj.charge_cap
  3304.   end
  3305.  
  3306.   #--------------------------------------------------------------------------#
  3307.   # * new-method :can_use?
  3308.   #--------------------------------------------------------------------------#  
  3309.   def can_use?() ; return @charge_time == 0 ; end
  3310.  
  3311.   #--------------------------------------------------------------------------#
  3312.   # * new-method :update
  3313.   #--------------------------------------------------------------------------#  
  3314.   def update()
  3315.     @charge_time = [@charge_time - 1, 0].max
  3316.   end
  3317.  
  3318. end
  3319.  
  3320. #==============================================================================#
  3321. # ** YGG::System (Battle Edits)
  3322. #==============================================================================#
  3323. class YGG::System
  3324.  
  3325.   #--------------------------------------------------------------------------#
  3326.   # * new-method :action_attack
  3327.   #--------------------------------------------------------------------------#  
  3328.   def action_attack( settings={} )
  3329.     user_ev, targets_ev = settings[:user], settings[:targets]
  3330.     user = user_ev.ygg_battler
  3331.     targets_ev.each { |target|
  3332.       next if target.ygg_invincible
  3333.       bat = target.ygg_battler
  3334.       next if bat.nil?()
  3335.       bat.ygg_guard = target.guard_time > 0
  3336.       bat.attack_effect( user )
  3337.       target.ygg_engage.engage( 180 )
  3338.       YGG::PopText.create_pop( { :character => target, :type => :attack_damage } ) if target.pop_enabled?() if YGG::USE_TEXT_POP        
  3339.       action_gain_exp( user, bat, user_ev, YGG::POP_EXP ) unless bat.actor?() if user.actor?()
  3340.       bat.ygg_guard = false
  3341.     }
  3342.   end
  3343.  
  3344.   #--------------------------------------------------------------------------#
  3345.   # * new-method :action_skill
  3346.   #--------------------------------------------------------------------------#  
  3347.   def action_skill( settings={} )
  3348.     user_ev, targets_ev, obj = settings[:user], settings[:targets], settings[:obj]
  3349.     targets = targets_ev.inject([]) { |r, e| r << e.ygg_battler }
  3350.     targets.compact!() ; user = user_ev.ygg_battler
  3351.     targets_ev.each { |target|
  3352.       next if target.ygg_invincible
  3353.       bat = target.ygg_battler
  3354.       next if bat.nil?()
  3355.       bat.ygg_guard = target.guard_time > 0 && obj.guardable
  3356.       bat.skill_effect( user, obj )
  3357.       target.ygg_engage.engage( 180 )
  3358.       YGG::PopText.create_pop( { :character => target, :type => :skill_damage } ) if target.pop_enabled?() if YGG::USE_TEXT_POP              
  3359.       action_gain_exp( user, bat, user_ev, YGG::POP_EXP ) unless bat.actor?() if user.actor?()
  3360.       bat.ygg_guard = false
  3361.     }
  3362.   end
  3363.  
  3364.   #--------------------------------------------------------------------------#
  3365.   # * new-method :action_item
  3366.   #--------------------------------------------------------------------------#  
  3367.   def action_item( settings={} )
  3368.     user_ev, targets_ev, obj = settings[:user], settings[:targets], settings[:obj]
  3369.     targets = targets_ev.inject([]) { |r, e| r << e.ygg_battler }
  3370.     targets.compact!() ; user = user_ev.ygg_battler
  3371.     targets_ev.each { |target|
  3372.       next if target.ygg_invincible
  3373.       bat = target.ygg_battler
  3374.       next if bat.nil?()
  3375.       bat.ygg_guard = target.guard_time > 0 && obj.guardable
  3376.       bat.item_effect( user, obj )
  3377.       target.ygg_engage.engage( 180 )
  3378.       YGG::PopText.create_pop( { :character => target, :type => :item_damage } ) if target.pop_enabled?() if YGG::USE_TEXT_POP              
  3379.       action_gain_exp( user, bat, user_ev, YGG::POP_EXP ) unless bat.actor?() if user.actor?()
  3380.       bat.ygg_guard = false
  3381.     }
  3382.   end
  3383.  
  3384.   #--------------------------------------------------------------------------#
  3385.   # * new-method :action_gain_exp
  3386.   #--------------------------------------------------------------------------#  
  3387.   def action_gain_exp( receivee, bat, event=nil, show=true )
  3388.     case YGG::EXP_GAINING_METHOD
  3389.     when 0 # // Dead
  3390.       return unless bat.dead?()
  3391.       exp = bat.exp
  3392.     when 1 # // Per Hit
  3393.       exp = YGG::EXP_PER_HIT_FORMULA.call(
  3394.         bat.hp_damage+receivee.mp_damage, receivee, bat )
  3395.     end  
  3396.     return if exp == 0  
  3397.     old_level = receivee.level
  3398.     case YGG::EXP_SAHRE_METHOD
  3399.     when 0 # Active Member Only
  3400.       receivee.gain_exp( exp, false )
  3401.     when 1 # All Members Equal
  3402.       ($game_party.members-[receivee]).each { |mem| mem.gain_exp( exp, false ) }
  3403.       receivee.gain_exp( exp, false )
  3404.     when 2 # All Members Split
  3405.       mems = ($game_party.members-[receivee])
  3406.       exp /= mems.size+1
  3407.       mems.each { |mem| mem.gain_exp( exp, false ) }
  3408.       receivee.gain_exp( exp, false )
  3409.     end          
  3410.     action_level_up( receivee, old_level, event, YGG::POP_LEVEL_UP ) if old_level != receivee.level
  3411.     unless event.nil?()
  3412.       ::YGG::PopText.create_pop(
  3413.         { :character => event, :type => :gain_exp, :parameters => [exp] }
  3414.       ) if YGG::USE_TEXT_POP                
  3415.     end if show
  3416.   end
  3417.  
  3418.   #--------------------------------------------------------------------------#
  3419.   # * new-method :action_level_up
  3420.   #--------------------------------------------------------------------------#
  3421.   def action_level_up( receivee, old_level, event=nil, show=true )
  3422.     $scene.level_up_window.show_level_up( receivee, old_level ) if YGG::USE_LEVEL_UP_WINDOW > 0
  3423.     unless event.nil?()
  3424.       if ::YGG::LEVEL_UP_ALERT
  3425.         event.ygg_anims << ::YGG::ANIM_ON_LEVEL unless ::YGG::ANIM_ON_LEVEL == 0
  3426.       end  
  3427.       ::YGG::PopText.create_pop(
  3428.         { :character => event, :type => :level_up, :parameters => [old_level] }
  3429.       ) if show if YGG::USE_TEXT_POP              
  3430.     end
  3431.   end
  3432.  
  3433. end
  3434.  
  3435. #==============================================================================#
  3436. # ** YGG::Handlers::Action
  3437. #==============================================================================#
  3438. class YGG::Handlers::Action
  3439.  
  3440.   #--------------------------------------------------------------------------#
  3441.   # * Public Instance Variable(s)
  3442.   #--------------------------------------------------------------------------#  
  3443.   attr_accessor :list
  3444.   attr_accessor :list_stack
  3445.   attr_accessor :skill_id, :item_id
  3446.   attr_accessor :user_event
  3447.   attr_accessor :target_events
  3448.   attr_accessor :parent_event
  3449.  
  3450.   #--------------------------------------------------------------------------#
  3451.   # * new-method :initialize
  3452.   #--------------------------------------------------------------------------#  
  3453.   def initialize( parent, list=[] )
  3454.     @parent_event = parent
  3455.     @interpreter  = ::Game_Interpreter.new()
  3456.     @list_stack   = [] ; setup( list ) ; execute( nil, [], { :skip_first_update=>true } )
  3457.   end
  3458.  
  3459.   #--------------------------------------------------------------------------#
  3460.   # * new-method :setup
  3461.   #--------------------------------------------------------------------------#  
  3462.   def setup( list=[] )
  3463.     @list        = list.clone
  3464.     @active_list = @list.clone
  3465.   end
  3466.  
  3467.   #--------------------------------------------------------------------------#
  3468.   # * new-method :busy?
  3469.   #--------------------------------------------------------------------------#  
  3470.   def busy?()
  3471.     return @list_index < @active_list.size || @interpreter.running?()
  3472.   end
  3473.  
  3474.   #--------------------------------------------------------------------------#
  3475.   # * new-method :execute
  3476.   #--------------------------------------------------------------------------#  
  3477.   def execute( user_event, starting_targets=[], start_values={} )
  3478.     @active_list    = @list.clone
  3479.     @wait_count     = start_values[:wait_count] || 0
  3480.     @skill_id       = start_values[:skill_id] || 0
  3481.     @item_id        = start_values[:item_id] || 0
  3482.     @range          = start_values[:range] || []
  3483.     @target_events  = starting_targets
  3484.     @user_event     = user_event
  3485.     @wait_for_comev = false
  3486.     @list_index     = 0
  3487.    
  3488.     @affected_targets = []
  3489.    
  3490.     update() unless start_values[:skip_first_update]
  3491.   end
  3492.  
  3493.   #--------------------------------------------------------------------------#
  3494.   # * new-method :update
  3495.   #--------------------------------------------------------------------------#  
  3496.   def update()
  3497.     @interpreter.update()
  3498.     return if @interpreter.running?() && @wait_for_comev
  3499.     @wait_count = [@wait_count-1, 0].max
  3500.     update_action() if @wait_count == 0
  3501.   end
  3502.  
  3503.   #--------------------------------------------------------------------------#
  3504.   # * new-method :update_action
  3505.   #--------------------------------------------------------------------------#  
  3506.   def update_action()
  3507.     unless @list_stack.empty?()
  3508.       setup( @list_stack.shift() )
  3509.       execute( @user_event, @target_events,
  3510.        {
  3511.         :skill_id => @skill_id,
  3512.         :item_id  => @item_id,
  3513.         :range    => @range
  3514.        }
  3515.       )
  3516.     end if @list_index >= @active_list.size
  3517.     while @list_index < @active_list.size
  3518.       #break if act_set.nil?()
  3519.       @action, @parameters = *@active_list[@list_index]
  3520.       #for i in 0...@parameters.size() ; @parameters[i] = @parameters[i].to_s() ; end
  3521.       act_result = -1
  3522.       #puts sprintf("ACTION: %s", @action)
  3523.       #puts sprintf("PARAMETERS: %s", @parameters)
  3524.       case @action.upcase()
  3525.       # // action: action_name
  3526.       when "ACTION", "ACTIONLIST", "ACTION LIST", "ACTION_LIST"
  3527.         act_result = action_actionlist( @action, @parameters )
  3528.       when "ANIMATION"
  3529.         act_result = action_animation( @action, @parameters )
  3530.       when "COMMONEVENT", "COMMON_EVENT", "COMMON EVENT"  
  3531.         act_result = action_common_event( @action, @parameters )
  3532.       when "ATTACKEFFECT", "ATTACK_EFFECT", "ATTACK EFFECT"
  3533.         act_result = action_effect( @action, @parameters )
  3534.       when "SKILLEFFECT", "SKILL_EFFECT", "SKILL EFFECT"
  3535.         act_result = action_effect( @action, @parameters )
  3536.       when "ITEMEFFECT", "ITEM_EFFECT", "ITEM EFFECT"  
  3537.         act_result = action_effect( @action, @parameters )
  3538.       when "OBJEFFECT", "OBJ_EFFECT", "OBJ EFFECT"    
  3539.         eff = @skill_id > 0 ? "SKILL_EFFECT" : nil
  3540.         eff = @item_id > 0 ? "ITEM_EFFECT" : "" if eff.nil?()
  3541.         act_result = action_effect( eff, @parameters+["PRESET"] )
  3542.       when "GUARD"  
  3543.         act_result = action_guard( @action, @parameters )
  3544.       when "CHARGE", "COOLDOWN"  
  3545.         act_result = action_charge( @action, @parameters )
  3546.       when "RANGE"  
  3547.         act_result = action_range( @action, @parameters )
  3548.       when "TARGET"  
  3549.         action_target( @action, @parameters )
  3550.         act_result = 0
  3551.       when "SUBTARGET"
  3552.         act_result = action_subtargets( @action, @parameters )  
  3553.       when "TARGET_SELECT", "TARGET SELECT", "TARGETSELECT"
  3554.         act_result = action_target_select( @action, @parameters )
  3555.       when "SET_ORIGIN", "SET ORIGIN", "SETORIGIN"
  3556.         act_result = action_origin( @action, @parameters )
  3557.       when "MOVE"  
  3558.         act_result = action_move( @action, @parameters )
  3559.       when "JUMP"  
  3560.         act_result = action_jump( @action, @parameters )  
  3561.       when "SETITEM", "SET_ITEM", "SET ITEM"  
  3562.         act_result = action_set_item( @action, @parameters )
  3563.       when "SETSKILL", "SET_SKILL", "SET SKILL"  
  3564.         act_result = action_set_skill( @action, @parameters )
  3565.       when "PROJECTILE"  
  3566.         act_result = action_projectile( @action, @parameters )
  3567.       when "SCRIPT"  
  3568.         act_result = action_script( @action, @parameters )
  3569.       when "THROUGH"  
  3570.         act_result = action_through( @action, @parameters )
  3571.       when "PARENTWAIT", "PARENT_WAIT", "PARENT WAIT"  
  3572.         act_result = action_parent_wait( @action, @parameters )
  3573.       when "WAIT", "WAIT_FOR_EVENT", "WAIT FOR ANIMATION"
  3574.         act_result = action_wait( @action, @parameters )
  3575.       when "SE"  
  3576.         act_result = action_se( @action, @parameters )
  3577.       when "ME"  
  3578.         act_result = action_me( @action, @parameters )  
  3579.       else
  3580.         act_result = extended_actions( @action, @parameters )
  3581.       end
  3582.       if act_result == -1
  3583.         puts "ERROR: -1 returned for action #{self}"
  3584.       else
  3585.         puts "BING: #{act_result} returned for action #{self}"
  3586.       end if YGG.debug_mode?
  3587.       @list_index += 1
  3588.       break if act_result == 1
  3589.     end
  3590.   end
  3591.  
  3592.   #--------------------------------------------------------------------------#
  3593.   # * new-method :extended_actions
  3594.   #--------------------------------------------------------------------------#  
  3595.   def extended_actions( action, parameters )
  3596.   end
  3597.  
  3598.   #--------------------------------------------------------------------------#
  3599.   # * new-method :action_set_skill
  3600.   #--------------------------------------------------------------------------#  
  3601.   def action_set_skill( action, parameters )
  3602.     @skill_id = parameters[0].to_i
  3603.     return 0
  3604.   end  
  3605.  
  3606.   #--------------------------------------------------------------------------#
  3607.   # * new-method :action_set_item
  3608.   #--------------------------------------------------------------------------#  
  3609.   def action_set_item( action, parameters )
  3610.     @item_id = parameters[0].to_i
  3611.     return 0
  3612.   end  
  3613.  
  3614.   #--------------------------------------------------------------------------#
  3615.   # * new-method :action_actionlist
  3616.   #--------------------------------------------------------------------------#  
  3617.   def action_actionlist( action, parameters )
  3618.     @active_list = @active_list.slice(0, @list_index+1) +
  3619.       ::YGG.get_action_list( parameters[0] ) +
  3620.       @active_list.slice( @list_index+1, @active_list.size )
  3621.     @list_index += 1
  3622.     return 0
  3623.   end  
  3624.    
  3625.   #--------------------------------------------------------------------------#
  3626.   # * new-method :action_animation
  3627.   #--------------------------------------------------------------------------#              
  3628.   def action_animation( action, parameters )
  3629.     p0 = parameters[0].to_s.upcase()
  3630.     p1 = parameters[1].upcase()
  3631.     p2 = parameters[2].upcase()
  3632.    
  3633.     id = 0
  3634.     case p0
  3635.     when "OBJ"
  3636.       id = $data_skills[@skill_id].animation_id if @skill_id > 0
  3637.       id = $data_items[@item_id].animation_id    if @item_id > 0
  3638.       id = @user_event.ygg_battler.atk_animation_id() if id == -1
  3639.     when "ATK", "ATTACK"  
  3640.       id = @user_event.ygg_battler.atk_animation_id()
  3641.     else
  3642.       id = p0.to_i
  3643.     end  
  3644.    
  3645.     case p1  
  3646.     when "POS"  
  3647.       event = @user_event
  3648.       x, y = *YGG.offset_xy(
  3649.        event.x, event.y,
  3650.        [parameters[3].to_i(), parameters[4].to_i()],
  3651.        event.direction )
  3652.       targets = action_target( "TARGET", ["MAP_XY", x, y], true )
  3653.       case p2
  3654.       when "NORMAL"
  3655.         targets.each { |t| t.animation_id = id }
  3656.       when "WILD"    
  3657.         $scene.push_ygg_anim( id, x, y, targets, false ) if $scene.is_a?( Scene_Map )
  3658.       end
  3659.     else
  3660.       action_target( "TARGET", [p1] ).each { |t|
  3661.         case p2
  3662.         when "NORMAL" ; t.animation_id = id
  3663.         when "WILD"   ; t.ygg_anims.push( id )
  3664.         end
  3665.       }  
  3666.     end
  3667.     return 0
  3668.   end
  3669.  
  3670.   #--------------------------------------------------------------------------#
  3671.   # * new-method :action_origin
  3672.   #--------------------------------------------------------------------------#  
  3673.   def action_origin( action, parameters )
  3674.     action_target( "TARGET", parameters, true ).each { |character|
  3675.       character.set_orgin() }
  3676.     return 0  
  3677.   end  
  3678.    
  3679.   #--------------------------------------------------------------------------#
  3680.   # * new-method :action_move
  3681.   #--------------------------------------------------------------------------#    
  3682.   def action_move( action, parameters )
  3683.     targets = action_target( "TARGET", [parameters[0]], true )
  3684.     targets.each { |character|
  3685.       case parameters[1].upcase
  3686.       when "FORWARD"
  3687.         character.move_forward()
  3688.       when "BACKWARD"
  3689.         character.move_backward()  
  3690.       when "UP"
  3691.         character.move_up()
  3692.       when "DOWN"
  3693.         character.move_down()
  3694.       when "LEFT"
  3695.         character.move_left()
  3696.       when "RIGHT"
  3697.         character.move_right()
  3698.       when "TO"  
  3699.         case parameters[2]
  3700.         when "ORIGIN"
  3701.           character.moveto( character.origin.x, character.origin.y )
  3702.         else
  3703.           prms = parameters.slice( 2, parameters.size )
  3704.           action_targets( "TARGET", prms, true ).each { |target|
  3705.             character.moveto( target.x, target.y )
  3706.           }
  3707.         end  
  3708.       when "TOXY", "TO_XY", "TO XY"  
  3709.         dist, sway = parameters[2], parameters[3]
  3710.         case character.direction
  3711.         when 2 # // Down
  3712.           x, y = character.x+sway, character.y+dist
  3713.         when 4 # // Left
  3714.           x, y = character.x-dist, character.y+sway
  3715.         when 6 # // Right
  3716.           x, y = character.x+dist, character.y-sway
  3717.         when 8 # // Up
  3718.           x, y = character.x-sway, character.y-dist
  3719.         end
  3720.         character.moveto( x, y )
  3721.       when "TOMAPXY", "TO_MAP_XY", "TO MAP XY"  
  3722.         character.moveto( parameters[2].to_i, parameters[3].to_i )
  3723.       when "TURNUP", "TURN_UP", "TURN UP"
  3724.         character.turn_up()
  3725.       when "TURNDOWN", "TURN_DOWN", "TURN DOWN"
  3726.         character.turn_down()
  3727.       when "TURNLEFT", "TURN_LEFT", "TURN LEFT"
  3728.         character.turn_left()
  3729.       when "TURNRIGHT", "TURN_RIGHT", "TURN RIGHT"
  3730.         character.turn_right()
  3731.       when "TURNRIGHT90", "TURN_RIGHT_90", "TURN RIGHT 90"
  3732.         character.turn_right_90()
  3733.       when "TURNLEFT90", "TURN_LEFT_90", "TURN LEFT 90"
  3734.         character.turn_left_90()  
  3735.       when "TURN180", "TURN_180", "TURN 180"
  3736.         character.turn_180()
  3737.       when "TURNTO", "TURN_TO", "TURN TO"
  3738.         prms = parameters.slice( 2, parameters.size )
  3739.         action_targets( "TARGET", prms, true ).each { |target|
  3740.           character.turn_to_coord( target.x, target.y ) }
  3741.       end
  3742.     }  
  3743.     return 0
  3744.   end
  3745.  
  3746.   #--------------------------------------------------------------------------#
  3747.   # * new-method :action_jump
  3748.   #--------------------------------------------------------------------------#    
  3749.   def action_jump( action, parameters )  
  3750.     users = action_target( "TARGET", parameters[0], true )
  3751.     users.each { |character|
  3752.       case parameters[1].upcase
  3753.       when "XY"
  3754.         character.jump( parameters[2].to_i, parameters[3].to_i )
  3755.       else
  3756.         action_target( "TARGET", parameters[1], true ).each { |t|
  3757.           character.jump_to_char( t )
  3758.         }
  3759.       end  
  3760.     }
  3761.     return 0
  3762.   end
  3763.  
  3764.   #--------------------------------------------------------------------------#
  3765.   # * new-method :action_charge
  3766.   #--------------------------------------------------------------------------#    
  3767.   def action_charge( action, parameters )
  3768.     targets = action_target( "TARGET", parameters[0], true )
  3769.     value = parameters[2].upcase == "MAX" ? t.ygg_battler.cooldown_max : parameters[2].to_i
  3770.     case parameters[1].upcase
  3771.     when "ADD"
  3772.       targets.each { |t| t.ygg_battler.cooldown += value }
  3773.     when "SUB"  
  3774.       targets.each { |t| t.ygg_battler.cooldown -= value }
  3775.     when "SET"  
  3776.       targets.each { |t| t.ygg_battler.cooldown  = value }
  3777.     end  
  3778.     return 0
  3779.   end
  3780.  
  3781.   #--------------------------------------------------------------------------#
  3782.   # * new-method :action_common_event
  3783.   #--------------------------------------------------------------------------#  
  3784.   def action_common_event( action, parameters )
  3785.     case parameters[0].upcase
  3786.     when "SKILL"
  3787.       common_event_id = $data_skills[parameters[1].to_i].common_event_id
  3788.     when "ITEM"  
  3789.       common_event_id = $data_items[parameters[1].to_i].common_event_id
  3790.     when "OBJ"  
  3791.       if @skill_id > 0
  3792.         action_common_event( "COMMON_EVENT", ["SKILL", @skill_id, parameters[2]] )
  3793.       elsif @item_id > 0
  3794.         action_common_event( "COMMON_EVENT", ["ITEM", @item_id, parameters[2]] )
  3795.       end  
  3796.       return
  3797.     when "ID"  
  3798.       common_event_id = parameters[1].to_i
  3799.     end  
  3800.     @interpreter.setup( $data_common_events[common_event_id].list )
  3801.     @wait_for_comev = parameters[2].to_s.upcase == "WAIT"
  3802.     return @wait_for_comev ? 1 : 0
  3803.   end
  3804.  
  3805.   #--------------------------------------------------------------------------#
  3806.   # * new-method :action_range
  3807.   #--------------------------------------------------------------------------#      
  3808.   def action_range( action, parameters )
  3809.     case parameters[0].upcase
  3810.     when "ADD"
  3811.       @range.push( [ parameters[1].to_i, parameters[2].to_i ] )
  3812.     when "SUB"  
  3813.       @range -= [[ parameters[1].to_i, parameters[2].to_i ]]
  3814.     when "CLEAR"  
  3815.       @range.clear()
  3816.     when "CREATE"  
  3817.       rng, minrng, type = parameters[1].to_i, parameters[2].to_i, parameters[3].to_i
  3818.       target = action_target( "TARGET", [parameters[4].to_s], true )[0]
  3819.       direction = target.nil?() ? parameters[4].to_i : target.direction
  3820.       @range = YGG.create_range_data( rng, minrng, type, direction )
  3821.     end  
  3822.     return 0
  3823.   end  
  3824.  
  3825.   #--------------------------------------------------------------------------#
  3826.   # * new-method :action_target
  3827.   #--------------------------------------------------------------------------#          
  3828.   def action_target( action, parameters, return_only=false )
  3829.     raise "Parameter is not an array" unless parameters.is_a?( Array )
  3830.     targets = []
  3831.     case parameters[0].upcase()
  3832.     when "AFFECTED"
  3833.       targets = @affected_targets
  3834.     when "PARENT"
  3835.       targets = [ @parent_event ]
  3836.     when "USER"
  3837.       targets = [ @user_event ]
  3838.     when "TARGET"  
  3839.       targets = [ @target_events[0] ]
  3840.     when "TARGETS"  
  3841.       targets = @target_events
  3842.     when "ALLIES"  
  3843.       targets = @target_events.inject([]) { |r, e| r.push( e ) if @user_event.ally_character?( e ) ; r }
  3844.     when "ENEMIES"  
  3845.       targets = @target_events.inject([]) { |r, e| r.push( e ) if @user_event.enemy_character?( e ) ; r }
  3846.     when "RANDTARGET"  
  3847.       targets = action_target( "TARGET", ["TARGETS"], true )
  3848.       targets = [targets[rand(targets.size)]]
  3849.     when "RANDALLY"  
  3850.       targets = action_target( "TARGET", ["ALLIES"], true )
  3851.       targets = [targets[rand(targets.size)]]  
  3852.     when "RANDENEMY"  
  3853.       targets = action_target( "TARGET", ["ENEMIES"], true )
  3854.       targets = [targets[rand(targets.size)]]    
  3855.     when "SCREEN", "ONSCREEN", "ON_SCREEN"  
  3856.       $game_yggdrasil.battlers.each { |ev|
  3857.         targets.push( ev ) if ev.limitedOnScreen?()
  3858.       }
  3859.     when "OFFSCREEN", "OFF_SCREEN"  
  3860.       $game_yggdrasil.battlers.each { |ev|
  3861.         targets.push( ev ) if !ev.limitedOnScreen?()
  3862.       }
  3863.     when "MAP_XY"
  3864.       xy_list = [ [parameters[1].to_i, parameters[2].to_i] ]
  3865.       targets = @user_event.get_target_events( xy_list )
  3866.     when "XY"  
  3867.       xy_list = [ [parameters[1].to_i, parameters[2].to_i] ]
  3868.       xy_list = YGG::offset_xy_list( @user_event.x, @user_event.y, xy_list, @user_event.direction )
  3869.       targets = @user_event.get_target_events( xy_list )
  3870.     when "RANGE"  
  3871.       xy_list = @range
  3872.       xy_list = YGG::offset_xy_list( @user_event.x, @user_event.y, xy_list, @user_event.direction )
  3873.       targets = @user_event.get_target_events( xy_list )
  3874.     end
  3875.     targets = targets.compact.uniq
  3876.     @target_events = targets unless return_only
  3877.     return targets
  3878.   end
  3879.  
  3880.   #--------------------------------------------------------------------------#
  3881.   # * new-method :action_subtargets
  3882.   #--------------------------------------------------------------------------#  
  3883.   def action_subtargets( action, parameters )
  3884.     @target_events -= action_target( "TARGET", parameters, true )
  3885.     return 0
  3886.   end
  3887.  
  3888.   #--------------------------------------------------------------------------#
  3889.   # * new-method :action_target_select
  3890.   #--------------------------------------------------------------------------#  
  3891.   def action_target_select( action, parameters )
  3892.     if @parent_event.ai_operated?()
  3893.       targs = action_target( "TARGET", parameters.slice( 1, parameters.size ) ).sort_by { rand }
  3894.       result = [] ; for i in 0...parameters[0].to_i ; result.push( targs[i] ) ; end
  3895.       @target_events = result.compact.uniq
  3896.     else  
  3897.       @target_events = $game_yggdrasil.start_target_selection( parameters[0].to_i,
  3898.         action_target( "TARGET", parameters.slice( 1, parameters.size ), true ) )
  3899.     end    
  3900.     return 0
  3901.   end
  3902.  
  3903.   #--------------------------------------------------------------------------#
  3904.   # * new-method :action_effect
  3905.   #--------------------------------------------------------------------------#            
  3906.   def action_effect( action, parameters )
  3907.     users   = action_target( "TARGET", [parameters[0]], true )
  3908.     targets = action_target( "TARGET", [parameters[1]], true )
  3909.     case action.upcase()
  3910.     when "ATTACKEFFECT", "ATTACK_EFFECT", "ATTACK EFFECT"
  3911.       users.each { |user|
  3912.         user.equip_handle( 0 ).do_attack()
  3913.         $game_yggdrasil.action_attack(
  3914.           { :user => user, :targets => targets }
  3915.         )
  3916.       }  
  3917.     when "SKILLEFFECT", "SKILL_EFFECT", "SKILL EFFECT"  
  3918.       users.each { |user|
  3919.         case parameters[2].upcase()
  3920.         when "PRESET", "OBJ"
  3921.           sid = @skill_id
  3922.         else ; sid = parameters[2].to_i
  3923.         end  
  3924.         $game_yggdrasil.action_skill(
  3925.           { :user => user, :targets => targets, :obj => $data_skills[sid] }
  3926.         )
  3927.       }  
  3928.     when "ITEMEFFECT", "ITEM_EFFECT", "ITEM EFFECT"  
  3929.       users.each { |user|
  3930.         case parameters[2].upcase()
  3931.         when "PRESET", "OBJ"
  3932.           iid = @item_id
  3933.         else ; iid = parameters[2].to_i
  3934.         end  
  3935.         $game_yggdrasil.action_item(
  3936.           { :user => user, :targets => targets, :obj => $data_items[iid] }
  3937.         )
  3938.       }  
  3939.     end  
  3940.     @affected_targets.clear()
  3941.     (users).each { |t|
  3942.       t.ygg_battler.clear_action_results() unless t.ygg_battler.nil?() unless t.nil?()
  3943.     }
  3944.     (targets).each { |t|
  3945.       @affected_targets << t unless (t.ygg_battler.skipped ||
  3946.         t.ygg_battler.missed ||
  3947.         t.ygg_battler.evaded) unless t.ygg_battler.nil?()
  3948.       t.ygg_battler.clear_action_results() unless t.ygg_battler.nil?() unless t.nil?()
  3949.     }
  3950.     return 0
  3951.   end
  3952.  
  3953.   #--------------------------------------------------------------------------#
  3954.   # * new-method :action_guard
  3955.   #--------------------------------------------------------------------------#                  
  3956.   def action_guard( action, parameters )
  3957.     @user_event.guard_time = parameters[0].to_i
  3958.     @user_event.equip_handle( 1 ).do_guard()
  3959.     return 0
  3960.   end
  3961.  
  3962.   #--------------------------------------------------------------------------#
  3963.   # * new-method :action_projectile
  3964.   #--------------------------------------------------------------------------#                  
  3965.   def action_projectile( action, parameters )
  3966.     users = action_target( "TARGET", [parameters[0]], true )
  3967.     case parameters[1].upcase
  3968.     when "PARENT"
  3969.       direction = action_target( "TARGET", ["PARENT"], true )[0].direction
  3970.     when "USER"
  3971.       direction = action_target( "TARGET", ["USER"], true )[0].direction
  3972.     when "TARGET"  
  3973.       direction = action_target( "TARGET", ["TARGET"], true )[0].direction
  3974.     else  
  3975.       direction = parameters[1].to_i
  3976.     end  
  3977.     projectile = ::YGG::PROJECTILE_MAP[parameters[2].to_s]
  3978.     setup_code = ::YGG::PROJETILE_SETUP[parameters[3].to_s]
  3979.     sp_code    = (parameters[4] || 0).to_s.to_i
  3980.     users.each { |user|
  3981.       pro = projectile.new( user, setup_code )
  3982.       case sp_code
  3983.       when 0
  3984.         pro.moveto( user.x, user.y )
  3985.       when 1
  3986.         pro.moveto( *user.get_xy_infront( 1, 0 ) )
  3987.       when 2
  3988.         pro.moveto( *user.get_xy_infront( -1, 0 ) )  
  3989.       end  
  3990.       pro.set_direction( direction )
  3991.       $game_yggdrasil.add_projectile( pro )
  3992.     }  
  3993.     return 0
  3994.   end
  3995.  
  3996.   #--------------------------------------------------------------------------#
  3997.   # * new-method :action_script
  3998.   #--------------------------------------------------------------------------#                  
  3999.   def action_script( action, parameters )
  4000.     user    = action_target( "TARGET", ["USER"] )
  4001.     target  = action_target( "TARGET", ["TARGET"] )
  4002.     targets = action_target( "TARGET", ["TARGETS"] )
  4003.     eval( parameters.to_s )
  4004.     return 0
  4005.   end
  4006.  
  4007.   #--------------------------------------------------------------------------#
  4008.   # * new-method :action_through
  4009.   #--------------------------------------------------------------------------#                  
  4010.   def action_through( action, parameters )
  4011.     targets = action_target( "TARGET", [parameters[0]] )
  4012.     case parameters[1].upcase
  4013.     when "TRUE", "ON", "YES"
  4014.       targets.each { |t| t.set_through( true ) }
  4015.     when "FALSE", "OFF", "NO"
  4016.       targets.each { |t| t.set_through( false ) }
  4017.     end
  4018.     return 0
  4019.   end
  4020.  
  4021.   #--------------------------------------------------------------------------#
  4022.   # * new-method :action_parent_wait
  4023.   #--------------------------------------------------------------------------#                  
  4024.   def action_parent_wait( action, parameters )
  4025.     @user_event.wait_count = parameters[0].to_i
  4026.     return 1
  4027.   end
  4028.  
  4029.   #--------------------------------------------------------------------------#
  4030.   # * new-method :action_wait
  4031.   #--------------------------------------------------------------------------#                  
  4032.   def action_wait( action, parameters )
  4033.     case action.upcase
  4034.     when "WAIT FOR ANIMATION"
  4035.       @wait_count = $data_animations[parameters[0].to_i].frame_max * ::Sprite_Base::RATE
  4036.     when "WAIT"
  4037.       @wait_count = parameters[0].to_i
  4038.     end  
  4039.     return 1
  4040.   end
  4041.  
  4042.   #--------------------------------------------------------------------------#
  4043.   # * new-method :action_se
  4044.   #--------------------------------------------------------------------------#
  4045.   def action_se( action, parameters )
  4046.     RPG::SE.new( parameters[0].to_s, parameters[1].to_i, parameters[2].to_i ).play()
  4047.     return 0
  4048.   end
  4049.  
  4050.   #--------------------------------------------------------------------------#
  4051.   # * new-method :action_me
  4052.   #--------------------------------------------------------------------------#
  4053.   def action_me( action, parameters )
  4054.     RPG::ME.new( parameters[0].to_s, parameters[1].to_i, parameters[2].to_i ).play()
  4055.     return 0
  4056.   end
  4057.  
  4058. end  
  4059.  
  4060. # // (YGG_MC) - Mix Code
  4061. #==============================================================================#
  4062. # // RMVX Mixins
  4063. #==============================================================================#
  4064. # ** RPG::Animation
  4065. #==============================================================================#
  4066. class RPG::Animation
  4067.  
  4068.   #----------------------------------------------------------------------------#
  4069.   # * new-method :cell_count
  4070.   #----------------------------------------------------------------------------#
  4071.   def cell_count() ; end unless method_defined? :cell_count
  4072.    
  4073. end  
  4074.  
  4075. #==============================================================================#
  4076. # ** RPG::BaseItem
  4077. #==============================================================================#
  4078. class RPG::BaseItem
  4079.  
  4080.   include YGG::Caches1x6
  4081.  
  4082.   #----------------------------------------------------------------------------#
  4083.   # * Public Instance Variable(s)
  4084.   #----------------------------------------------------------------------------#
  4085.   attr_accessor :pickup_sfx
  4086.  
  4087.   #----------------------------------------------------------------------------#
  4088.   # * new-method :pickup_sfx
  4089.   #----------------------------------------------------------------------------#
  4090.   def pickup_sfx()
  4091.     @pickup_sfx ||= self.note =~ YGG::REGEXP::BASE_ITEM::PICKUP_SFX ?
  4092.       RPG::SE.new( $1, $2.to_i, $3.to_i ) : ::YGG::SOUND_ITEM
  4093.     return @pickup_sfx
  4094.   end
  4095.  
  4096.   #----------------------------------------------------------------------------#
  4097.   # * new-method :drops_attraction?
  4098.   #----------------------------------------------------------------------------#
  4099.   def drops_attraction?() ; return @drops_attraction ; end
  4100.  
  4101. end
  4102.  
  4103. #==============================================================================#
  4104. # ** RPG::Armor
  4105. #==============================================================================#
  4106. class RPG::Armor
  4107.  
  4108.   #----------------------------------------------------------------------------#
  4109.   # * super-method :drops_attraction?
  4110.   #----------------------------------------------------------------------------#  
  4111.   def yggdrasil_1x6_cache_end()
  4112.     super()
  4113.     @ygg_actions[0] ||= ::YGG.get_action_list( "GUARD_ACTION" )
  4114.   end
  4115.  
  4116. end
  4117.  
  4118. #==============================================================================#
  4119. # ** RPG::UsableItem
  4120. #==============================================================================#
  4121. class RPG::UsableItem
  4122.  
  4123.   #----------------------------------------------------------------------------#
  4124.   # * Public Instance Variable(s)
  4125.   #----------------------------------------------------------------------------#  
  4126.   attr_accessor :guardable
  4127.  
  4128.   #----------------------------------------------------------------------------#
  4129.   # * super-method :yggdrasil_1x6_cache_start
  4130.   #----------------------------------------------------------------------------#
  4131.   def yggdrasil_1x6_cache_start()
  4132.     super()
  4133.     @__use_target_select = false
  4134.     @guardable = false
  4135.   end
  4136.  
  4137.   #----------------------------------------------------------------------------#
  4138.   # * super-method :yggdrasil_1x6_cache_check
  4139.   #----------------------------------------------------------------------------#  
  4140.   def yggdrasil_1x6_cache_check( line )
  4141.     super( line )
  4142.     case line
  4143.     when ::YGG::REGEXP::SKILL::UTARGET_SELECT
  4144.       @__use_target_select = true
  4145.     when ::YGG::REGEXP::SKILL::GUARDABLE
  4146.       @guardable = true
  4147.     when ::YGG::REGEXP::SKILL::NOT_GUARDABLE  
  4148.       @guardable = false
  4149.     end  
  4150.   end
  4151.  
  4152.   #----------------------------------------------------------------------------#
  4153.   # * super-method :yggdrasil_1x6_cache_end
  4154.   #----------------------------------------------------------------------------#  
  4155.   def yggdrasil_1x6_cache_end()
  4156.     super()
  4157.     case @scope
  4158.     when 0     # // None
  4159.       @ygg_actions[0] ||= ::YGG.get_action_list( "NORMAL_OBJ0" ).clone
  4160.     when 11    # // User
  4161.       @ygg_actions[0] ||= ::YGG.get_action_list( "NORMAL_OBJ1" ).clone
  4162.     when 1     # // 1 Enemy
  4163.       @ygg_actions[0] ||= @__use_target_select ?
  4164.         ::YGG.get_action_list( "NORMAL_OBJ2_T1" ).clone :
  4165.         ::YGG.get_action_list( "NORMAL_OBJ2_1" ).clone
  4166.     when 3     # // 1 Enemy Dual
  4167.       @ygg_actions[0] ||= @__use_target_select ?
  4168.         ::YGG.get_action_list( "NORMAL_OBJ2_T2" ).clone :
  4169.         ::YGG.get_action_list( "NORMAL_OBJ2_2" ).clone
  4170.     when 4     # // 1 Random Enemy
  4171.       @ygg_actions[0] ||= ::YGG.get_action_list( "NORMAL_OBJ2_R1" ).clone
  4172.     when 5     # // 2 Random Enemies
  4173.       @ygg_actions[0] ||= ::YGG.get_action_list( "NORMAL_OBJ2_R2" ).clone
  4174.     when 6     # // 3 Random Enemies
  4175.       @ygg_actions[0] ||= ::YGG.get_action_list( "NORMAL_OBJ2_R3" ).clone  
  4176.     when 7, 9  # // 1 Ally
  4177.       @ygg_actions[0] ||= @__use_target_select ?
  4178.         ::YGG.get_action_list( "NORMAL_OBJ3_T1" ).clone :
  4179.         ::YGG.get_action_list( "NORMAL_OBJ3_1" ).clone
  4180.     when 2     # // All Enemies
  4181.       @ygg_actions[0] ||= ::YGG.get_action_list( "NORMAL_OBJ4" ).clone  
  4182.     when 8, 10 # // All Allies
  4183.       @ygg_actions[0] ||= ::YGG.get_action_list( "NORMAL_OBJ5" ).clone  
  4184.     end  
  4185.   end
  4186.  
  4187. end
  4188.  
  4189. #==============================================================================#
  4190. # ** RPG::Enemy
  4191. #==============================================================================#
  4192. class RPG::Enemy
  4193.  
  4194.   include YGG::Caches1x6
  4195.  
  4196.   #----------------------------------------------------------------------------#
  4197.   # * Public Instance Variable(s)
  4198.   #----------------------------------------------------------------------------#  
  4199.   attr_accessor :atk_animation_id
  4200.   attr_accessor :atk_animation_id2
  4201.   attr_accessor :drop_items
  4202.   attr_accessor :gold_variation
  4203.   attr_accessor :equip_icons
  4204.   attr_accessor :use_equipment
  4205.   attr_accessor :atk_act_name
  4206.   attr_accessor :grd_act_name
  4207.   #----------------------------------------------------------------------------#
  4208.   # * super-method :yggdrasil_1x6_cache_check
  4209.   #----------------------------------------------------------------------------#  
  4210.   def yggdrasil_1x6_cache_start()
  4211.     super()
  4212.     @drop_items   ||= []  ; @__drop_id = -1
  4213.     @__drop         = nil ; @__drop_reading = false
  4214.     @gold_variation = 0
  4215.     @equip_icons    = Array.new( 2, 0 )
  4216.     @use_equipment  = false
  4217.     @atk_act_name, @grd_act_name = "Swing1", "GRise1"
  4218.   end
  4219.  
  4220.   #----------------------------------------------------------------------------#
  4221.   # * super-method :yggdrasil_1x6_cache_check
  4222.   #----------------------------------------------------------------------------#  
  4223.   def yggdrasil_1x6_cache_check( line )
  4224.     super( line )
  4225.     case line
  4226.     when YGG::REGEXP::ENEMY::ATK_ANIMATION_ID
  4227.       @atk_animation_id = $1.to_i
  4228.     when YGG::REGEXP::ENEMY::DROP_ITEM2
  4229.       @drop_items[@__drop_id] = @__drop if @__drop_id > -1
  4230.       @__drop_id = -1 ; @__drop = nil ; @__drop_reading = false  
  4231.     when YGG::REGEXP::ENEMY::DROP_ITEM1
  4232.       @__drop_id = $1.to_i ; @__drop = DropItem.new() ; @__drop_reading = true    
  4233.     when YGG::REGEXP::ENEMY::DROP_CLEAR  
  4234.       @drop_items.clear()
  4235.     when YGG::REGEXP::ENEMY::GOLD_VARI
  4236.       @gold_variation = $1.to_i
  4237.     when YGG::REGEXP::ENEMY::EQUIP_ICONS
  4238.       icon = 0
  4239.       eq_id = $1.to_i
  4240.       n = $2
  4241.       case n
  4242.       when /(?:WEP|WEAPON)[ ](\d+)/i
  4243.         icon = $data_weapons[$1.to_i].icon_index
  4244.       when /(?:ARM|ARMOR)[ ](\d+)/i
  4245.         icon = $data_armors[$1.to_i].icon_index
  4246.       when /(?:SKL|SKILL)[ ](\d+)/i  
  4247.         icon = $data_skills[$1.to_i].icon_index
  4248.       when /(?:ITE|ITEM)[ ](\d+)/i
  4249.         icon = $data_items[$1.to_i].icon_index
  4250.       else
  4251.         icon = n.to_i
  4252.       end  
  4253.       @equip_icons[eq_id] = icon
  4254.     when YGG::REGEXP::ENEMY::USE_EQUIPMENT
  4255.       @use_equipment = true
  4256.     when YGG::REGEXP::ENEMY::NO_EQUIPMENT
  4257.       @use_equipment = false  
  4258.     else
  4259.       if @__drop_reading
  4260.         case line
  4261.         # // Type of the drop item (0: none, 1: item, 2: weapon, 3: armor)
  4262.         when /kind:[ ](\d+)/i
  4263.           @__drop.kind = $1.to_i
  4264.         when /(?:item_id|item id|itemid):[ ](\d+)/i  
  4265.           @__drop.kind = 1 ; @__drop.item_id = $1.to_i
  4266.         when /(?:weapon_id|weapon id|weaponid):[ ](\d+)/i  
  4267.           @__drop.kind = 2 ; @__drop.weapon_id = $1.to_i
  4268.         when /(?:armor_id|armor id|armorid):[ ](\d+)/i    
  4269.           @__drop.kind = 3 ; @__drop.armor_id = $1.to_i
  4270.         when /(?:denom|denominator|prob|probability):[ ](\d+)/i  
  4271.           @__drop.denominator = $1.to_i
  4272.         end
  4273.       end  
  4274.     end  
  4275.   end
  4276.  
  4277.   #----------------------------------------------------------------------------#
  4278.   # * super-method :yggdrasil_1x6_cache_end
  4279.   #----------------------------------------------------------------------------#  
  4280.   def yggdrasil_1x6_cache_end()
  4281.     super()
  4282.     @atk_animation_id  ||= 1
  4283.     @atk_animation_id2 ||= 0
  4284.     @ygg_actions[0]    ||= ::YGG.get_action_list( "NORMAL_ATTACK_EN" ) # // Attack Action
  4285.     @ygg_actions[1]    ||= ::YGG.get_action_list( "GUARD_ACTION_EN" )  # // Guard Action
  4286.     @ygg_actions[2]    ||= ::YGG.get_action_list( "ESCAPE_ACTION_EN" ) # // Escape Action
  4287.     @ygg_actions[3]    ||= ::YGG.get_action_list( "WAIT_ACTION_EN" )   # // Wait Action
  4288.     @drop_items[1]     ||= @drop_item1
  4289.     @drop_items[2]     ||= @drop_item2
  4290.     # // Match Drop Items D: We dont want mismatch and chaos >:
  4291.     @drop_item1 = @drop_items[1]
  4292.     @drop_item2 = @drop_items[2]
  4293.   end
  4294.  
  4295. end  
  4296.  
  4297. #==============================================================================#
  4298. # ** RPG::State
  4299. #==============================================================================#
  4300. class RPG::State
  4301.  
  4302.   #--------------------------------------------------------------------------#
  4303.   # * Public Instance Variable(s)
  4304.   #--------------------------------------------------------------------------#  
  4305.   attr_accessor :hold_ticks
  4306.   attr_accessor :effect_tone
  4307.   attr_accessor :tone_effect
  4308.   attr_accessor :move_mod
  4309.  
  4310.   #----------------------------------------------------------------------------#
  4311.   # * new-method :yggdrasil_1x6_cache
  4312.   #----------------------------------------------------------------------------#  
  4313.   def yggdrasil_1x6_cache()
  4314.     yggdrasil_1x6_cache_start()
  4315.     self.note.split(/[\r\n]+/).each { |line| yggdrasil_1x6_cache_check( line ) }
  4316.     yggdrasil_1x6_cache_end()
  4317.   end
  4318.  
  4319.   #----------------------------------------------------------------------------#
  4320.   # * new-method :yggdrasil_1x6_cache_start
  4321.   #----------------------------------------------------------------------------#  
  4322.   def yggdrasil_1x6_cache_start()
  4323.     @hold_ticks  = self.hold_turn * ::YGG::STATE_TURN_COUNTER
  4324.     @move_mod    = 0
  4325.     @effect_tone = Tone.new( 0, 0, 0, 0 )
  4326.     @tone_effect = false
  4327.     @slip_freq   = ::YGG::SLIP_DAMAGE_FREQUENCY
  4328.   end
  4329.  
  4330.   #----------------------------------------------------------------------------#
  4331.   # * new-method :yggdrasil_1x6_cache_check
  4332.   #----------------------------------------------------------------------------#  
  4333.   def yggdrasil_1x6_cache_check( line )
  4334.     case line
  4335.     when ::YGG::REGEXP::STATE::HOLD_TICKS
  4336.       @hold_ticks = $1.to_i
  4337.     when ::YGG::REGEXP::STATE::TONE  
  4338.       @effect_tone = ::Tone.new( $1.to_i, $2.to_i, $3.to_i, $4.to_i )
  4339.       @tone_effect = true
  4340.     when ::YGG::REGEXP::STATE::MOVE_MOD  
  4341.       @move_mod = $1.to_i
  4342.     when ::YGG::REGEXP::STATE::SLIP_FREQ  
  4343.       @slip_freq = $1.to_i
  4344.     end  
  4345.   end
  4346.  
  4347.   #----------------------------------------------------------------------------#
  4348.   # * new-method :yggdrasil_1x6_cache_end
  4349.   #----------------------------------------------------------------------------#  
  4350.   def yggdrasil_1x6_cache_end()
  4351.   end
  4352.  
  4353.   #----------------------------------------------------------------------------#
  4354.   # * new-method :slip_freq
  4355.   #----------------------------------------------------------------------------#
  4356.   def slip_freq()
  4357.     return self.slip_damage ? @slip_freq : 0
  4358.   end
  4359.  
  4360. end
  4361.  
  4362. #==============================================================================#
  4363. # ** YGG::System ($game_yggdrasil)
  4364. #==============================================================================#
  4365. class YGG::System
  4366.  
  4367.   #--------------------------------------------------------------------------#
  4368.   # * Constants
  4369.   #--------------------------------------------------------------------------#
  4370.   ITEMS_MAPID = ::YGG::ITEM_MAP
  4371.  
  4372.   #--------------------------------------------------------------------------#
  4373.   # * Public Instance Variable(s)
  4374.   #--------------------------------------------------------------------------#
  4375.   attr_accessor :passage_objs
  4376.  
  4377.   attr_reader :projectiles
  4378.   attr_reader :new_projectiles
  4379.  
  4380.   attr_reader :new_poptexts
  4381.  
  4382.   attr_reader :active_ranges
  4383.   attr_reader :battlers
  4384.  
  4385.   #--------------------------------------------------------------------------#
  4386.   # * new-method :initialize
  4387.   #--------------------------------------------------------------------------#
  4388.   def initialize()
  4389.     setup_map( -1 )
  4390.   end
  4391.  
  4392.   #--------------------------------------------------------------------------#
  4393.   # * new-method :hud
  4394.   #--------------------------------------------------------------------------#
  4395.   def hud()
  4396.     @hud ||= YGG::Handlers::HudWrapper.new()
  4397.     return @hud
  4398.   end
  4399.  
  4400.   #--------------------------------------------------------------------------#
  4401.   # * new-method :add_pop
  4402.   #--------------------------------------------------------------------------#
  4403.   def add_pop( poptext, x, y, z=1 )
  4404.     return unless ::YGG::USE_TEXT_POP
  4405.     pop = ::YGG::PopHandler.new( poptext, x, y, z )
  4406.     @pop_texts.push( pop )
  4407.     @new_poptexts  << pop
  4408.     return pop
  4409.   end
  4410.  
  4411.   #--------------------------------------------------------------------------#
  4412.   # * new-method :remove_pop
  4413.   #--------------------------------------------------------------------------#  
  4414.   def remove_pop( pop_handler )
  4415.     pop_handler.force_complete!()
  4416.     @pop_texts.delete( pop_handler )
  4417.     @new_poptexts.delete( pop_handler )
  4418.     return pophandler
  4419.   end
  4420.  
  4421.   #--------------------------------------------------------------------------#
  4422.   # * new-method :add_projectile
  4423.   #--------------------------------------------------------------------------#  
  4424.   def add_projectile( projectile )
  4425.     @projectiles << projectile
  4426.     @new_projectiles << projectile
  4427.     projectile.pro_register()
  4428.     return projectile
  4429.   end
  4430.  
  4431.   #--------------------------------------------------------------------------#
  4432.   # * new-method :remove_projectile
  4433.   #--------------------------------------------------------------------------#  
  4434.   def remove_projectile( projectile )
  4435.     @projectiles.delete( projectile )
  4436.     @new_projectiles.delete( projectile )
  4437.     projectile.pro_unregister()
  4438.     projectile.force_terminate()
  4439.     return projectile
  4440.   end
  4441.  
  4442.   #--------------------------------------------------------------------------#
  4443.   # * new-method :add_battler
  4444.   #--------------------------------------------------------------------------#
  4445.   def add_battler( b ) ; @battlers |= [b] ; end
  4446.  
  4447.   #--------------------------------------------------------------------------#
  4448.   # * new-method :remove_battler
  4449.   #--------------------------------------------------------------------------#
  4450.   def remove_battler( b ) ; @battlers -= [b] ; end
  4451.  
  4452.   #--------------------------------------------------------------------------#
  4453.   # * new-method :flush_battlers
  4454.   #--------------------------------------------------------------------------#
  4455.   def flush_battlers()
  4456.     @battlers.clear()
  4457.   end
  4458.  
  4459.   #--------------------------------------------------------------------------#
  4460.   # * new-method :add_passage_obj
  4461.   #--------------------------------------------------------------------------#
  4462.   def add_passage_obj( obj )
  4463.     @passage_objs |= [obj]
  4464.   end
  4465.  
  4466.   #--------------------------------------------------------------------------#
  4467.   # * new-method :remove_passage_obj
  4468.   #--------------------------------------------------------------------------#
  4469.   def remove_passage_obj( obj )
  4470.     @passage_objs -= [obj]
  4471.   end
  4472.  
  4473.   #--------------------------------------------------------------------------#
  4474.   # * new-method :update
  4475.   #--------------------------------------------------------------------------#
  4476.   def update()
  4477.     update_poptexts()
  4478.     update_drops()
  4479.     update_roam_events()
  4480.     update_projectiles()
  4481.     update_hud()
  4482.   end
  4483.  
  4484.   #--------------------------------------------------------------------------#
  4485.   # * new-method :update_hud
  4486.   #--------------------------------------------------------------------------#
  4487.   def update_hud()
  4488.     self.hud.update()
  4489.   end
  4490.  
  4491.   #--------------------------------------------------------------------------#
  4492.   # * new-method :update_roam_events
  4493.   #--------------------------------------------------------------------------#
  4494.   def update_roam_events()
  4495.     @roam_events.each { |ev| ev.update() }
  4496.   end
  4497.  
  4498.   #--------------------------------------------------------------------------#
  4499.   # * new-method :update_projectiles
  4500.   #--------------------------------------------------------------------------#
  4501.   def update_projectiles()
  4502.     @projectiles = @projectiles.inject([]) { |result, pro|
  4503.       unless pro.terminated?() ; pro.update() ; result << pro  
  4504.       else ; @new_projectiles.delete( pro ) ; pro.registered = false ; end
  4505.       result
  4506.     } unless @projectiles.empty?()
  4507.   end
  4508.  
  4509.   #--------------------------------------------------------------------------#
  4510.   # * new-method :pop_texts
  4511.   #--------------------------------------------------------------------------#
  4512.   def update_poptexts()
  4513.     @pop_texts = @pop_texts.inject([]) { |result, pop|
  4514.       pop.update() ; result << pop unless pop.complete?() ; result
  4515.     } unless @pop_texts.empty?()
  4516.   end
  4517.  
  4518.   #--------------------------------------------------------------------------#
  4519.   # * new-method :pop_texts
  4520.   #--------------------------------------------------------------------------#
  4521.   def pop_texts() ; return @pop_texts ; end
  4522.  
  4523.   #--------------------------------------------------------------------------#
  4524.   # * new-method :roam_xy
  4525.   #--------------------------------------------------------------------------#
  4526.   def roam_xy( x, y )
  4527.     return (
  4528.       @roam_events +
  4529.       @passage_objs).inject([]) { |r, ev| r << ev if ev.pos?( x, y ) ; r }
  4530.   end
  4531.            
  4532.   #--------------------------------------------------------------------------#
  4533.   # * new-method :battlers_xy
  4534.   #--------------------------------------------------------------------------#
  4535.   def battlers_xy( x, y )
  4536.     return @battlers.inject([]) { |result, b| result << b if b.pos?( x, y ) ; result }
  4537.   end
  4538.  
  4539.   #--------------------------------------------------------------------------#
  4540.   # * new-method :battlers_range
  4541.   #--------------------------------------------------------------------------#  
  4542.   def battlers_range( x1, y1, x2, y2 )
  4543.     return @battlers.inject([]) { |result, b|
  4544.       result << b if b.x.between?( x1, x2 ) && b.y.between?( y1, y2 ) ; result }
  4545.   end
  4546.  
  4547.   #--------------------------------------------------------------------------#
  4548.   # * new-method :on?
  4549.   #--------------------------------------------------------------------------#  
  4550.   if ::YGG::ABS_SYSTEM_SWITCH.nil?()
  4551.     def on?() ; return true ; end
  4552.   else
  4553.     def on?() ; return $game_switches[::YGG::ABS_SYSTEM_SWITCH] ; end  
  4554.   end  
  4555.  
  4556.   #--------------------------------------------------------------------------#
  4557.   # * new-method :setup_map
  4558.   #--------------------------------------------------------------------------#
  4559.   def setup_map( map_id )
  4560.     @map_id          = map_id
  4561.     @pop_texts     ||= [] ; @pop_texts.clear()
  4562.     @new_poptexts  ||= [] ; @new_poptexts.clear()
  4563.     @battlers      ||= [] ; @battlers.each { |b| b.ygg_unregister() } ; @battlers.clear()  
  4564.     @active_drops  ||= [] ; @active_drops.clear()
  4565.     @active_ranges ||= [] ; @active_ranges.clear()
  4566.     @projectiles   ||= [] ; @projectiles.clear()  
  4567.     @new_projectiles||=[] ; @new_projectiles.clear()
  4568.     @roam_events   ||= [] ; @roam_events.clear()
  4569.     @passage_objs  ||= [] ; @passage_objs.clear()
  4570.   end  
  4571.  
  4572.   #--------------------------------------------------------------------------#
  4573.   # * new-method :get_map
  4574.   #--------------------------------------------------------------------------#  
  4575.   def get_map( map_id )
  4576.     $game_map.get_map( map_id )
  4577.   end
  4578.  
  4579.   #--------------------------------------------------------------------------#
  4580.   # * new-method :setup_itemmap
  4581.   #--------------------------------------------------------------------------#
  4582.   def setup_itemmap()
  4583.     if $items_map.nil?()
  4584.       $items_map = get_map( ITEMS_MAPID )
  4585.       $items_map.events.values.each { |ev| ev.pages.each { |pg|
  4586.         pg.list = YGG.parse_event_list( pg.list ) } }
  4587.     end  
  4588.   end
  4589.  
  4590.   #--------------------------------------------------------------------------#
  4591.   # * new-method :create_drops
  4592.   #--------------------------------------------------------------------------#
  4593.   def create_drops( x, y, dropee )
  4594.     place_drops( x, y, dropee.items, dropee.gold )
  4595.   end  
  4596.  
  4597.   #--------------------------------------------------------------------------#
  4598.   # * new-method :place_drops
  4599.   #--------------------------------------------------------------------------#
  4600.   def place_drops( x, y, item_set, gold = nil )
  4601.     drops = []  
  4602.     for dr in item_set.compact
  4603.       cc = YGG::Drop_Character.new( dr, YGG::ITEM_FADE_TIME )
  4604.       fail_count = 0
  4605.       dx, dy = x, y
  4606.       loop do
  4607.         x_r = rand(YGG::DROP_SCATTER_DISTANCE)
  4608.         y_r = rand(YGG::DROP_SCATTER_DISTANCE)
  4609.         x_r = -x_r if rand(2) == 0
  4610.         y_r = -y_r if rand(2) == 0
  4611.         dx = x + x_r
  4612.         dy = y + y_r
  4613.         if fail_count > 20 ; break dx, dy = x, y ; end
  4614.         break if $game_map.passable?( dx, dy )
  4615.         fail_count += 1
  4616.       end  
  4617.       cc.moveto( dx, dy )
  4618.       drops.push( cc )
  4619.     end
  4620.     unless gold.nil?() || gold.eql?( 0 )
  4621.       cc = YGG::Drop_Character.new( YGG::Containers::GoldItem.new( gold ), YGG::GOLD_FADE_TIME )
  4622.       cc.moveto( x, y )
  4623.       drops.push( cc )
  4624.     end
  4625.     drops.each { |char|
  4626.       @active_drops.push( char ) ;
  4627.       $scene.spriteset.add_drop_sprite( char ) if $scene.is_a?( Scene_Map )
  4628.     }
  4629.     return drops
  4630.   end
  4631.  
  4632.   #--------------------------------------------------------------------------#
  4633.   # * new-method :items_map
  4634.   #--------------------------------------------------------------------------#
  4635.   def items_map() ; return $items_map ; end
  4636.  
  4637.   #--------------------------------------------------------------------------#
  4638.   # * alias-method :update_drops
  4639.   #--------------------------------------------------------------------------#
  4640.   def update_drops()
  4641.     @active_drops = @active_drops.inject([]) { |result, dr| dr.update()
  4642.       result.push( dr ) unless dr.timeout?() ; result } unless @active_drops.empty?()
  4643.   end
  4644.  
  4645.   #--------------------------------------------------------------------------#
  4646.   # * new-method :active_drops
  4647.   #--------------------------------------------------------------------------#
  4648.   def active_drops() ; return @active_drops ; end
  4649.  
  4650.   #--------------------------------------------------------------------------#
  4651.   # * new-method :drops_xy
  4652.   #--------------------------------------------------------------------------#  
  4653.   def drops_xy( x, y )
  4654.     return self.active_drops.inject([]) { |result, dr|
  4655.       result.push(dr) if dr.pos?(x, y) ; result }
  4656.   end
  4657.  
  4658. end
  4659.  
  4660. #==============================================================================#
  4661. # // Start Yggdrasil MixIn Code  
  4662. #==============================================================================#
  4663. YGG::Containers::Drops = Struct.new( :items, :gold )
  4664. #==============================================================================#
  4665. # ** YGG::MixIns::Actor
  4666. #==============================================================================#
  4667. module YGG::MixIns::Actor
  4668.  
  4669.   #--------------------------------------------------------------------------#
  4670.   # * new-method :create_drops_object
  4671.   #--------------------------------------------------------------------------#  
  4672.   def create_drops_object()
  4673.     return ::YGG::Containers::Drops.new( [], 0 )
  4674.   end
  4675.  
  4676. end
  4677.  
  4678. #==============================================================================#
  4679. # ** YGG::MixIns::Enemy
  4680. #==============================================================================#
  4681. module YGG::MixIns::Enemy
  4682.    
  4683.   #--------------------------------------------------------------------------#
  4684.   # * new-method :create_drops_object
  4685.   #--------------------------------------------------------------------------#  
  4686.   def create_drops_object()
  4687.     return ::YGG::Containers::Drops.new( self.all_drops, self.calc_gold )
  4688.   end
  4689.  
  4690. end
  4691.  
  4692. #==============================================================================#
  4693. # ** YGG::MixIns::Movement
  4694. #==============================================================================#
  4695. module YGG::MixIns::Movement
  4696.  
  4697.   #--------------------------------------------------------------------------#
  4698.   # * new-method :distance_from
  4699.   #--------------------------------------------------------------------------#
  4700.   def distance_from( obj )
  4701.     return (obj.x - self.x).abs + (obj.y - self.y).abs
  4702.   end
  4703.  
  4704.   #--------------------------------------------------------------------------#
  4705.   # * Jump to XY
  4706.   #--------------------------------------------------------------------------#  
  4707.   def jump_to_xy( tx, ty )
  4708.     jump( tx-self.x, ty-self.y )
  4709.   end
  4710.  
  4711.   #--------------------------------------------------------------------------#
  4712.   # * Jump to Character
  4713.   #--------------------------------------------------------------------------#  
  4714.   def jump_to_char( char )
  4715.     jump_to_xy( char.x, char.y )
  4716.   end
  4717.  
  4718.   #--------------------------------------------------------------------------#
  4719.   # * Jump to Event
  4720.   #--------------------------------------------------------------------------#  
  4721.   def jump_to_event( event_id )
  4722.     jump_to_char( $game_map.events[event_id] )
  4723.   end
  4724.  
  4725.   #--------------------------------------------------------------------------#
  4726.   # * new-method :jump_forward
  4727.   #--------------------------------------------------------------------------#
  4728.   def jump_forward( amount, offset )
  4729.     case direction
  4730.     when 2
  4731.       jump( offset, amount )
  4732.     when 4
  4733.       jump( -amount, offset )
  4734.     when 6
  4735.       jump( amount, -offset )
  4736.     when 8
  4737.       jump( -offset, -amount )
  4738.     end  
  4739.   end
  4740.  
  4741.   #--------------------------------------------------------------------------#
  4742.   # * new-method :jump_backward
  4743.   #--------------------------------------------------------------------------#
  4744.   def jump_backward( amount, offset )
  4745.     jump_forward( -amount, -offset )
  4746.   end
  4747.  
  4748.   #--------------------------------------------------------------------------#
  4749.   # * new-method :distance_x_from_tx
  4750.   #--------------------------------------------------------------------------#
  4751.   def distance_x_from_tx( tx )
  4752.     sx = @x - tx
  4753.     if $game_map.loop_horizontal?         # When looping horizontally
  4754.       if sx.abs > $game_map.width / 2     # Larger than half the map width?
  4755.         sx -= $game_map.width             # Subtract map width
  4756.       end
  4757.     end
  4758.     return sx
  4759.   end
  4760.  
  4761.   #--------------------------------------------------------------------------#
  4762.   # * new-method :distance_y_from_ty
  4763.   #--------------------------------------------------------------------------#
  4764.   def distance_y_from_ty( ty )
  4765.     sy = @y - ty
  4766.     if $game_map.loop_vertical?           # When looping vertically
  4767.       if sy.abs > $game_map.height / 2    # Larger than half the map height?
  4768.         sy -= $game_map.height            # Subtract map height
  4769.       end
  4770.     end
  4771.     return sy
  4772.   end
  4773.  
  4774.   #--------------------------------------------------------------------------#
  4775.   # * new-method :move_toward_xy
  4776.   #--------------------------------------------------------------------------#
  4777.   def move_toward_xy( x, y )
  4778.     move_8d = false
  4779.     sx = distance_x_from_tx(x)
  4780.     sy = distance_y_from_ty(y)
  4781.     if move_8d
  4782.       # // Need to work on it
  4783.     else  
  4784.       if sx != 0 or sy != 0
  4785.         if sx.abs > sy.abs                  # Horizontal distance is longer
  4786.           sx > 0 ? move_left : move_right   # Prioritize left-right
  4787.           if @move_failed and sy != 0
  4788.             sy > 0 ? move_up : move_down
  4789.           end
  4790.         else                                # Vertical distance is longer
  4791.           sy > 0 ? move_up : move_down      # Prioritize up-down
  4792.           if @move_failed and sx != 0
  4793.             sx > 0 ? move_left : move_right
  4794.           end
  4795.         end
  4796.       end
  4797.     end  
  4798.   end
  4799.  
  4800.   #--------------------------------------------------------------------------#
  4801.   # * new-method :move_away_from_xy
  4802.   #--------------------------------------------------------------------------#
  4803.   def move_away_from_xy( x, y )
  4804.     move_8d = false
  4805.     sx = distance_x_from_tx(x)
  4806.     sy = distance_y_from_ty(y)
  4807.     if move_8d
  4808.       # // Need to work on it
  4809.     else  
  4810.       if sx != 0 or sy != 0
  4811.         if sx.abs > sy.abs                  # Horizontal distance is longer
  4812.           sx > 0 ? move_right : move_left   # Prioritize left-right
  4813.           if @move_failed and sy != 0
  4814.             sy > 0 ? move_down : move_up
  4815.           end
  4816.         else                                # Vertical distance is longer
  4817.           sy > 0 ? move_down : move_up      # Prioritize up-down
  4818.           if @move_failed and sx != 0
  4819.             sx > 0 ? move_right : move_left
  4820.           end
  4821.         end
  4822.       end
  4823.     end  
  4824.   end
  4825.  
  4826.   #--------------------------------------------------------------------------#
  4827.   # * new-method :move_toward_char
  4828.   #--------------------------------------------------------------------------#
  4829.   def move_toward_char( char )
  4830.     move_toward_xy( char.x, char.y )
  4831.   end
  4832.  
  4833.   #--------------------------------------------------------------------------#
  4834.   # * new-method :move_away_from_xy
  4835.   #--------------------------------------------------------------------------#
  4836.   def move_away_from_char( char )
  4837.     move_away_from_xy( char.x, char.y )
  4838.   end
  4839.  
  4840.   #--------------------------------------------------------------------------#
  4841.   # * new-method :move_toward_event
  4842.   #--------------------------------------------------------------------------#
  4843.   def move_toward_event( event_id )
  4844.     move_toward_char( $game_map.events[event_id] )
  4845.   end  
  4846.  
  4847.   #--------------------------------------------------------------------------#
  4848.   # * new-method :move_away_from_event
  4849.   #--------------------------------------------------------------------------#
  4850.   def move_away_from_event( event_id )
  4851.     move_away_from_char( $game_map.events[event_id] )
  4852.   end
  4853.  
  4854.   #--------------------------------------------------------------------------#
  4855.   # * new-method :thrust_wait
  4856.   #--------------------------------------------------------------------------#
  4857.   def thrust_wait( t=30 ) ; @wait_count = t ; end
  4858.  
  4859.   #--------------------------------------------------------------------------#
  4860.   # * new-method :half_down
  4861.   #--------------------------------------------------------------------------#
  4862.   def half_down( turn_ok=true )
  4863.     turn_down if turn_ok
  4864.     @y = $game_map.round_y(@y + 0.5)
  4865.     @real_y = ((@y - 0.5)*256)
  4866.     @move_failed = false
  4867.   end
  4868.  
  4869.   #--------------------------------------------------------------------------#
  4870.   # * new-method :half_left
  4871.   #--------------------------------------------------------------------------#
  4872.   def half_left( turn_ok=true )
  4873.     turn_left if turn_ok
  4874.     @x = $game_map.round_x(@x-0.5)
  4875.     @real_x = ((@x+0.5)*256)
  4876.     @move_failed = false
  4877.   end
  4878.  
  4879.   #--------------------------------------------------------------------------#
  4880.   # * new-method :half_right
  4881.   #--------------------------------------------------------------------------#
  4882.   def half_right( turn_ok=true )
  4883.     turn_right if turn_ok
  4884.     @x = $game_map.round_x(@x+0.5)
  4885.     @real_x = ((@x-0.5)*256)
  4886.     @move_failed = false
  4887.   end
  4888.  
  4889.   #--------------------------------------------------------------------------#
  4890.   # * new-method :half_up
  4891.   #--------------------------------------------------------------------------#
  4892.   def half_up( turn_ok=true )
  4893.     turn_up if turn_ok
  4894.     @y = $game_map.round_y(@y-0.5)
  4895.     @real_y = ((@y+0.5)*256)
  4896.     @move_failed = false
  4897.   end
  4898.  
  4899.   #--------------------------------------------------------------------------#
  4900.   # * new-method :half_forward
  4901.   #--------------------------------------------------------------------------#
  4902.   def half_forward()
  4903.     case @direction
  4904.     when 2 ; half_down
  4905.     when 4 ; half_left
  4906.     when 6 ; half_right
  4907.     when 8 ; half_up
  4908.     end
  4909.   end
  4910.  
  4911.   #--------------------------------------------------------------------------#
  4912.   # * new-method :half_backward
  4913.   #--------------------------------------------------------------------------#
  4914.   def half_backward()
  4915.     last_direction_fix = @direction_fix
  4916.     @direction_fix = true
  4917.     case @direction
  4918.     when 2;  half_up
  4919.     when 4;  half_right
  4920.     when 6;  half_left
  4921.     when 8;  half_down
  4922.     end
  4923.     @direction_fix = last_direction_fix
  4924.   end
  4925.  
  4926.   #--------------------------------------------------------------------------#
  4927.   # * new-method :free_move_toward_target
  4928.   #--------------------------------------------------------------------------#
  4929.   def free_move_toward_target( t_x, t_y )
  4930.     sx = fr_distance_x_from(t_x)
  4931.     sy = fr_distance_y_from(t_y)
  4932.     if sx != 0 or sy != 0
  4933.       if sx.abs > sy.abs                  # Horizontal distance is longer
  4934.         sx > 0 ? free_left : free_right   # Prioritize left-right
  4935.         if @move_failed and sy != 0
  4936.           sy > 0 ? free_up : free_down
  4937.         end
  4938.       else                                # Vertical distance is longer
  4939.         sy > 0 ? free_up : free_down      # Prioritize up-down
  4940.         if @move_failed and sx != 0
  4941.           sx > 0 ? free_left : free_right
  4942.         end
  4943.       end
  4944.     end
  4945.   end
  4946.  
  4947.   #--------------------------------------------------------------------------#
  4948.   # * new-method :fr_distance_x_from
  4949.   #--------------------------------------------------------------------------#
  4950.   def fr_distance_x_from( targ_x )
  4951.     sx = self.x - targ_x
  4952.     if $game_map.loop_horizontal?         # When looping horizontally
  4953.       if sx.abs > $game_map.width / 2     # Larger than half the map width?
  4954.         sx -= $game_map.width             # Subtract map width
  4955.       end
  4956.     end
  4957.     return sx
  4958.   end
  4959.  
  4960.   #--------------------------------------------------------------------------#
  4961.   # * new-method :fr_distance_y_from
  4962.   #--------------------------------------------------------------------------#
  4963.   def fr_distance_y_from( targ_y )
  4964.     sy = self.y - targ_y
  4965.     if $game_map.loop_vertical?           # When looping vertically
  4966.       if sy.abs > $game_map.height / 2    # Larger than half the map height?
  4967.         sy -= $game_map.height            # Subtract map height
  4968.       end
  4969.     end
  4970.     return sy
  4971.   end
  4972.  
  4973.   #--------------------------------------------------------------------------#
  4974.   # * new-method :limited_down
  4975.   #--------------------------------------------------------------------------#
  4976.   def limited_down( orx, ory, limit, dist=1 )
  4977.     dist_x = fr_distance_x_from(orx)
  4978.     dist_y = fr_distance_y_from(ory) + dist
  4979.     move_down() if (dist_x.abs + dist_y.abs) < limit  
  4980.     return (dist_x.abs + dist_y.abs)
  4981.   end  
  4982.  
  4983.   #--------------------------------------------------------------------------#
  4984.   # * new-method :limited_up
  4985.   #--------------------------------------------------------------------------#  
  4986.   def limited_up( orx, ory, limit, dist=1 )
  4987.     dist_x = fr_distance_x_from(orx)
  4988.     dist_y = fr_distance_y_from(ory) - dist
  4989.     move_up() if (dist_x.abs + dist_y.abs) < limit
  4990.     return (dist_x.abs + dist_y.abs)
  4991.   end
  4992.  
  4993.   #--------------------------------------------------------------------------#
  4994.   # * new-method :limited_left
  4995.   #--------------------------------------------------------------------------#  
  4996.   def limited_left( orx, ory, limit, dist=1 )
  4997.     dist_x = fr_distance_x_from(orx) - dist
  4998.     dist_y = fr_distance_y_from(ory)
  4999.     move_left() if (dist_x.abs + dist_y.abs) < limit
  5000.     return (dist_x.abs + dist_y.abs)
  5001.   end
  5002.  
  5003.   #--------------------------------------------------------------------------#
  5004.   # * new-method :limited_right
  5005.   #--------------------------------------------------------------------------#  
  5006.   def limited_right( orx, ory, limit, dist=1 )
  5007.     dist_x = fr_distance_x_from(orx) + dist
  5008.     dist_y = fr_distance_y_from(ory)
  5009.     move_right() if (dist_x.abs + dist_y.abs) < limit
  5010.     return (dist_x.abs + dist_y.abs)
  5011.   end  
  5012.  
  5013.   #--------------------------------------------------------------------------#
  5014.   # * new-method :thrust_down
  5015.   #--------------------------------------------------------------------------#
  5016.   def thrust_down()
  5017.     dudspeed = @move_speed
  5018.     @move_speed = 6
  5019.     half_down()
  5020.     thrust_wait()
  5021.     half_up( false )
  5022.     @move_speed = dudspeed
  5023.   end
  5024.  
  5025.   #--------------------------------------------------------------------------#
  5026.   # * new-method :thrust_up
  5027.   #--------------------------------------------------------------------------#
  5028.   def thrust_up()
  5029.     dudspeed = @move_speed
  5030.     @move_speed = 6
  5031.     half_up()
  5032.     thrust_wait()
  5033.     half_down( false )
  5034.     @move_speed = dudspeed
  5035.   end
  5036.  
  5037.   #--------------------------------------------------------------------------#
  5038.   # * new-method :thrust_left
  5039.   #--------------------------------------------------------------------------#  
  5040.   def thrust_left()
  5041.     dudspeed = @move_speed
  5042.     @move_speed = 6
  5043.     half_left()
  5044.     thrust_wait()
  5045.     half_right( false )
  5046.     @move_speed = dudspeed
  5047.   end
  5048.  
  5049.   #--------------------------------------------------------------------------#
  5050.   # * new-method :thrust_right
  5051.   #--------------------------------------------------------------------------#
  5052.   def thrust_right()
  5053.     dudspeed = @move_speed
  5054.     @move_speed = 6
  5055.     half_right()
  5056.     thrust_wait()
  5057.     half_left( false )
  5058.     @move_speed = dudspeed
  5059.   end
  5060.  
  5061.   #--------------------------------------------------------------------------#
  5062.   # * new-method :thrust_forward
  5063.   #--------------------------------------------------------------------------#
  5064.   def thrust_forward()
  5065.     case @direction
  5066.     when 2 ; thrust_down()
  5067.     when 4 ; thrust_left()
  5068.     when 6 ; thrust_right()
  5069.     when 8 ; thrust_up()
  5070.     end
  5071.   end
  5072.  
  5073.   #--------------------------------------------------------------------------#
  5074.   # * new-method :thrust_backward
  5075.   #--------------------------------------------------------------------------#
  5076.   def thrust_backward()
  5077.     last_direction_fix = @direction_fix
  5078.     @direction_fix = true
  5079.     case @direction
  5080.     when 2 ; thrust_up
  5081.     when 4 ; thrust_right
  5082.     when 6 ; thrust_left
  5083.     when 8 ; thrust_down
  5084.     end
  5085.     @direction_fix = last_direction_fix
  5086.   end
  5087.  
  5088.   #--------------------------------------------------------------------------#
  5089.   # * new-method :ygg_dodge
  5090.   #--------------------------------------------------------------------------#
  5091.   def ygg_dodge()
  5092.     last_direction_fix = @direction_fix
  5093.     @direction_fix = true
  5094.     dodge_val = rand(2)
  5095.     case @direction
  5096.     when 2, 8; dodge_val == 0 ? thrust_left() : thrust_right()
  5097.     when 4, 6; dodge_val == 0 ? thrust_up() : thrust_down()
  5098.     end
  5099.     @direction_fix = last_direction_fix
  5100.   end
  5101.  
  5102.   #--------------------------------------------------------------------------#
  5103.   # * new-method :free_down
  5104.   #--------------------------------------------------------------------------#
  5105.   def free_down( turn_ok=true )
  5106.     if passable?(@x, @y.round.to_i+0.1)                  # Passable
  5107.       turn_down
  5108.       @y = $game_map.round_y(@y+0.1)
  5109.       @real_y = (@y-0.1)*256
  5110.       increase_steps
  5111.       @move_failed = false
  5112.     else                                    # Impassable
  5113.       turn_down if turn_ok
  5114.       check_event_trigger_touch(@x, @y.round+1)   # Touch event is triggered?
  5115.       @move_failed = true
  5116.     end
  5117.   end
  5118.  
  5119.   #--------------------------------------------------------------------------#
  5120.   # * new-method :free_left
  5121.   #--------------------------------------------------------------------------#
  5122.   def free_left( turn_ok=true )
  5123.     if passable?(@x.round.to_i-1, @y)                  # Passable
  5124.       turn_left
  5125.       @x = $game_map.round_x(@x-0.1)
  5126.       @real_x = (@x+0.1)*256
  5127.       increase_steps
  5128.       @move_failed = false
  5129.     else                                    # Impassable
  5130.       turn_left if turn_ok
  5131.       check_event_trigger_touch(@x.round-1, @y)   # Touch event is triggered?
  5132.       @move_failed = true
  5133.     end
  5134.   end
  5135.  
  5136.   #--------------------------------------------------------------------------#
  5137.   # * new-method :free_right
  5138.   #--------------------------------------------------------------------------#
  5139.   def free_right( turn_ok=true )
  5140.     if passable?(@x.round.to_i+1, @y)                  # Passable
  5141.       turn_right
  5142.       @x = $game_map.round_x(@x+0.1)
  5143.       @real_x = (@x-0.1)*256
  5144.       increase_steps
  5145.       @move_failed = false
  5146.     else                                    # Impassable
  5147.       turn_right if turn_ok
  5148.       check_event_trigger_touch(@x.round+1, @y)   # Touch event is triggered?
  5149.       @move_failed = true
  5150.     end
  5151.   end
  5152.  
  5153.   #--------------------------------------------------------------------------#
  5154.   # * new-method :free_up
  5155.   #--------------------------------------------------------------------------#
  5156.   def free_up( turn_ok=true )
  5157.     if passable?(@x, @y.truncate-1)                  # Passable
  5158.       turn_up
  5159.       @y = $game_map.round_y(@y-0.1)
  5160.       @real_y = (@y+0.1)*256
  5161.       increase_steps
  5162.       @move_failed = false
  5163.     else                                    # Impassable
  5164.       turn_up if turn_ok
  5165.       check_event_trigger_touch(@x, @y.truncate-1)   # Touch event is triggered?
  5166.       @move_failed = true
  5167.     end
  5168.   end
  5169.  
  5170.   #--------------------------------------------------------------------------#
  5171.   # * new-method :hit_away
  5172.   #--------------------------------------------------------------------------#
  5173.   def hit_away( atk_direction )
  5174.     def_speed = @move_speed
  5175.     @move_speed = 6
  5176.     case atk_direction
  5177.     when 2
  5178.       turn_up
  5179.       move_backward
  5180.     when 4
  5181.       turn_right
  5182.       move_backward
  5183.     when 6
  5184.       turn_left
  5185.       move_backward
  5186.     when 8
  5187.       turn_down
  5188.       move_backward
  5189.     end
  5190.     @move_speed = def_speed
  5191.   end
  5192.  
  5193.   #--------------------------------------------------------------------------#
  5194.   # * new-method :turn_to_coord
  5195.   #--------------------------------------------------------------------------#
  5196.   def turn_to_coord( sx, sy )
  5197.     if sx > self.x and sy == self.y    ; turn_right()
  5198.     elsif sx < self.x and sy == self.y ; turn_left()
  5199.     elsif sx == self.x and sy > self.y ; turn_down()
  5200.     elsif sx == self.x and sy < self.y ; turn_up()
  5201.     end  
  5202.   end
  5203.  
  5204.   #--------------------------------------------------------------------------#
  5205.   # * new-method :set_origin
  5206.   #--------------------------------------------------------------------------#
  5207.   def set_origin()
  5208.     @origin ||= ::YGG::Pos.new( self.x, self.y ) ; @origin.set( self.x, self.y )
  5209.   end
  5210.    
  5211.   #--------------------------------------------------------------------------#
  5212.   # * new-method :get_xy_infront
  5213.   #--------------------------------------------------------------------------#  
  5214.   def get_xy_infront( dist, sway )
  5215.     case direction
  5216.     when 2 # // Down
  5217.       return [x+sway, y+dist]
  5218.     when 4 # // Left
  5219.       return [x-dist, y+sway]
  5220.     when 6 # // Right
  5221.       return [x+dist, y-sway]
  5222.     when 8 # // Up
  5223.       return [x-sway, y-dist]
  5224.     end
  5225.   end
  5226.  
  5227. end
  5228.  
  5229. #==============================================================================#
  5230. # ** YGG::MixIns::Battle
  5231. #==============================================================================#
  5232. module YGG::MixIns::Battle
  5233.  
  5234.   #--------------------------------------------------------------------------#
  5235.   # * Public Instance Variable(s)
  5236.   #--------------------------------------------------------------------------#
  5237.   attr_accessor :ygg_delay_max
  5238.  
  5239.   #--------------------------------------------------------------------------#
  5240.   # * new-method :ai_operated?
  5241.   #--------------------------------------------------------------------------#
  5242.   def ai_operated?()
  5243.     return @ai_operated
  5244.   end
  5245.  
  5246.   #--------------------------------------------------------------------------#
  5247.   # * new-method :hp_visible?
  5248.   #--------------------------------------------------------------------------#
  5249.   def hp_visible?()
  5250.     return $game_yggdrasil.on?() && @hp_visible
  5251.   end
  5252.    
  5253.   #--------------------------------------------------------------------------#
  5254.   # * new-method :mp_visible?
  5255.   #--------------------------------------------------------------------------#
  5256.   def mp_visible?()
  5257.     return $game_yggdrasil.on?() && @mp_visible
  5258.   end
  5259.    
  5260.   #--------------------------------------------------------------------------#
  5261.   # * new-method :ygg_can_move?
  5262.   #--------------------------------------------------------------------------#
  5263.   def ygg_can_move?() ; return true ; end
  5264.    
  5265.   #--------------------------------------------------------------------------#
  5266.   # * new-method :ygg_attacker | ygg_battler
  5267.   #--------------------------------------------------------------------------#
  5268.   def ygg_attacker() ; return nil ; end  
  5269.   def ygg_battler()  ; return ygg_attacker() ; end
  5270.    
  5271.   #--------------------------------------------------------------------------#
  5272.   # * new-method :wild_type?
  5273.   #--------------------------------------------------------------------------#
  5274.   def wild_type?() ; return false ; end  
  5275.    
  5276.   #--------------------------------------------------------------------------#
  5277.   # * new-method :ygg_enemy?
  5278.   #--------------------------------------------------------------------------#
  5279.   def ygg_enemy?() ; return false ; end  
  5280.    
  5281.   #--------------------------------------------------------------------------#
  5282.   # * new-method :ygg_ally?
  5283.   #--------------------------------------------------------------------------#
  5284.   def ygg_ally?() ; return false ; end  
  5285.    
  5286.   #--------------------------------------------------------------------------#
  5287.   # * new-method :ygg_death
  5288.   #--------------------------------------------------------------------------#
  5289.   def ygg_death() ; end  
  5290.    
  5291.   #--------------------------------------------------------------------------#
  5292.   # * new-method :ygg_boss?
  5293.   #--------------------------------------------------------------------------#
  5294.   def ygg_boss?() ; return false end  
  5295.    
  5296.   #--------------------------------------------------------------------------#
  5297.   # * new-method :process_extension_actions
  5298.   #--------------------------------------------------------------------------#
  5299.   def process_extension_actions() ; end
  5300.    
  5301.   #--------------------------------------------------------------------------#
  5302.   # * new-method :ygg_can_attack?
  5303.   #--------------------------------------------------------------------------#
  5304.   def ygg_can_attack?() ; return true ; end
  5305.  
  5306.   #--------------------------------------------------------------------------#
  5307.   # * new-method :targetable?
  5308.   #--------------------------------------------------------------------------#
  5309.   def targetable?( target )
  5310.     return false if self.ygg_battler.nil?()
  5311.     return true if target.upcase == "ALL"
  5312.     return true if self.ygg_ally?() && target == "ALLY"
  5313.     return true if self.ygg_enemy?() && target == "ENEMY"
  5314.     return false
  5315.   end  
  5316.  
  5317.   #--------------------------------------------------------------------------#
  5318.   # * new-method :ally_character?
  5319.   #--------------------------------------------------------------------------#  
  5320.   def ally_character?( char )
  5321.     return true if self.ygg_ally?() && char.ygg_ally?()
  5322.     return true if self.ygg_enemy?() && char.ygg_enemy?()
  5323.     return false
  5324.   end
  5325.  
  5326.   #--------------------------------------------------------------------------#
  5327.   # * new-method :enemy_character?
  5328.   #--------------------------------------------------------------------------#  
  5329.   def enemy_character?( char )
  5330.     return !ally_character?( char )
  5331.   end
  5332.  
  5333.   #--------------------------------------------------------------------------#
  5334.   # * new-method :ygg_correct_target
  5335.   #--------------------------------------------------------------------------#  
  5336.   def ygg_correct_target( target )
  5337.     return "ALLY" if self.ygg_enemy?() && target =~ /ENEMY/i
  5338.     return "ENEMY" if self.ygg_enemy?() && target =~ /ALLY/i
  5339.     return target
  5340.   end
  5341.  
  5342.   #--------------------------------------------------------------------------#
  5343.   # * new-method :ygg_abs_update
  5344.   #--------------------------------------------------------------------------#  
  5345.   def ygg_abs_update()
  5346.     @guard_time = [@guard_time - 1, 0].max
  5347.   end  
  5348. # ---------------------------------------------------------------------------- #    
  5349. # Calculations
  5350.  
  5351.   #--------------------------------------------------------------------------#
  5352.   # * new-method :Get Targets
  5353.   #--------------------------------------------------------------------------#
  5354.   # This is used to get all targets at a given location
  5355.   # l_x - x coordiante
  5356.   # l_y - y coordiante
  5357.   # target - "A", "E", "N", "W"
  5358.   # exclude_self - If the target that is encountered, happens to be the
  5359.   #                user, should they be ignored?
  5360.   #--------------------------------------------------------------------------#
  5361.   def ygg_get_targets( l_x=0, l_y=0, target="ALL", exclude_self = false )
  5362.     objects = $game_yggdrasil.battlers_xy( l_x, l_y ).inject([]) { |result, event|
  5363.       if event.targetable?( target )
  5364.         result.push( event )  
  5365.       end unless (exclude_self && event == self)
  5366.       result
  5367.     }
  5368.     if $game_player.pos?( l_x, l_y ) and $game_player.targetable?( target )
  5369.       objects.push( $game_player )  
  5370.     end unless (exclude_self && $game_player == self)
  5371.     return objects
  5372.   end
  5373.  
  5374. # ---------------------------------------------------------------------------- #    
  5375. # Processes
  5376.   #--------------------------------------------------------------------------#
  5377.   # * new-method :update_battler
  5378.   #--------------------------------------------------------------------------#
  5379.   def update_battler()
  5380.     update_states()
  5381.     self.ygg_battler.update_obj_handles()
  5382.     self.ygg_battler.update_cooldown()
  5383.   end
  5384.  
  5385.   #--------------------------------------------------------------------------#
  5386.   # * new-method :update_states
  5387.   #--------------------------------------------------------------------------#
  5388.   def update_states()
  5389.     self.ygg_battler.update_states
  5390.   end
  5391.    
  5392. # ---------------------------------------------------------------------------- #    
  5393. # Yggdrasil Battle Actions
  5394.  
  5395.   #--------------------------------------------------------------------------#
  5396.   # * new-method :get_targets_nearby
  5397.   #--------------------------------------------------------------------------#
  5398.   def get_targets_nearby( range=1, type ="ALL" )
  5399.     coords = []
  5400.     if YGG::FULL_FIELD_SCAN
  5401.       coords.concat( YGG.create_range_data( range ) )  
  5402.     else  
  5403.       case direction
  5404.       when 2
  5405.         for i in 0..range
  5406.           coords.push( [0, i] )
  5407.         end  
  5408.       when 4
  5409.         for i in 0..range
  5410.           coords.push( [-i, 0] )
  5411.         end  
  5412.       when 6
  5413.         for i in 0..range
  5414.           coords.push( [i, 0] )
  5415.         end  
  5416.       when 8
  5417.         for i in 0..range
  5418.           coords.push( [0, -i] )
  5419.         end  
  5420.       end  
  5421.     end  
  5422.     for coo in coords
  5423.       o = ygg_get_targets( coo[0]+self.x, coo[1]+self.y, type, true )
  5424.       return o unless o.empty?()
  5425.     end
  5426.     return []
  5427.   end
  5428.  
  5429. end
  5430.  
  5431. #==============================================================================#
  5432. # ** YGG::MixIns::AI
  5433. #==============================================================================#
  5434. module YGG::MixIns::AI
  5435.  
  5436.   #--------------------------------------------------------------------------#
  5437.   # * Public Instance Variables
  5438.   #--------------------------------------------------------------------------#  
  5439.   attr_accessor :ai_engine
  5440.  
  5441.   #--------------------------------------------------------------------------#
  5442.   # * new-method :setup_ai_engine
  5443.   #--------------------------------------------------------------------------#  
  5444.   def setup_ai_engine( engine, setup_data={} )
  5445.     @ai_engine = engine.new( self, setup_data )
  5446.   end
  5447.  
  5448.   #--------------------------------------------------------------------------#
  5449.   # * new-method :terminate_ai_engine
  5450.   #--------------------------------------------------------------------------#  
  5451.   def terminate_ai_engine()
  5452.     @ai_engine = nil
  5453.   end
  5454.  
  5455.   #--------------------------------------------------------------------------#
  5456.   # * new-method :ygg_update_ai
  5457.   #--------------------------------------------------------------------------#
  5458.   def ygg_update_ai()
  5459.     @ai_engine.update() unless @ai_engine.nil?()
  5460.   end
  5461.  
  5462. end
  5463.  
  5464. #==============================================================================#
  5465. # ** YGG::MixIns::Player
  5466. #==============================================================================#
  5467. module YGG::MixIns::Player
  5468.  
  5469.   #--------------------------------------------------------------------------#
  5470.   # * new-method :drop_attraction?
  5471.   #--------------------------------------------------------------------------#
  5472.   def drop_attraction?()
  5473.     return self.ygg_battler.drops_attraction? unless self.ygg_battler.nil?()
  5474.     return false
  5475.   end
  5476.  
  5477. end  
  5478. #==============================================================================#
  5479. # // Mix In
  5480. class Game_Actor     ; include YGG::MixIns::Actor    ; end
  5481. class Game_Enemy     ; include YGG::MixIns::Enemy    ; end
  5482. class Game_Character ; include YGG::MixIns::Movement ; end
  5483. class Game_Character ; include YGG::MixIns::Battle   ; end
  5484. class Game_Event     ; include YGG::MixIns::AI       ; end
  5485. class Game_Player    ; include YGG::MixIns::Player   ; end
  5486. #==============================================================================#  
  5487. #==============================================================================#
  5488. # ** Game_Character
  5489. #==============================================================================#
  5490. class Game_Character
  5491.  
  5492.   #--------------------------------------------------------------------------#
  5493.   # * Public Instance Variable(s)
  5494.   #--------------------------------------------------------------------------#
  5495.   attr_accessor :use_equipment
  5496.  
  5497.   attr_accessor :ygg_atk_delay
  5498.   attr_accessor :ygg_atk_delay_max
  5499.   attr_accessor :ygg_anims
  5500.  
  5501.   attr_accessor :move_speed_mod
  5502.   attr_accessor :tone
  5503.   attr_accessor :zoom_x, :zoom_y
  5504.   attr_accessor :wait_count
  5505.  
  5506.   attr_accessor :ygg_invincible
  5507.   attr_accessor :guard_time
  5508.  
  5509.   attr_reader :action_handle
  5510.  
  5511.   #--------------------------------------------------------------------------#
  5512.   # * alias-method :initialize
  5513.   #--------------------------------------------------------------------------#
  5514.   alias :ygg_gmc_mixin_initialize :initialize unless $@
  5515.   def initialize( *args, &block )
  5516.     ygg_gmc_mixin_initialize( *args, &block )
  5517.     ygg_initialize()
  5518.   end
  5519.  
  5520.   #--------------------------------------------------------------------------#
  5521.   # * new-method :ygg_initialize
  5522.   #--------------------------------------------------------------------------#
  5523.   def ygg_initialize()
  5524.     @use_equipment     = false
  5525.     @equipment_handles = [::YGG::Handlers::Equip.new( 0 ),
  5526.                           ::YGG::Handlers::Equip.new( 1 )]
  5527.     @action_handle     = ::YGG::Handlers::Action.new( self, [] )
  5528.     @free_act_handles  = []
  5529.     @ygg_registered    = false
  5530.    
  5531.     @ygg_boss          = false
  5532.     @ygg_anims         = []
  5533.     @ygg_slip_counter  = 0
  5534.     @ygg_invincible    = false
  5535.    
  5536.     @move_speed_mod    = 0
  5537.    
  5538.     reset_tone()
  5539.    
  5540.     @zoom_x, @zoom_y   = 1.0, 1.0
  5541.    
  5542.     @ai_operated       = false
  5543.     @hp_visible        = true
  5544.     @mp_visible        = true
  5545.    
  5546.     @guard_time        = 0
  5547.    
  5548.     ygg_register() if $game_yggdrasil.on?()  
  5549.   end
  5550.  
  5551.   #--------------------------------------------------------------------------#
  5552.   # * new-method :refresh_handles
  5553.   #--------------------------------------------------------------------------#
  5554.   def refresh_handles()
  5555.     @equipment_handles.each { |hnd|
  5556.       hnd.parent = self
  5557.       hnd.refresh()
  5558.     }
  5559.     @action_handle.parent_event = self
  5560.   end
  5561.  
  5562.   #--------------------------------------------------------------------------#
  5563.   # * new-method :pop_enabled?
  5564.   #--------------------------------------------------------------------------#  
  5565.   def pop_enabled?() ; return true ; end
  5566.  
  5567.   #--------------------------------------------------------------------------#
  5568.   # * new-method :reset_tone
  5569.   #--------------------------------------------------------------------------#  
  5570.   def reset_tone()
  5571.     @tone              = Tone.new( 0, 0, 0, 0 )
  5572.     @target_tone       = Tone.new( 0, 0, 0, 0 )
  5573.     @tone_time         = 60.0
  5574.   end
  5575.  
  5576.   #--------------------------------------------------------------------------#
  5577.   # * new-method :screen_rect
  5578.   #--------------------------------------------------------------------------#  
  5579.   def screen_rect()
  5580.     @screen_rect ||= Rect.new( -32, -32, Graphics.width, Graphics.height )
  5581.     return @screen_rect
  5582.   end unless method_defined? :screen_rect
  5583.  
  5584.   #--------------------------------------------------------------------------#
  5585.   # * new-method :onScreen?
  5586.   #--------------------------------------------------------------------------#  
  5587.   def onScreen?()
  5588.     r = self.screen_rect
  5589.     return self.screen_x.between?( r.x, r.width ) && self.screen_y.between?( r.y, r.height )
  5590.   end
  5591.  
  5592.   #--------------------------------------------------------------------------#
  5593.   # * new-method :limitedOnScreen?
  5594.   #--------------------------------------------------------------------------#  
  5595.   def limitedOnScreen?()
  5596.     return false unless screen_x.between?( 0, Graphics.width ) && screen_y.between?( 0, Graphics.height )
  5597.     return true
  5598.   end
  5599.  
  5600.   #--------------------------------------------------------------------------#
  5601.   # * overwrite-method :collide_with_characters?
  5602.   #--------------------------------------------------------------------------#
  5603.   def collide_with_characters?( x, y )
  5604.     for event in $game_map.events_xy( x, y )          # Matches event position
  5605.       unless event.through                          # Passage OFF?
  5606.         return true if event.priority_type == 1     # Target is normal char
  5607.       end
  5608.     end
  5609.     if @priority_type == 1                          # Self is normal char
  5610.       return true if $game_player.pos_nt?(x, y)     # Matches player position
  5611.       return true if $game_map.boat.pos_nt?(x, y)   # Matches boat position
  5612.       return true if $game_map.ship.pos_nt?(x, y)   # Matches ship position
  5613.     end
  5614.     return false
  5615.   end
  5616.  
  5617.   #--------------------------------------------------------------------------#
  5618.   # * overwrite-method :update_move
  5619.   #--------------------------------------------------------------------------#  
  5620.   def update_move()
  5621.     distance = 2 ** self.move_speed   # Convert to movement distance
  5622.     distance *= 2 if dash?        # If dashing, double it
  5623.     @real_x = [@real_x - distance, @x * 256].max if @x * 256 < @real_x
  5624.     @real_x = [@real_x + distance, @x * 256].min if @x * 256 > @real_x
  5625.     @real_y = [@real_y - distance, @y * 256].max if @y * 256 < @real_y
  5626.     @real_y = [@real_y + distance, @y * 256].min if @y * 256 > @real_y
  5627.     update_bush_depth unless moving?
  5628.     if @walk_anime
  5629.       @anime_count += 1.5
  5630.     elsif @step_anime
  5631.       @anime_count += 1
  5632.     end
  5633.   end
  5634.  
  5635.   #--------------------------------------------------------------------------#
  5636.   # * overwrite-method :update_animation
  5637.   #--------------------------------------------------------------------------#  
  5638.   def update_animation()
  5639.     speed = self.move_speed + (dash? ? 1 : 0)
  5640.     if @anime_count > 18 - speed * 2
  5641.       if not @step_anime and @stop_count > 0
  5642.         @pattern = @original_pattern
  5643.       else
  5644.         @pattern = (@pattern + 1) % 4
  5645.       end
  5646.       @anime_count = 0
  5647.     end
  5648.   end
  5649.  
  5650.   #--------------------------------------------------------------------------#
  5651.   # * new-method :extra_speed_mod
  5652.   #--------------------------------------------------------------------------#  
  5653.   def extra_speed_mod()
  5654.     return self.ygg_battler.nil?() ? 0 : ygg_battler.move_mod  
  5655.   end
  5656.  
  5657.   #--------------------------------------------------------------------------#
  5658.   # * new-method :move_speed
  5659.   #--------------------------------------------------------------------------#  
  5660.   def move_speed()
  5661.     return @move_speed + @move_speed_mod + extra_speed_mod
  5662.   end
  5663.  
  5664.   #--------------------------------------------------------------------------#
  5665.   # * new-method :equip_handle
  5666.   #--------------------------------------------------------------------------#
  5667.   def equip_handle( eq_id ) ; @equipment_handles[eq_id] ; end
  5668.    
  5669.   #--------------------------------------------------------------------------#
  5670.   # * new-method :equip_icon
  5671.   #--------------------------------------------------------------------------#  
  5672.   def equip_icon( eq_id )
  5673.     return 0 if self.ygg_battler.nil?()
  5674.     return self.ygg_battler.equip_icon( eq_id )
  5675.   end
  5676.  
  5677.   #--------------------------------------------------------------------------#
  5678.   # * new-method :equip_atk_act_name
  5679.   #--------------------------------------------------------------------------#    
  5680.   def equip_atk_act_name( eq_id )
  5681.     return "" if self.ygg_battler.nil?()
  5682.     return self.ygg_battler.equip_atk_act_name( eq_id )
  5683.   end
  5684.  
  5685.   #--------------------------------------------------------------------------#
  5686.   # * new-method :equip_grd_act_name
  5687.   #--------------------------------------------------------------------------#    
  5688.   def equip_grd_act_name( eq_id )
  5689.     return "" if self.ygg_battler.nil?()
  5690.     return self.ygg_battler.equip_grd_act_name( eq_id )
  5691.   end
  5692.    
  5693.   #--------------------------------------------------------------------------#
  5694.   # * alias-method :update
  5695.   #--------------------------------------------------------------------------#
  5696.   alias :ygg_gmc_mixin_update :update unless $@
  5697.   def update( *args, &block )
  5698.     ygg_gmc_mixin_update( *args, &block )
  5699.     if self.ygg_battler.nil?()
  5700.       ygg_unregister() if @ygg_registered
  5701.     else
  5702.       abs_on = $game_system.yggdrasil_on?()  
  5703.       if abs_on
  5704.         @target_tone = self.ygg_battler.effect_tone
  5705.         if self.ygg_battler.character_need_refresh
  5706.           self.ygg_battler.character_need_refresh = false
  5707.         end  
  5708.         ygg_register() unless @ygg_registered
  5709.         @equipment_handles.each { |eq|
  5710.           eq.icon_index    = self.equip_icon( eq.eq_id )
  5711.           eq.attack_action = self.equip_atk_act_name( eq.eq_id )
  5712.           eq.guard_action  = self.equip_grd_act_name( eq.eq_id )
  5713.           eq.direction     = self.direction  
  5714.           eq.guard_time    = self.guard_time
  5715.           eq.update() }
  5716.         self.ygg_engage.update() unless self.ygg_engage.nil?()
  5717.         @action_handle.update()
  5718.         @free_act_handles = @free_act_handles.inject([]) { |r, h|
  5719.           h.update() ; r << h if h.busy?() ; r
  5720.         } unless @free_act_handles.empty?()
  5721.       end  
  5722.     end  
  5723.     [:red, :green, :blue, :gray].each { |s|
  5724.       v1, v2 = @tone.send(s), @target_tone.send(s)
  5725.       if v1 > v2
  5726.         @tone.send( s.to_s+"=", [v1-(255.0/@tone_time), v2].max )
  5727.       elsif v1 < v2
  5728.         @tone.send( s.to_s+"=", [v1+(255.0/@tone_time), v2].min )
  5729.       end  
  5730.     }
  5731.   end
  5732.  
  5733.   #--------------------------------------------------------------------------#
  5734.   # * new-method :ygg_engage
  5735.   #--------------------------------------------------------------------------#
  5736.   def ygg_engage()
  5737.     return ygg_battler.ygg_engage
  5738.   end
  5739.  
  5740.   #--------------------------------------------------------------------------#
  5741.   # * new-method :ygg_register
  5742.   #--------------------------------------------------------------------------#
  5743.   def ygg_register()
  5744.     $game_yggdrasil.add_battler( self )
  5745.     @ygg_registered = true
  5746.   end  
  5747.  
  5748.   #--------------------------------------------------------------------------#
  5749.   # * new-method :ygg_unregister
  5750.   #--------------------------------------------------------------------------#
  5751.   def ygg_unregister()
  5752.     $game_yggdrasil.remove_battler( self )
  5753.     @ygg_registered = false
  5754.   end
  5755.  
  5756.   #--------------------------------------------------------------------------#
  5757.   # * new-method :get_target_events
  5758.   #--------------------------------------------------------------------------#
  5759.   def get_target_events( xy_list )
  5760.     return xy_list.inject([]) { |result, point|
  5761.       result + $game_yggdrasil.battlers_xy( *point )
  5762.     }
  5763.   end
  5764.    
  5765.   #--------------------------------------------------------------------------#
  5766.   # * new-method :set_through
  5767.   #--------------------------------------------------------------------------#  
  5768.   def set_through( bool ) ; @through = bool ; end
  5769.    
  5770. end
  5771.  
  5772. # // (YGG_VG)
  5773. #==============================================================================#
  5774. # // Start Yggdrasil Visual Code
  5775. #==============================================================================#
  5776. # ** YGG
  5777. #==============================================================================#
  5778. module YGG
  5779. #==============================================================================#
  5780. # ** YGG::Sprites::ValueBar_Base
  5781. #==============================================================================#  
  5782.   class Sprites::ValueBar_Base < ::Sprite
  5783.    
  5784.     BAR_DRAW_MODE = 0 # // 0 Use 2 sprites, 1 Draw onto base
  5785.    
  5786.     #--------------------------------------------------------------------------#
  5787.     # * super-method :initialize
  5788.     #--------------------------------------------------------------------------#        
  5789.     def initialize( parent, base_name, bar_name, value_proc, max_proc )
  5790.       super( parent.viewport )
  5791.       @parent       = parent
  5792.       @base_name    = base_name
  5793.       @bar_name     = bar_name
  5794.       case BAR_DRAW_MODE
  5795.       when 0
  5796.         self.bitmap   = Cache.system( base_name )
  5797.         @bar          = ::Sprite_Base.new( self.viewport )
  5798.         @bar.bitmap   = Cache.system( bar_name )
  5799.         @bar.x        = self.x       = @parent.x
  5800.         @bar.y        = self.y       = @parent.y
  5801.         @bar.visible  = self.visible = @parent.visible
  5802.       when 1
  5803.         base_ref      = Cache.system( base_name )
  5804.         self.bitmap   = Bitmap.new( base_ref.width, base_ref.height )
  5805.       end  
  5806.       @value_proc     = value_proc
  5807.       @max_proc       = max_proc
  5808.       @last_value     = -1
  5809.       @last_max       = -1
  5810.       @offsets        = ::YGG::Pos.new( 0, 0, 0 )
  5811.       @baroffsets     = ::YGG::Pos.new( 0, 0, 1 )
  5812.     end
  5813.    
  5814.     #--------------------------------------------------------------------------#
  5815.     # * super-method :dispose
  5816.     #--------------------------------------------------------------------------#    
  5817.     def dispose()
  5818.       case BAR_DRAW_MODE
  5819.       when 0
  5820.         @bar.dispose()
  5821.       when 1
  5822.         self.bitmap.dispose()
  5823.       end  
  5824.       super()
  5825.     end
  5826.    
  5827.   case BAR_DRAW_MODE
  5828.   when 0
  5829.    
  5830.     #--------------------------------------------------------------------------#
  5831.     # * super-method :update
  5832.     #--------------------------------------------------------------------------#    
  5833.     def update()
  5834.       super()
  5835.       val = @value_proc.call() #* 100
  5836.       max = @max_proc.call() #* 100
  5837.       if (val != @last_value || max != @last_max)
  5838.         if max.eql?( 0 )
  5839.           @bar.src_rect.width = 0
  5840.         else  
  5841.           bar_width = @bar.bitmap.width * val / max
  5842.           @bar.src_rect.width = bar_width
  5843.         end  
  5844.         @last_value = val
  5845.         @last_max   = max
  5846.       end
  5847.       pox = @parent.src_rect.width / 2 - (@parent.src_rect.width +
  5848.         self.bitmap.width) / 2
  5849.       @bar.x       = @baroffsets.x + self.x       = @parent.x + pox + @offsets.x
  5850.       @bar.y       = @baroffsets.y + self.y       = @parent.y + @offsets.y
  5851.       @bar.z       = @baroffsets.z + self.z       = @parent.z + @offsets.z
  5852.       @bar.visible = self.visible# = @parent.visible
  5853.       @bar.opacity = self.opacity
  5854.     end
  5855.    
  5856.   when 1  
  5857.    
  5858.     #--------------------------------------------------------------------------#
  5859.     # * super-method :update
  5860.     #--------------------------------------------------------------------------#    
  5861.     def update()
  5862.       super()
  5863.       val = @value_proc.call() #* 100
  5864.       max = @max_proc.call() #* 100
  5865.       if (val != @last_value || max != @last_max)
  5866.         self.bitmap.clear()
  5867.         base = Cache.system( @base_name )
  5868.         bar  = Cache.system( @bar_name )
  5869.         self.bitmap.blt( 0, 0, base, base.rect )
  5870.         unless max.eql?( 0 )
  5871.           bar_width = bar.width * val / max
  5872.           rect = bar.rect.clone()
  5873.           rect.width = bar_width
  5874.           self.bitmap.blt( @baroffsets.x, @baroffsets.y, bar, rect )
  5875.         end  
  5876.         @last_value = val
  5877.         @last_max   = max
  5878.       end
  5879.       pox = @parent.src_rect.width / 2 - (@parent.src_rect.width +
  5880.       self.bitmap.width) / 2
  5881.       self.x       = @parent.x + pox + @offsets.x
  5882.       self.y       = @parent.y + @offsets.y
  5883.       self.z       = @parent.z + @offsets.z
  5884.       #self.visible = @parent.visible
  5885.     end  
  5886.    
  5887.   end
  5888.    
  5889.   end
  5890. #==============================================================================#
  5891. # ** YGG::Sprites::HpBar
  5892. #==============================================================================#    
  5893.   class Sprites::HpBar < Sprites::ValueBar_Base
  5894.    
  5895.     #--------------------------------------------------------------------------#
  5896.     # * super-method :initialize
  5897.     #--------------------------------------------------------------------------#    
  5898.     def initialize( parent )
  5899.       val_proc = Proc.new { @parent.character.ygg_attacker.hp }
  5900.       max_proc = Proc.new { @parent.character.ygg_attacker.maxhp }
  5901.       base_name= "1x6Graphics/EventBarBase"
  5902.       if parent.character.ygg_attacker.actor?()
  5903.         bar_name = "1x6Graphics/EventBar2"
  5904.       else
  5905.         bar_name = "1x6Graphics/EventBar3"
  5906.       end  
  5907.       super( parent, base_name, bar_name, val_proc, max_proc )
  5908.       @offsets.set( 0, 0, 0 )
  5909.       @baroffsets.set( 1, 1, 0 )
  5910.     end
  5911.  
  5912.     #--------------------------------------------------------------------------#
  5913.     # * super-method :update
  5914.     #--------------------------------------------------------------------------#
  5915.     def update()
  5916.       self.opacity = @parent.character.ygg_engage.bar_opacity
  5917.       self.visible = @parent.character.hp_visible?() && @parent.visible
  5918.       super()
  5919.     end
  5920.    
  5921.   end
  5922. #==============================================================================#
  5923. # ** YGG::Sprites::MpBar
  5924. #==============================================================================#  
  5925.   class Sprites::MpBar < Sprites::ValueBar_Base
  5926.    
  5927.     #--------------------------------------------------------------------------#
  5928.     # * super-method :initialize
  5929.     #--------------------------------------------------------------------------#    
  5930.     def initialize( parent )
  5931.       val_proc = Proc.new { @parent.character.ygg_attacker.mp }
  5932.       max_proc = Proc.new { @parent.character.ygg_attacker.maxmp }
  5933.       base_name= "1x6Graphics/EventBarBase"
  5934.       bar_name = "1x6Graphics/EventBar5"
  5935.       super( parent, base_name, bar_name, val_proc, max_proc )
  5936.       @offsets.set( 0, 6, 0 )
  5937.       @baroffsets.set( 1, 1, 1 )
  5938.     end
  5939.    
  5940.     #--------------------------------------------------------------------------#
  5941.     # * super-method :update
  5942.     #--------------------------------------------------------------------------#
  5943.     def update()
  5944.       #self.opacity = @parent.character.ygg_engage.bar_opacity
  5945.       self.visible = @parent.character.mp_visible?() && @parent.visible
  5946.       super()
  5947.     end
  5948.    
  5949.   end
  5950.    
  5951. end  
  5952.  
  5953. #==============================================================================#
  5954. # ** Sprite_Character
  5955. #==============================================================================#
  5956. class Sprite_Character < Sprite_Base
  5957.  
  5958.   #--------------------------------------------------------------------------#
  5959.   # * alias-method :initialize
  5960.   #--------------------------------------------------------------------------#
  5961.   alias :ygg1x6_hpmp_spc_initialize :initialize unless $@
  5962.   def initialize( *args )
  5963.     ygg1x6_hpmp_spc_initialize( *args )
  5964.     create_bars()
  5965.     update_bars()
  5966.   end
  5967.  
  5968.   #--------------------------------------------------------------------------#
  5969.   # * new-method :create_bars
  5970.   #--------------------------------------------------------------------------#
  5971.   def create_bars()
  5972.     unless @character.ygg_battler.nil?()
  5973.       create_hp_bar() if @hp_bar.nil?() if ::YGG::USE_HPBAR
  5974.       create_mp_bar() if @mp_bar.nil?() if ::YGG::USE_MPBAR
  5975.     end
  5976.   end
  5977.  
  5978.   #--------------------------------------------------------------------------#
  5979.   # * new-method :create_hp_bar
  5980.   #--------------------------------------------------------------------------#
  5981.   def create_hp_bar()
  5982.     return if @character.ygg_battler.nil?()
  5983.     @hp_bar = ::YGG::Sprites::HpBar.new( self )
  5984.   end
  5985.  
  5986.   #--------------------------------------------------------------------------#
  5987.   # * new-method :create_mp_bar
  5988.   #--------------------------------------------------------------------------#  
  5989.   def create_mp_bar()
  5990.     return if @character.ygg_battler.nil?()
  5991.     @mp_bar = ::YGG::Sprites::MpBar.new( self )
  5992.   end
  5993.  
  5994.   #--------------------------------------------------------------------------#
  5995.   # * alias-method :dispose
  5996.   #--------------------------------------------------------------------------#
  5997.   alias :ygg1x6_hpmp_spc_dispose :dispose unless $@
  5998.   def dispose()
  5999.     dispose_bars()
  6000.     ygg1x6_hpmp_spc_dispose()
  6001.   end
  6002.  
  6003.   #--------------------------------------------------------------------------#
  6004.   # * new-method :dispose_bars
  6005.   #--------------------------------------------------------------------------#  
  6006.   def dispose_bars()
  6007.     dispose_hp_bar() unless @hp_bar.nil?()
  6008.     dispose_mp_bar() unless @mp_bar.nil?()
  6009.   end
  6010.  
  6011.   #--------------------------------------------------------------------------#
  6012.   # * new-method :dispose_hp_bar
  6013.   #--------------------------------------------------------------------------#  
  6014.   def dispose_hp_bar() ; @hp_bar.dispose() ; @hp_bar = nil ; end
  6015.  
  6016.   #--------------------------------------------------------------------------#
  6017.   # * new-method :dispose_mp_bar
  6018.   #--------------------------------------------------------------------------#  
  6019.   def dispose_mp_bar() ; @mp_bar.dispose() ; @mp_bar = nil ; end
  6020.  
  6021.   #--------------------------------------------------------------------------#
  6022.   # * alias-method :update
  6023.   #--------------------------------------------------------------------------#  
  6024.   alias :ygg1x6_hpmp_spc_update :update unless $@
  6025.   def update()
  6026.     ygg1x6_hpmp_spc_update()
  6027.     update_bars() unless @character.nil?()
  6028.   end
  6029.  
  6030.   #--------------------------------------------------------------------------#
  6031.   # * new-method :update_bars
  6032.   #--------------------------------------------------------------------------#  
  6033.   def update_bars()
  6034.     update_hp_bar() unless @hp_bar.nil?()
  6035.     update_mp_bar() unless @mp_bar.nil?()
  6036.   end
  6037.  
  6038.   #--------------------------------------------------------------------------#
  6039.   # * new-method :update_hp_bar
  6040.   #--------------------------------------------------------------------------#  
  6041.   def update_hp_bar()
  6042.     if @hp_bar.nil?() && !@character.ygg_attacker.nil?()
  6043.       create_hp_bar()
  6044.     elsif !@hp_bar.nil?() && @character.ygg_attacker.nil?()  
  6045.       dispose_hp_bar()
  6046.     end
  6047.     @hp_bar.update() unless @hp_bar.nil?()
  6048.   end
  6049.  
  6050.   #--------------------------------------------------------------------------#
  6051.   # * new-method :update_mp_bar
  6052.   #--------------------------------------------------------------------------#  
  6053.   def update_mp_bar()
  6054.     if @mp_bar.nil?() && !@character.ygg_attacker.nil?()
  6055.       create_mp_bar()
  6056.     elsif !@mp_bar.nil?() && @character.ygg_attacker.nil?()  
  6057.       dispose_mp_bar()
  6058.     end
  6059.     @mp_bar.update() unless @mp_bar.nil?()
  6060.   end
  6061.  
  6062. end if ::YGG::USE_STAT_BARS
  6063.  
  6064. #==============================================================================#
  6065. # ** YGG
  6066. #==============================================================================#
  6067. module YGG  
  6068. #==============================================================================#
  6069. # ** PopText
  6070. #==============================================================================#  
  6071.   PopText = Struct.new( :text, :font, :move_rule )
  6072. #==============================================================================#  
  6073.   class PopText
  6074.    
  6075.   #--------------------------------------------------------------------------#
  6076.   # * new-class-method :create_pop
  6077.   #--------------------------------------------------------------------------#  
  6078.     def self.create_pop( setup_data={} )
  6079.       character  = setup_data[:character]
  6080.       bat        = setup_data[:battler] || (character.nil?() ? nil : character.ygg_battler)
  6081.       type       = setup_data[:type] || :nil
  6082.       parameters = setup_data[:parameters] || []
  6083.       move_rule  = :default
  6084.       pop_stack  = []
  6085.       font_size_add = 0
  6086.       case type
  6087.       when :attack_damage, :skill_damage, :item_damage
  6088.         case type
  6089.         when :attack_damage
  6090.           move_rule = bat.critical ? :shatter : :attack_default
  6091.         when :skill_damage  
  6092.           move_rule = bat.critical ? :shatter : :skill_default
  6093.         when :item_damage
  6094.           move_rule = bat.critical ? :shatter : :item_default
  6095.         end
  6096.         font_size_add += ::YGG::CRITICAL_FONTSIZE_ADD if bat.critical
  6097.         if bat.hp_damage > 0
  6098.           rule = YGG::POPUP_RULES["HP_DMG"]
  6099.           text = sprintf( YGG::POPUP_SETTINGS[:hp_dmg], bat.hp_damage.abs )
  6100.         elsif bat.hp_damage < 0
  6101.           rule = YGG::POPUP_RULES["HP_HEAL"]
  6102.           text = sprintf( YGG::POPUP_SETTINGS[:hp_heal], bat.hp_damage.abs )
  6103.         elsif bat.missed    
  6104.           rule = YGG::POPUP_RULES["MISSED"]
  6105.           text = YGG::POPUP_SETTINGS[:missed]
  6106.         elsif bat.evaded    
  6107.           rule = YGG::POPUP_RULES["EVADED"]
  6108.           text = YGG::POPUP_SETTINGS[:evaded]
  6109.         elsif bat.skipped  
  6110.           rule = YGG::POPUP_RULES["NULLED"]
  6111.           text = YGG::POPUP_SETTINGS[:nulled]
  6112.         elsif bat.hp_damage == 0
  6113.           rule = YGG::POPUP_RULES["HP_NO_DMG"]
  6114.           text = sprintf( YGG::POPUP_SETTINGS[:hp_dmg], bat.hp_damage.abs )
  6115.         end
  6116.         pop_stack << [text, rule, move_rule]  
  6117.         pop_stack << [YGG::POPUP_SETTINGS[:critical],
  6118.                       YGG::POPUP_RULES["CRITICAL"],
  6119.                       :crit_default] if bat.critical if YGG::SHOW_CRITICAL
  6120.         pop_stack << [POPUP_SETTINGS[:guard],
  6121.                       YGG::POPUP_RULES["GUARD"],
  6122.                       :guard_default] if bat.guarding?() if YGG::SHOW_GUARD            
  6123.         if type == :skill_damage || type == :item_damage          
  6124.           skip_stack = false
  6125.           if bat.mp_damage > 0
  6126.             rule = YGG::POPUP_RULES["MP_DMG"]
  6127.             text = sprintf( YGG::POPUP_SETTINGS[:mp_dmg], bat.mp_damage.abs )
  6128.           elsif bat.mp_damage < 0
  6129.             rule = YGG::POPUP_RULES["MP_HEAL"]
  6130.             text = sprintf( YGG::POPUP_SETTINGS[:mp_heal], bat.mp_damage.abs )
  6131.           elsif bat.missed  
  6132.             skip_stack = true
  6133.             #rule = YGG::POPUP_RULES["MISSED"]
  6134.             #text = YGG::POPUP_SETTINGS[:missed]
  6135.           elsif bat.evaded    
  6136.             skip_stack = true
  6137.             #rule = YGG::POPUP_RULES["EVADED"]
  6138.             #text = YGG::POPUP_SETTINGS[:evaded]
  6139.           elsif bat.skipped  
  6140.             skip_stack = true
  6141.             #rule = YGG::POPUP_RULES["NULLED"]
  6142.             #text = YGG::POPUP_SETTINGS[:nulled]
  6143.           elsif bat.mp_damage == 0
  6144.             skip_stack = true
  6145.           #  rule = YGG::POPUP_RULES["MP_NO_DMG"]
  6146.           #  text = sprintf( YGG::POPUP_SETTINGS[:mp_dmg], bat.mp_damage.abs )
  6147.           end
  6148.           pop_stack << [text, rule, move_rule] unless skip_stack
  6149.         end
  6150.       when :gain_exp
  6151.         rule = YGG::POPUP_RULES["EXP_POP"]
  6152.         text = sprintf( YGG::POPUP_SETTINGS[:exp_pop], parameters[0] )
  6153.         move_rule = :exp_default
  6154.         pop_stack << [text, rule, move_rule]
  6155.       when :level_up  
  6156.         rule = YGG::POPUP_RULES["LVL_POP"]
  6157.         text = sprintf( YGG::POPUP_SETTINGS[:lvl_pop], parameters[0] )
  6158.         move_rule = :lvl_default
  6159.         pop_stack << [text, rule, move_rule]
  6160.       when :custom
  6161.         rule = [
  6162.           setup_data[:font_size] || Font.default_size,
  6163.           setup_data[:font_color] || Font.default_color,
  6164.           setup_data[:font_name] || Font.default_name,
  6165.           [(setup_data[:font_bold] || Font.default_bold) ? "BOLD" : "NO BOLD",
  6166.            (setup_data[:font_italic] || Font.default_italic) ? "ITALIC" : "NO ITALIC",
  6167.            (setup_data[:font_shadow] || Font.default_shadow) ? "SHADOW" : "NO SHADOW"
  6168.           ],
  6169.           setup_data[:font_name]
  6170.         ]
  6171.         pop_stack << [setup_data[:text] || "", rule, setup_data[:move_rule] || :default]
  6172.       end
  6173.       pop_stack.each { |pop|
  6174.         text, rule, move_rule = *pop
  6175.         font        = Font.new()
  6176.         proprule    = rule[2].inject([]) { |r, s| s.upcase }
  6177.         colors      = rule[1].kind_of?( Array ) ? rule[1] : [rule[1], rule[1]]
  6178.         font.name   = rule[3].empty? ? Font.default_name : rule[3]
  6179.         font.size   = (rule[0] || Font.default_size) + font_size_add
  6180.         font.bold   = proprule.include?("BOLD")
  6181.         font.italic = proprule.include?("ITALIC")
  6182.         font.shadow = proprule.include?("SHADOW")
  6183.         font.bold   = false if proprule.include?("NO BOLD")
  6184.         font.italic = false if proprule.include?("NO ITALIC")
  6185.         font.shadow = false if proprule.include?("NO SHADOW")
  6186.         font.color  = bat.nil?() ? colors[1] : (bat.actor?() ? colors[1] : colors[0])
  6187.         $game_yggdrasil.add_pop( PopText.new( text, font, move_rule ), character.x, character.y )
  6188.       }
  6189.     end
  6190.    
  6191.   end  
  6192.  
  6193. #==============================================================================#
  6194. # ** PopHandler
  6195. #==============================================================================#  
  6196.   class PopHandler < ::YGG::Handlers::Screen
  6197.    
  6198.     class BounceHandle
  6199.    
  6200.     #--------------------------------------------------------------------------#
  6201.     # * Public Instance Variable(s)
  6202.     #--------------------------------------------------------------------------#    
  6203.       attr_accessor :x, :y
  6204.       attr_accessor :ox, :oy
  6205.      
  6206.       attr_accessor :x_velocity, :y_velocity
  6207.       attr_accessor :x_boost, :y_boost
  6208.       attr_accessor :x_add, :y_add
  6209.    
  6210.       attr_accessor :cap_duration
  6211.       attr_accessor :finished
  6212.       attr_accessor :pause_update
  6213.       attr_accessor :gravity
  6214.       attr_accessor :floor_val
  6215.      
  6216.     #--------------------------------------------------------------------------#
  6217.     # * Constant(s)
  6218.     #--------------------------------------------------------------------------#      
  6219.       GRAVITY = 0.58
  6220.       TRANSEPARENT_START = 0
  6221.       TRANSEPARENT_X_SLIDE = 0    
  6222.      
  6223.     #--------------------------------------------------------------------------#
  6224.     # * new-method :initialize
  6225.     #--------------------------------------------------------------------------#
  6226.       def initialize( setup_data={} )
  6227.         @start_settings = [setup_data[:x] || 0, setup_data[:y] || 0, 0, 0]
  6228.         @cap_duration = setup_data[:cap_duration] || 80
  6229.         @x_velocity = setup_data[:x_velocity] || 0.4
  6230.         @y_velocity = setup_data[:y_velocity] || 1.5
  6231.         @x_boost    = setup_data[:x_boost] || 8
  6232.         @y_boost    = setup_data[:y_boost] || 4
  6233.         @x_add      = setup_data[:x_add] || 0
  6234.         @y_add      = setup_data[:y_add] || 4
  6235.         @gravity    = setup_data[:gravity] || GRAVITY
  6236.         @floor_val  = setup_data[:floor_val] || 0
  6237.         reset()
  6238.       end
  6239.      
  6240.     #--------------------------------------------------------------------------#
  6241.     # * new-method :reset
  6242.     #--------------------------------------------------------------------------#
  6243.       def reset()
  6244.         @x, @y, @ox, @oy = *@start_settings
  6245.         @finished = false
  6246.         @pause_update = false
  6247.         prep_pop()
  6248.       end
  6249.      
  6250.     #--------------------------------------------------------------------------#
  6251.     # * new-method :x_init_velocity
  6252.     #--------------------------------------------------------------------------#
  6253.       def x_init_velocity()
  6254.         return @x_velocity * ( rand(@x_boost) + @x_add )
  6255.       end
  6256.      
  6257.     #--------------------------------------------------------------------------#
  6258.     # * new-method :y_init_velocity
  6259.     #--------------------------------------------------------------------------#
  6260.       def y_init_velocity()
  6261.         return @y_velocity * ( rand(@y_boost) + @y_add )  
  6262.       end
  6263.      
  6264.     #--------------------------------------------------------------------------#
  6265.     # * new-method :prep_pop
  6266.     #--------------------------------------------------------------------------#
  6267.       def prep_pop()
  6268.         @now_x_speed = x_init_velocity
  6269.         @now_y_speed = y_init_velocity
  6270.         @potential_x_energy = 0.0
  6271.         @potential_y_energy = 0.0
  6272.         @speed_off_x = rand(2)
  6273.         @pop_duration = @cap_duration
  6274.       end
  6275.      
  6276.     #--------------------------------------------------------------------------#
  6277.     # * new-method :update
  6278.     #--------------------------------------------------------------------------#
  6279.       def update()
  6280.         return if @finished or @pause_update
  6281.         if @pop_duration <= TRANSEPARENT_START
  6282.           @x += TRANSEPARENT_X_SLIDE if @speed_off_x == 0
  6283.           @x -= TRANSEPARENT_X_SLIDE if @speed_off_x == 1
  6284.         end
  6285.         n = @oy + @now_y_speed
  6286.         if n <= @floor_val #0
  6287.           @now_y_speed *= -1
  6288.           @now_y_speed /=  2
  6289.           @now_x_speed /=  2
  6290.         end      
  6291.         @oy = [n, @floor_val].max
  6292.         @potential_y_energy += @gravity
  6293.         speed                = @potential_y_energy.floor
  6294.         @now_y_speed        -= speed
  6295.         @potential_y_energy -= speed
  6296.         @potential_x_energy += @now_x_speed
  6297.         speed                = @potential_x_energy.floor
  6298.         @ox                 += speed if @speed_off_x == 0
  6299.         @ox                 -= speed if @speed_off_x == 1
  6300.         @potential_x_energy -= speed
  6301.         @pop_duration       -= 1
  6302.         if @pop_duration == 0
  6303.           @finished = true
  6304.         end
  6305.       end
  6306.    
  6307.     end
  6308.  
  6309.   #--------------------------------------------------------------------------#
  6310.   # * Public Instance Variable(s)
  6311.   #--------------------------------------------------------------------------#    
  6312.     attr_accessor :ox, :oy, :oz
  6313.     attr_accessor :width, :height
  6314.     attr_accessor :zoom_x, :zoom_y
  6315.     attr_accessor :opacity
  6316.    
  6317.     attr_accessor :poptext
  6318.     attr_accessor :completed
  6319.    
  6320.   #--------------------------------------------------------------------------#
  6321.   # * new-method :initialize
  6322.   #--------------------------------------------------------------------------#                      
  6323.     def initialize( poptext, x, y, z )
  6324.       super( x, y, z )
  6325.       @frame     = 0
  6326.       @poptext   = poptext
  6327.       @ox        = 0
  6328.       @oy        = 0
  6329.       @oz        = 0
  6330.       @width     = 128
  6331.       @height    = 32
  6332.       @opacity   = 255
  6333.       @zoom_x    = 1.0
  6334.       @zoom_y    = 1.0
  6335.       @completed = false
  6336.       @bounce_handle = BounceHandle.new( { :x => 0, :y => 0 } )
  6337.     end
  6338.    
  6339.   #--------------------------------------------------------------------------#
  6340.   # * new-method :complete?()
  6341.   #--------------------------------------------------------------------------#                    
  6342.     def complete?() ; return @completed ; end
  6343.      
  6344.   #--------------------------------------------------------------------------#
  6345.   # * new-method :update
  6346.   #--------------------------------------------------------------------------#                  
  6347.     def update()
  6348.       case @poptext.move_rule
  6349.       when :default
  6350.         case @frame
  6351.         when 0..10
  6352.           @ox += 2
  6353.         when 11..20
  6354.           @ox -= 2
  6355.         when 21..40
  6356.           @oy -= 2
  6357.         when 41..60
  6358.           @oy -= 4
  6359.           @opacity -= 255 / 20
  6360.         when 61
  6361.           @completed = true
  6362.         end
  6363.       when :attack_default, :skill_default, :item_default  
  6364.         @bounce_handle.update()
  6365.         @ox, @oy = @bounce_handle.ox, -@bounce_handle.oy
  6366.         @completed = @bounce_handle.finished
  6367.       when :exp_default
  6368.         case @frame
  6369.         when 0...1
  6370.           @oy -= 16
  6371.         when 1..32
  6372.           @oy += 1
  6373.         when 33..64
  6374.           @opacity -= 255 / 32
  6375.         when 65
  6376.           @completed = true
  6377.         end
  6378.       when :lvl_default
  6379.         case @frame
  6380.         when 0..64
  6381.           @ox -= 1
  6382.         when 65..96  
  6383.           @opacity -= 255 / 32
  6384.         when 97
  6385.           @completed = true
  6386.         end  
  6387.       when :crit_default
  6388.         case @frame
  6389.         when 0...1
  6390.           @oy -= 16
  6391.         when 1..32
  6392.           @oy -= 2
  6393.           @zoom_x += 1.0 / 32
  6394.           @zoom_y = @zoom_x
  6395.         when 33..64
  6396.           @opacity -= 255 / 32
  6397.           @zoom_x -= 1.0 / 32
  6398.           @zoom_y = @zoom_x
  6399.         when 65
  6400.           @completed = true
  6401.         end
  6402.       when :guard_default  
  6403.         case @frame
  6404.         when 0...1
  6405.           @oy -= 16
  6406.         when 1..32
  6407.           @oy -= 2
  6408.           @zoom_x += 0.5 / 32
  6409.           @zoom_y = @zoom_x
  6410.         when 33..64
  6411.           @opacity -= 255 / 32
  6412.           @zoom_x -= 0.5 / 32
  6413.           @zoom_y = @zoom_x
  6414.         when 65
  6415.           @completed = true
  6416.         end
  6417.       when :shatter
  6418.         case @frame
  6419.         when 0..5
  6420.           @ox += 3
  6421.         when 6..10
  6422.           @ox -= 3
  6423.         when 11..30
  6424.           @ox += 3
  6425.           @oy -= 1
  6426.           @opacity -= 255 / 80
  6427.         when 31..50
  6428.           @ox -= 3
  6429.           @oy -= 1
  6430.           @opacity -= 255 / 80
  6431.         when 51..60  
  6432.           @opacity -= 255 / 40
  6433.         when 61
  6434.           @completed = true
  6435.         end
  6436.       end
  6437.       @frame += 1
  6438.     end  
  6439.    
  6440.   #--------------------------------------------------------------------------#
  6441.   # * new-method :screen_|x/y/z
  6442.   #--------------------------------------------------------------------------#                
  6443.     def screen_x() ; return super() + @ox      ; end    
  6444.     def screen_y() ; return super() + @oy + 32 ; end    
  6445.     def screen_z() ; return super() + @oz      ; end
  6446.    
  6447.   end
  6448.  
  6449. #==============================================================================#
  6450. # ** PopSprite
  6451. #==============================================================================#  
  6452.   class PopSprite < ::Sprite
  6453.    
  6454.   #--------------------------------------------------------------------------#
  6455.   # * Public Instance Variable(s)
  6456.   #--------------------------------------------------------------------------#        
  6457.     attr_accessor :pophandler
  6458.     attr_accessor :completed
  6459.    
  6460.   #--------------------------------------------------------------------------#
  6461.   # * new-method :initialize
  6462.   #--------------------------------------------------------------------------#              
  6463.     def initialize( viewport, pophandler )
  6464.       super( viewport )
  6465.       @pophandler      = pophandler
  6466.       self.bitmap      = Bitmap.new( @pophandler.width, @pophandler.height )
  6467.       self.ox          = @pophandler.width / 2
  6468.       self.bitmap.font = @pophandler.poptext.font.clone
  6469.       self.bitmap.draw_text( 0, 0, @pophandler.width, 24, @pophandler.poptext.text, 1 )
  6470.     end
  6471.  
  6472.   #--------------------------------------------------------------------------#
  6473.   # * new-method :dispose
  6474.   #--------------------------------------------------------------------------#              
  6475.     def dispose()
  6476.       @pophandler = nil
  6477.       unless self.bitmap.nil?()
  6478.         self.bitmap.font = Font.new()
  6479.         self.bitmap.dispose()
  6480.       end  
  6481.       self.bitmap = nil
  6482.       super()
  6483.     end
  6484.    
  6485.   #--------------------------------------------------------------------------#
  6486.   # * new-method :update
  6487.   #--------------------------------------------------------------------------#            
  6488.     def update()
  6489.       super()
  6490.       self.x       = @pophandler.screen_x
  6491.       self.y       = @pophandler.screen_y
  6492.       self.z       = @pophandler.screen_z
  6493.       self.zoom_x  = @pophandler.zoom_x
  6494.       self.zoom_y  = @pophandler.zoom_y
  6495.       self.opacity = @pophandler.opacity
  6496.       @completed   = @pophandler.completed
  6497.     end
  6498.    
  6499.   end
  6500. #==============================================================================#
  6501. # ** PopSpriteset
  6502. #==============================================================================#
  6503.   class PopSpriteset
  6504.    
  6505.   #--------------------------------------------------------------------------#
  6506.   # * new-method :initialize
  6507.   #--------------------------------------------------------------------------#        
  6508.     def initialize( viewport )
  6509.       @viewport = viewport
  6510.       @pop_sprites = []
  6511.       create_pops()
  6512.     end
  6513.    
  6514.   #--------------------------------------------------------------------------#
  6515.   # * new-method :create_pops
  6516.   #--------------------------------------------------------------------------#    
  6517.     def create_pops()
  6518.       $game_yggdrasil.new_poptexts.clear()
  6519.       $game_yggdrasil.pop_texts.each { |hnd| add_pop( hnd ) }
  6520.     end
  6521.    
  6522.   #--------------------------------------------------------------------------#
  6523.   # * new-method :dispose
  6524.   #--------------------------------------------------------------------------#
  6525.     def dispose()
  6526.       @pop_sprites.each { |sp| sp.dispose() }
  6527.       @pop_sprites.clear()
  6528.     end
  6529.  
  6530.   #--------------------------------------------------------------------------#
  6531.   # * new-method :update
  6532.   #--------------------------------------------------------------------------#
  6533.     def update()
  6534.       unless $game_yggdrasil.new_poptexts.empty?()
  6535.         $game_yggdrasil.new_poptexts.each { |hnd| add_pop( hnd ) }
  6536.         $game_yggdrasil.new_poptexts.clear()
  6537.       end  
  6538.       @pop_sprites = @pop_sprites.inject([]) { |result, sprite|
  6539.         sprite.update() ; sprite.dispose() if sprite.completed
  6540.         result << sprite unless sprite.disposed?() ; result
  6541.       } unless @pop_sprites.empty?()
  6542.     end
  6543.    
  6544.   #--------------------------------------------------------------------------#
  6545.   # * new-method :add_pop
  6546.   #--------------------------------------------------------------------------#
  6547.     def add_pop( pophandler )
  6548.       @pop_sprites << PopSprite.new( @viewport, pophandler )
  6549.     end
  6550.    
  6551.   end
  6552.  
  6553. end
  6554.  
  6555. #==============================================================================#
  6556. # ** Spriteset_Map
  6557. #==============================================================================#
  6558. class Spriteset_Map
  6559.  
  6560.   #--------------------------------------------------------------------------#
  6561.   # * Public Instance Variable(s)
  6562.   #--------------------------------------------------------------------------#      
  6563.   attr_accessor :poptext_spriteset
  6564.  
  6565.   #--------------------------------------------------------------------------#
  6566.   # * new-method :initialize
  6567.   #--------------------------------------------------------------------------#  
  6568.   alias :ygg_spm_ptxt_initialize :initialize unless $@  
  6569.   def initialize( *args, &block )
  6570.     ygg_spm_ptxt_initialize( *args, &block )
  6571.     create_poptext_spriteset()
  6572.   end
  6573.  
  6574.   #--------------------------------------------------------------------------#
  6575.   # * new-method :create_poptext_spriteset
  6576.   #--------------------------------------------------------------------------#  
  6577.   def create_poptext_spriteset()
  6578.     @poptext_spriteset = YGG::PopSpriteset.new( @viewport2 )
  6579.   end
  6580.  
  6581.   #--------------------------------------------------------------------------#
  6582.   # * alias-method :dispose
  6583.   #--------------------------------------------------------------------------#
  6584.   alias :ygg_spm_ptxt_dispose :dispose unless $@  
  6585.   def dispose( *args, &block )
  6586.     @poptext_spriteset.dispose() unless @poptext_spriteset.nil?()
  6587.     ygg_spm_ptxt_dispose( *args, &block )
  6588.   end
  6589.  
  6590.   #--------------------------------------------------------------------------#
  6591.   # * alias-method :update
  6592.   #--------------------------------------------------------------------------#  
  6593.   alias :ygg_spm_ptxt_update :update unless $@
  6594.   def update( *args, &block )
  6595.     ygg_spm_ptxt_update( *args, &block )
  6596.     @poptext_spriteset.update() unless @poptext_spriteset.nil?()
  6597.   end
  6598.  
  6599. end if ::YGG::USE_TEXT_POP
  6600.  
  6601. # // (YGG_DropsWindow)
  6602. #==============================================================================#
  6603. # ** YGG::Drops_Window
  6604. #==============================================================================#
  6605. class YGG::Drops_Window < ::Sprite
  6606.  
  6607.   #--------------------------------------------------------------------------#
  6608.   # * Constant(s)
  6609.   #--------------------------------------------------------------------------#      
  6610.   CHANGE_MAX  = 90  # 120
  6611.   FADE_LIMIT  = 30  # 30
  6612.   FADE_SPEED  = 40  # 60
  6613.   WLH         = 24
  6614.   BORDER_SIZE = 2
  6615.  
  6616.   #--------------------------------------------------------------------------#
  6617.   # * Public Instance Variable(s)
  6618.   #--------------------------------------------------------------------------#      
  6619.   attr_accessor :cleared
  6620.  
  6621.   #--------------------------------------------------------------------------#
  6622.   # * super-method :initialize
  6623.   #--------------------------------------------------------------------------#
  6624.   def initialize( setup_data={}, viewport=nil )
  6625.     super( viewport )
  6626.     width = setup_data[:width] || 128
  6627.     @background = Sprite.new( self.viewport )
  6628.     @background.bitmap = Bitmap.new( width, WLH )
  6629.     @background.bitmap.fill_rect( BORDER_SIZE, BORDER_SIZE,
  6630.       width-(BORDER_SIZE*2), WLH-(BORDER_SIZE*2),
  6631.       Color.new( 0, 0, 0 ) )
  6632.     @background.bitmap.blur() ; @background.bitmap.blur()
  6633.     @background.opacity = 198
  6634.     self.bitmap = Bitmap.new( width, WLH )
  6635.     self.src_rect.set( 0, 0, width, WLH )
  6636.     @change_time = 0
  6637.     @cleared = false
  6638.     self.x, self.y, self.z = setup_data[:x] || 0, setup_data[:y] || 0, setup_data[:z] || 200
  6639.   end
  6640.  
  6641.   #--------------------------------------------------------------------------#
  6642.   # * super-method :dispose
  6643.   #--------------------------------------------------------------------------#
  6644.   def dispose()
  6645.     unless @background.nil?()
  6646.       @background.bitmap.dispose() ; @background.dispose()
  6647.     end
  6648.     self.bitmap.dispose()
  6649.     super()
  6650.   end
  6651.  
  6652.   #--------------------------------------------------------------------------#
  6653.   # * super-method :x=
  6654.   #--------------------------------------------------------------------------#
  6655.   def x=( new_x )
  6656.     super( new_x )
  6657.     @background.x = self.x
  6658.   end
  6659.  
  6660.   #--------------------------------------------------------------------------#
  6661.   # * super-method :y=
  6662.   #--------------------------------------------------------------------------#
  6663.   def y=( new_y )
  6664.     super( new_y )
  6665.     @background.y = self.y
  6666.   end
  6667.  
  6668.   #--------------------------------------------------------------------------#
  6669.   # * super-method :z=
  6670.   #--------------------------------------------------------------------------#
  6671.   def z=( new_z )
  6672.     super( new_z+1 )
  6673.     @background.z = new_z
  6674.   end
  6675.  
  6676.   #--------------------------------------------------------------------------#
  6677.   # * super-method :viewport=
  6678.   #--------------------------------------------------------------------------#
  6679.   def viewport=( new_viewport )
  6680.     super( new_viewport )
  6681.     @background.viewport = self.viewport
  6682.   end
  6683.  
  6684.   #--------------------------------------------------------------------------#
  6685.   # * super-method :visible=
  6686.   #--------------------------------------------------------------------------#
  6687.   def visible=( new_visible )
  6688.     super( new_visible )
  6689.     @background.visible = self.visible
  6690.   end
  6691.  
  6692.   #--------------------------------------------------------------------------#
  6693.   # * new-method :draw_icon
  6694.   #--------------------------------------------------------------------------#
  6695.   def draw_icon( icon_index, x, y, enabled = true )
  6696.     bitmap = Cache.system( "Iconset" )
  6697.     rect = Rect.new( icon_index % 16 * 24, icon_index / 16 * 24, 24, 24 )
  6698.     self.bitmap.blt( x, y, bitmap, rect, enabled ? 255 : 128 )
  6699.   end unless method_defined? :draw_icon
  6700.  
  6701.   #--------------------------------------------------------------------------#
  6702.   # * new-method :draw_currency_value
  6703.   #--------------------------------------------------------------------------#
  6704.   def draw_currency_value( value, x, y, width )
  6705.     cx = self.bitmap.text_size( Vocab::gold ).width
  6706.     self.bitmap.font.color = Color.new( 255, 255, 255 )
  6707.     self.bitmap.draw_text( x, y, width-cx-2, WLH, value, 2 )
  6708.     self.bitmap.font.color = Color.new( 255, 255, 176 )
  6709.     self.bitmap.draw_text( x, y, width, WLH, Vocab::gold, 2 )
  6710.   end unless method_defined? :draw_currency_value
  6711.  
  6712.   #--------------------------------------------------------------------------#
  6713.   # * super-method :update
  6714.   #--------------------------------------------------------------------------#
  6715.   def update()
  6716.     super()
  6717.     @change_time -= 1 unless @change_time == 0
  6718.     if @change_time <= FADE_LIMIT
  6719.       self.opacity -= 255.0 / FADE_SPEED
  6720.     else
  6721.       self.opacity += 255.0 / FADE_SPEED
  6722.     end  
  6723.     if @change_time <= 0
  6724.       unless @cleared
  6725.         self.bitmap.clear()
  6726.         @cleared = true
  6727.       end  
  6728.       unless $game_player.ygg_gained_items.empty?
  6729.         obj = $game_player.ygg_gained_items.shift
  6730.         draw_icon( obj.icon_index, 4, 0 )
  6731.         self.bitmap.font.color = Color.new( 255, 255, 255 )
  6732.         self.bitmap.font.size  = 18
  6733.         self.bitmap.draw_text( 28, 0, self.width + 32, WLH, obj.name )
  6734.         if obj.is_a?( ::YGG::Containers::GoldItem )
  6735.           cc = obj.gold_amount
  6736.           draw_currency_value( cc, 0, 0, self.width - 4 )
  6737.         end  
  6738.         @cleared = false
  6739.         @change_time = CHANGE_MAX
  6740.       end
  6741.     end  
  6742.   end
  6743.  
  6744. end
  6745.  
  6746. #==============================================================================#
  6747. # ** YGG::Sprites::Animation
  6748. #==============================================================================#  
  6749. class YGG::Sprites::Animation < ::YGG::Handlers::Screen
  6750.  
  6751.   #--------------------------------------------------------------------------#
  6752.   # * Constants
  6753.   #--------------------------------------------------------------------------#
  6754.   RATE = 3 # // RMVX Default is 4
  6755.   RATE = ::Sprite_Base::RATE if $imported["IEO-BugFixesUpgrades"] || $imported["CoreFixesUpgradesMelody"]
  6756.  
  6757.   #--------------------------------------------------------------------------#
  6758.   # * Class Variable(s)
  6759.   #--------------------------------------------------------------------------#
  6760.   @@animations = []
  6761.   @@_reference_count = {}
  6762.  
  6763.   #--------------------------------------------------------------------------#
  6764.   # * Public Instance Variable(s)
  6765.   #--------------------------------------------------------------------------#
  6766.   attr_accessor :completed
  6767.   attr_accessor :looped_anim
  6768.   attr_accessor :started_anim
  6769.   attr_accessor :viewport
  6770.   attr_accessor :ox, :oy
  6771.   attr_accessor :opacity
  6772.  
  6773.   #--------------------------------------------------------------------------#
  6774.   # * new-method :initialize
  6775.   #--------------------------------------------------------------------------#
  6776.   def initialize( viewport=nil )
  6777.     super( 0, 0, 0 )
  6778.     @viewport           = viewport
  6779.     @animation          = nil
  6780.     @animation_bitmap1  = nil
  6781.     @animation_bitmap2  = nil
  6782.     @animation_duration = 0     # Remaining animation time
  6783.     @started_anim       = false
  6784.     @looped_anim        = false
  6785.     @completed          = true
  6786.     @targets            = []
  6787.     @ox, @oy            = -16, -32
  6788.     @opacity            = 255
  6789.   end
  6790.  
  6791.   #--------------------------------------------------------------------------#
  6792.   # * new-method :animation?
  6793.   #--------------------------------------------------------------------------#
  6794.   def animation? ; return !@animation.nil?() ; end
  6795.    
  6796.   #--------------------------------------------------------------------------#
  6797.   # * new-method :width
  6798.   #--------------------------------------------------------------------------#  
  6799.   def width ; return 32 ; end
  6800.    
  6801.   #--------------------------------------------------------------------------#
  6802.   # * new-method :height
  6803.   #--------------------------------------------------------------------------#    
  6804.   def height ; return 32 ; end
  6805.    
  6806.   #--------------------------------------------------------------------------#
  6807.   # * new-method :cell_limit
  6808.   #--------------------------------------------------------------------------#    
  6809.   def cell_limit ; 4 ; end  
  6810.  
  6811.   #--------------------------------------------------------------------------#
  6812.   # * new-method :flash
  6813.   #--------------------------------------------------------------------------#  
  6814.   def flash( color, duration )
  6815.     @targets.each { |sp| sp.flash( color, duration ) unless sp.disposed?() }
  6816.   end
  6817.  
  6818.   #--------------------------------------------------------------------------#
  6819.   # * new-method :screen_rect
  6820.   #--------------------------------------------------------------------------#  
  6821.   def screen_rect()
  6822.     @screen_rect ||= Rect.new( -32, -32, Graphics.width, Graphics.height )
  6823.     return @screen_rect
  6824.   end
  6825.  
  6826.   #--------------------------------------------------------------------------#
  6827.   # * new-method :onScreen?
  6828.   #--------------------------------------------------------------------------#  
  6829.   def onScreen?()
  6830.     r = self.screen_rect
  6831.     return self.screen_x.between?( r.x, r.width ) && self.screen_y.between?( r.y, r.height )
  6832.   end
  6833.  
  6834.   #--------------------------------------------------------------------------#
  6835.   # * new-method :limitedOnScreen?
  6836.   #--------------------------------------------------------------------------#  
  6837.   def limitedOnScreen?()
  6838.     return false unless screen_x.between?( 0, Graphics.width ) && screen_y.between?( 0, Graphics.height )
  6839.     return true
  6840.   end
  6841.  
  6842.   #--------------------------------------------------------------------------#
  6843.   # * new-method :play_anim
  6844.   #--------------------------------------------------------------------------#
  6845.   def play_anim( anim_id, targets=[] )
  6846.     set_targets( targets ) ; animation = $data_animations[anim_id]
  6847.     raise "Animation #{anim_id} does not exist" if ::YGG.debug_mode?() && animation.nil?()
  6848.     animation = RPG::Animation.new if animation.nil?() if ::YGG.silent_error?()
  6849.     start_animation( animation )
  6850.   end
  6851.  
  6852.   #--------------------------------------------------------------------------#
  6853.   # * new-method :setup_pos
  6854.   #--------------------------------------------------------------------------#
  6855.   def setup_pos( x, y, looped = false )
  6856.     self.moveto( x, y )
  6857.     @looped_anim = looped
  6858.   end
  6859.  
  6860.   #--------------------------------------------------------------------------#
  6861.   # * new-method :set_targets
  6862.   #--------------------------------------------------------------------------#
  6863.   def set_targets( new_targets )
  6864.     @targets.clear() ; @targets += new_targets
  6865.     @targets = @targets.flatten.uniq.compact
  6866.   end
  6867.  
  6868.   #--------------------------------------------------------------------------#
  6869.   # * new-method :load_animation_bitmap
  6870.   #--------------------------------------------------------------------------#  
  6871.   def load_animation_bitmap()
  6872.     animation1_name    = @animation.animation1_name
  6873.     animation1_hue     = @animation.animation1_hue
  6874.     animation2_name    = @animation.animation2_name
  6875.     animation2_hue     = @animation.animation2_hue
  6876.     @animation_bitmap1 = Cache.animation(animation1_name, animation1_hue)
  6877.     @animation_bitmap2 = Cache.animation(animation2_name, animation2_hue)
  6878.     if @@_reference_count.include?(@animation_bitmap1)
  6879.       @@_reference_count[@animation_bitmap1] += 1
  6880.     else
  6881.       @@_reference_count[@animation_bitmap1] = 1
  6882.     end
  6883.     if @@_reference_count.include?(@animation_bitmap2)
  6884.       @@_reference_count[@animation_bitmap2] += 1
  6885.     else
  6886.       @@_reference_count[@animation_bitmap2] = 1
  6887.     end
  6888.     Graphics.frame_reset()
  6889.   end
  6890.  
  6891.   #--------------------------------------------------------------------------#
  6892.   # * overwrite-method :start_animation
  6893.   #--------------------------------------------------------------------------#
  6894.   def start_animation( animation, mirror = false )
  6895.     dispose_animation()
  6896.     @animation = animation
  6897.     return if @animation.nil?()
  6898.     @animation_mirror = mirror
  6899.     @animation_duration = @animation.frame_max * RATE + 1
  6900.     load_animation_bitmap()
  6901.     @animation_sprites = []
  6902.     @cell_count = [animation.cell_count, self.cell_limit].min
  6903.     if @animation.position != 3 or not @@animations.include?( animation )
  6904.       for i in 0...@cell_count
  6905.         sprite = ::Sprite.new( viewport )
  6906.         sprite.visible = false
  6907.         @animation_sprites.push( sprite )
  6908.       end
  6909.       unless @@animations.include?( animation )
  6910.         @@animations.push( animation )
  6911.       end
  6912.     end
  6913.     update_animation_position()
  6914.     @started_anim = true
  6915.   end
  6916.  
  6917.   #--------------------------------------------------------------------------#
  6918.   # * new-method :dispose
  6919.   #--------------------------------------------------------------------------#
  6920.   def dispose() ; dispose_animation() ; end
  6921.  
  6922.   #--------------------------------------------------------------------------#
  6923.   # * new-method :dispose_animation
  6924.   #--------------------------------------------------------------------------#
  6925.   def dispose_animation()
  6926.     if @animation_bitmap1 != nil
  6927.       @@_reference_count[@animation_bitmap1] -= 1
  6928.       if @@_reference_count[@animation_bitmap1] == 0
  6929.         @animation_bitmap1.dispose
  6930.       end
  6931.     end
  6932.     if @animation_bitmap2 != nil
  6933.       @@_reference_count[@animation_bitmap2] -= 1
  6934.       if @@_reference_count[@animation_bitmap2] == 0
  6935.         @animation_bitmap2.dispose()
  6936.       end
  6937.     end
  6938.     @animation_sprites.each { |sprite| sprite.dispose } unless @animation_sprites.nil?()
  6939.     @animation_sprites = nil
  6940.     @animation = nil
  6941.     @animation_bitmap1 = nil
  6942.     @animation_bitmap2 = nil
  6943.   end
  6944.  
  6945.   #--------------------------------------------------------------------------#
  6946.   # * new-method: update
  6947.   #--------------------------------------------------------------------------#
  6948.   def update()
  6949.     update_animation() if @animation != nil
  6950.     @@animations.clear
  6951.   end
  6952.  
  6953.   #--------------------------------------------------------------------------#
  6954.   # * new-method: update_animation
  6955.   #--------------------------------------------------------------------------#
  6956.   def update_animation()
  6957.     @animation_duration -= 1
  6958.     update_animation_position() if @animation_duration > 0
  6959.     return unless @animation_duration % RATE == 0
  6960.     if @animation_duration > 0
  6961.       frame_index = @animation.frame_max - ((@animation_duration+RATE-1)/RATE)
  6962.       animation_set_sprites( @animation.frames[frame_index] )
  6963.       for timing in @animation.timings
  6964.         next unless timing.frame == frame_index
  6965.         animation_process_timing( timing )
  6966.       end
  6967.       return
  6968.     end
  6969.     return start_animation( @animation ) if @looped_anim
  6970.     dispose_animation()
  6971.   end
  6972.  
  6973.   #--------------------------------------------------------------------------#
  6974.   # * new-method :animation_set_sprites
  6975.   #--------------------------------------------------------------------------#
  6976.   def animation_set_sprites( frame )
  6977.     cell_data = frame.cell_data
  6978.     for i in 0...@cell_count
  6979.       sprite = @animation_sprites[i]
  6980.       next if sprite.nil?()
  6981.       pattern = cell_data[i, 0]
  6982.       if pattern == nil or pattern == -1
  6983.         sprite.visible = false
  6984.         next
  6985.       end  
  6986.       unless self.onScreen?()
  6987.         sprite.visible = false
  6988.         next
  6989.       end  
  6990.       if pattern < 100
  6991.         sprite.bitmap = @animation_bitmap1
  6992.       else
  6993.         sprite.bitmap = @animation_bitmap2
  6994.       end
  6995.       sprite.visible = true
  6996.       sprite.src_rect.set( pattern % 5 * 192,
  6997.         pattern % 100 / 5 * 192, 192, 192 )
  6998.       if @animation_mirror
  6999.         sprite.x = @animation_ox - cell_data[i, 1]
  7000.         sprite.y = @animation_oy + cell_data[i, 2]
  7001.         sprite.angle = (360 - cell_data[i, 4])
  7002.         sprite.mirror = (cell_data[i, 5] == 0)
  7003.       else
  7004.         sprite.x = @animation_ox + cell_data[i, 1]
  7005.         sprite.y = @animation_oy + cell_data[i, 2]
  7006.         sprite.angle = cell_data[i, 4]
  7007.         sprite.mirror = (cell_data[i, 5] == 1)
  7008.       end
  7009.       sprite.z = self.screen_z + 300 + i
  7010.       sprite.ox = 96
  7011.       sprite.oy = 96
  7012.       sprite.zoom_x = cell_data[i, 3] / 100.0
  7013.       sprite.zoom_y = cell_data[i, 3] / 100.0
  7014.       sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  7015.       sprite.blend_type = cell_data[i, 7]
  7016.     end
  7017.   end
  7018.  
  7019.   #--------------------------------------------------------------------------#
  7020.   # * new-method: animation_process_timing
  7021.   #--------------------------------------------------------------------------#
  7022.   def animation_process_timing( timing )
  7023.     timing.se.play()
  7024.     case timing.flash_scope
  7025.     when 1
  7026.       self.flash( timing.flash_color, timing.flash_duration * RATE )
  7027.     when 2
  7028.       self.viewport.flash( timing.flash_color, timing.flash_duration * RATE ) unless self.viewport.nil?()
  7029.     when 3
  7030.       self.flash( nil, timing.flash_duration * RATE )
  7031.     end
  7032.   end
  7033.  
  7034.   #--------------------------------------------------------------------------#
  7035.   # * new-method :update_animation_position
  7036.   #--------------------------------------------------------------------------#  
  7037.   def update_animation_position()
  7038.     unless self.onScreen?()
  7039.       @animation_ox = -Graphics.width
  7040.       @animation_oy = -Graphics.height
  7041.       return
  7042.     end
  7043.     if @animation.position == 3
  7044.       if self.viewport.nil?()
  7045.         @animation_ox = Integer(Graphics.width) / 2
  7046.         @animation_oy = Integer(Graphics.height) / 2
  7047.       else
  7048.         @animation_ox = self.viewport.rect.width / 2
  7049.         @animation_oy = self.viewport.rect.height / 2
  7050.       end
  7051.     else
  7052.       @animation_ox = self.screen_x + self.ox + self.width / 2
  7053.       @animation_oy = self.screen_y + self.oy + self.height / 2
  7054.       if @animation.position == 0
  7055.         @animation_oy -= self.height / 2
  7056.       elsif @animation.position == 2
  7057.         @animation_oy += self.height / 2
  7058.       end
  7059.     end
  7060.   end
  7061.  
  7062. end
  7063.  
  7064. #==============================================================================#
  7065. # ** YGG::Sprites::Pos
  7066. #==============================================================================#
  7067. class YGG::Sprites::Pos < ::Sprite
  7068.  
  7069. # // Customize Start  
  7070.   #--------------------------------------------------------------------------#
  7071.   # * Constant(s)
  7072.   #--------------------------------------------------------------------------#
  7073.   COLOR1    = Color.new( 128, 128, 255 ) # Main Color
  7074.   COLOR2    = Color.new( 255, 178, 178 ) # Flash Color
  7075.   FLASHTIME = 60
  7076. # // Customize End  
  7077.   #--------------------------------------------------------------------------#
  7078.   # * Public Instance Variable(s)
  7079.   #--------------------------------------------------------------------------#
  7080.   attr_accessor :completed
  7081.   attr_accessor :pos_data
  7082.  
  7083.   #--------------------------------------------------------------------------#
  7084.   # * super-method :initialize
  7085.   #--------------------------------------------------------------------------#
  7086.   def initialize( pos_data, viewport = nil )
  7087.     @completed    = false
  7088.     super( viewport )
  7089.     @use_sprite = true
  7090.     @pos_data = pos_data
  7091.     self.x = @pos_data.screen_x ; self.y = @pos_data.screen_y
  7092.     self.z = 1
  7093.     self.bitmap = Bitmap.new( 32, 32 )
  7094.     rect = Rect.new(1, 1, 30, 30)
  7095.     self.bitmap.fill_rect( rect, COLOR1 )
  7096.     self.ox = 16 ; self.oy = 32
  7097.   end
  7098.  
  7099.   #--------------------------------------------------------------------------#
  7100.   # * super-method :update
  7101.   #--------------------------------------------------------------------------#
  7102.   def update()
  7103.     return if @completed
  7104.     self.x = @pos_data.screen_x()
  7105.     self.y = @pos_data.screen_y()
  7106.     self.z = @pos_data.screen_z()
  7107.     case @pos_data.fader_type
  7108.     when 0
  7109.       self.opacity -= 255 / @pos_data.fade_max
  7110.       @pos_data.fade_amount -= 1 unless @pos_data.fade_amount == 0
  7111.       @completed = true if @pos_data.fade_amount == 0
  7112.     end  
  7113.     super()
  7114.   end
  7115.  
  7116. end
  7117.  
  7118. #==============================================================================#
  7119. # ** YGG::Sprites::Icon
  7120. #==============================================================================#
  7121. class YGG::Sprites::Icon < ::Sprite
  7122.  
  7123.   #--------------------------------------------------------------------------#
  7124.   # * Public Instance Variable(s)
  7125.   #--------------------------------------------------------------------------#  
  7126.   ICON_WIDTH  = 24
  7127.   ICON_HEIGHT = 24
  7128.  
  7129.   #--------------------------------------------------------------------------#
  7130.   # * Public Instance Variable(s)
  7131.   #--------------------------------------------------------------------------#  
  7132.   attr_accessor :ref_object
  7133.  
  7134.   #--------------------------------------------------------------------------#
  7135.   # * super-method :initialize
  7136.   #--------------------------------------------------------------------------#  
  7137.   def initialize( viewport, ref_object )
  7138.     super( viewport )
  7139.     @ref_object = ref_object
  7140.     self.bitmap = Cache.system( "Iconset" )
  7141.     @icon_index = -1
  7142.     update_bitmap()
  7143.   end
  7144.  
  7145.   #--------------------------------------------------------------------------#
  7146.   # * super-method :update
  7147.   #--------------------------------------------------------------------------#
  7148.   def update()
  7149.     super() ; update_bitmap() ; update_position()
  7150.   end
  7151.  
  7152.   #--------------------------------------------------------------------------#
  7153.   # * new-method :update_position
  7154.   #--------------------------------------------------------------------------#
  7155.   def update_position()
  7156.     self.x = @ref_object.screen_x
  7157.     self.y = @ref_object.screen_y
  7158.     self.z = @ref_object.screen_z
  7159.   end
  7160.  
  7161.   #--------------------------------------------------------------------------#
  7162.   # * new-method :update_bitmap
  7163.   #--------------------------------------------------------------------------#
  7164.   def update_bitmap()
  7165.     if @ref_object.icon_index != @icon_index
  7166.       @icon_index = @ref_object.icon_index
  7167.       self.src_rect.set(
  7168.        @icon_index % 16 * ICON_WIDTH ,
  7169.        @icon_index / 16 * ICON_HEIGHT,
  7170.        ICON_WIDTH, ICON_HEIGHT )
  7171.     end
  7172.   end
  7173.  
  7174. end  
  7175.  
  7176. #==============================================================================#
  7177. # ** YGG::Sprites::EquipIcon
  7178. #==============================================================================#
  7179. class YGG::Sprites::EquipIcon < ::YGG::Sprites::Icon
  7180.  
  7181.   #--------------------------------------------------------------------------#
  7182.   # * super-method :initialize
  7183.   #--------------------------------------------------------------------------#
  7184.   def initialize( viewport, character, eqhnd_id )
  7185.     @eqhnd_id = eqhnd_id
  7186.     @parent   = character
  7187.     super( viewport, equip_handle() )
  7188.   end
  7189.  
  7190.   #--------------------------------------------------------------------------#
  7191.   # * overwrite-method :equip_handle
  7192.   #--------------------------------------------------------------------------#
  7193.   def equip_handle() ; return @parent.character.equip_handle( @eqhnd_id ) ; end
  7194.    
  7195.   #--------------------------------------------------------------------------#
  7196.   # * overwrite-method :update_position
  7197.   #--------------------------------------------------------------------------#
  7198.   def update_position()
  7199.     self.ox, self.oy = @ref_object.sox, @ref_object.soy
  7200.     self.x = @parent.x + @ref_object.ox
  7201.     self.y = @parent.y + @ref_object.oy
  7202.     self.z = @parent.z + @ref_object.oz
  7203.   end
  7204.  
  7205.   #--------------------------------------------------------------------------#
  7206.   # * new-method :update_angle
  7207.   #--------------------------------------------------------------------------#
  7208.   def update_angle()
  7209.     self.angle  = @ref_object.angle
  7210.     self.mirror = @ref_object.mirror
  7211.   end
  7212.  
  7213.   #--------------------------------------------------------------------------#
  7214.   # * new-method :update_visible
  7215.   #--------------------------------------------------------------------------#
  7216.   def update_visible()
  7217.     self.visible = @ref_object.visible
  7218.     self.opacity = @ref_object.opacity
  7219.   end
  7220.  
  7221.   #--------------------------------------------------------------------------#
  7222.   # * super-method :update
  7223.   #--------------------------------------------------------------------------#
  7224.   def update()
  7225.     @ref_object = equip_handle()
  7226.     super()
  7227.     update_angle()
  7228.     update_visible()
  7229.   end
  7230.  
  7231. end
  7232.  
  7233. #==============================================================================#
  7234. # ** YGG::Sprites::CharacterIcon
  7235. #==============================================================================#
  7236. class YGG::Sprites::CharacterIcon < ::YGG::Sprites::Icon
  7237.  
  7238.   #--------------------------------------------------------------------------#
  7239.   # * Public Instance Variable(s)
  7240.   #--------------------------------------------------------------------------#
  7241.   attr_accessor :self_timeout
  7242.  
  7243.   #--------------------------------------------------------------------------#
  7244.   # * super-method :initialize
  7245.   #--------------------------------------------------------------------------#
  7246.   def initialize( viewport, character = nil )
  7247.     super( viewport, character )
  7248.     @icon_index = 0
  7249.     self.ox = 12
  7250.     self.oy = 24
  7251.     @ready_to_remove = false
  7252.     @self_timeout = 120
  7253.     update
  7254.   end
  7255.  
  7256.   #--------------------------------------------------------------------------#
  7257.   # * new-method :ready_to_remove?
  7258.   #--------------------------------------------------------------------------#
  7259.   def ready_to_remove?() ; return @ready_to_remove ; end
  7260.  
  7261.   #--------------------------------------------------------------------------#
  7262.   # * super-method :update
  7263.   #--------------------------------------------------------------------------#
  7264.   def update()
  7265.     super()
  7266.     @self_timeout    = @ref_object.icon_time_out
  7267.     @ready_to_remove = true if @self_timeout == 0
  7268.     self.visible     = @ref_object.visible
  7269.     self.opacity     = @ref_object.opacity
  7270.   end
  7271.  
  7272. end
  7273.  
  7274. #==============================================================================#
  7275. # ** Sprite_Character
  7276. #==============================================================================#
  7277. class Sprite_Character < Sprite_Base
  7278.  
  7279.   #--------------------------------------------------------------------------#
  7280.   # * alias-method :initialize
  7281.   #--------------------------------------------------------------------------#
  7282.   alias :ygg_spc_initialize :initialize unless $@
  7283.   def initialize( *args, &block )
  7284.     ygg_spc_initialize( *args, &block )
  7285.     create_equipment()
  7286.   end
  7287.  
  7288.   #--------------------------------------------------------------------------#
  7289.   # * alias-method :dispose
  7290.   #--------------------------------------------------------------------------#
  7291.   alias :ygg_spc_dispose :dispose unless $@
  7292.   def dispose( *args, &block )
  7293.     ygg_spc_dispose( *args, &block )
  7294.     dispose_equipment()
  7295.   end
  7296.  
  7297.   #--------------------------------------------------------------------------#
  7298.   # * alias-method :update
  7299.   #--------------------------------------------------------------------------#
  7300.   alias :ygg_spc_update :update unless $@
  7301.   def update( *args, &block )
  7302.     ygg_spc_update( *args, &block )
  7303.     unless @equipment.nil?()
  7304.       if @character.use_equipment && @equipment.empty?() ; create_equipment()
  7305.       elsif !@character.use_equipment && !@equipment.empty?() ; dispose_equipment()
  7306.       end
  7307.       update_equipment()
  7308.     end  
  7309.     if $scene.is_a?( Scene_Map )
  7310.       @character.ygg_anims.each { |aid| $scene.push_ygg_anim( aid, @character.x, @character.y ) }
  7311.       @character.ygg_anims.clear()
  7312.     end  
  7313.     self.tone = @character.tone
  7314.     self.zoom_x = @character.zoom_x
  7315.     self.zoom_y = @character.zoom_y
  7316.   end
  7317.  
  7318.   #--------------------------------------------------------------------------#
  7319.   # * new-method :create_equipment
  7320.   #--------------------------------------------------------------------------#
  7321.   def create_equipment()
  7322.     @equipment = []
  7323.     if @character.use_equipment
  7324.       @equipment[0] = YGG::Sprites::EquipIcon.new( self.viewport, self, 0 ) # Weap
  7325.       @equipment[1] = YGG::Sprites::EquipIcon.new( self.viewport, self, 1 ) # Shld
  7326.     end  
  7327.   end
  7328.  
  7329.   #--------------------------------------------------------------------------#
  7330.   # * new-method :dispose_equipment
  7331.   #--------------------------------------------------------------------------#
  7332.   def dispose_equipment()
  7333.     @equipment.each { |e| e.dispose() } ; @equipment.clear()
  7334.   end
  7335.  
  7336.   #--------------------------------------------------------------------------#
  7337.   # * new-method :update_equipment
  7338.   #--------------------------------------------------------------------------#
  7339.   def update_equipment() ; @equipment.each { |e| e.update() } ; end
  7340.  
  7341. end
  7342.  
  7343. #==============================================================================#
  7344. # ** YGG::Sprites::Projectile
  7345. #==============================================================================#
  7346. class ::YGG::Sprites::Projectile < Sprite_Character
  7347.  
  7348.   #--------------------------------------------------------------------------#
  7349.   # * overwrite-method :create_bars
  7350.   #--------------------------------------------------------------------------#  
  7351.   def create_bars()  ; end
  7352.    
  7353.   #--------------------------------------------------------------------------#
  7354.   # * overwrite-method :dispose_bars
  7355.   #--------------------------------------------------------------------------#    
  7356.   def dispose_bars() ; end
  7357.  
  7358.   #--------------------------------------------------------------------------#
  7359.   # * overwrite-method :update_bars
  7360.   #--------------------------------------------------------------------------#    
  7361.   def update_bars()  ; end
  7362.    
  7363. end
  7364.  
  7365. #==============================================================================#
  7366. # ** Spriteset_Map
  7367. #==============================================================================#
  7368. class Spriteset_Map
  7369.  
  7370.   #--------------------------------------------------------------------------#
  7371.   # * Public Instance Variable(s)
  7372.   #--------------------------------------------------------------------------#
  7373.   attr_accessor :anim_viewport # Viewport used by Ygg Anims
  7374.   attr_accessor :character_sprites
  7375.   attr_accessor :projectile_sprites
  7376.   attr_accessor :range_sprites
  7377.   attr_accessor :drop_sprites
  7378.   attr_accessor :ygg_anims
  7379.   attr_accessor :viewport1, :viewport2, :viewport3
  7380.  
  7381.   #--------------------------------------------------------------------------#
  7382.   # * alias-method :initialize
  7383.   #--------------------------------------------------------------------------#
  7384.   alias :ygg_anim_ssm_initialize :initialize unless $@
  7385.   def initialize( *args, &block )
  7386.     ygg_anim_ssm_initialize( *args, &block )
  7387.     @disposed = false
  7388.     create_projectiles()
  7389.     create_anims()
  7390.     create_ranges()
  7391.     create_drops()
  7392.   end
  7393.  
  7394.   #--------------------------------------------------------------------------#
  7395.   # * new-method :get_character
  7396.   #--------------------------------------------------------------------------#
  7397.   def get_character( ev )
  7398.     @character_sprites.each { |s| return s if s.character == ev }
  7399.   end  
  7400.  
  7401.   #--------------------------------------------------------------------------#
  7402.   # * new-method :disposed?
  7403.   #--------------------------------------------------------------------------#
  7404.   def disposed?() ; return @disposed ; end
  7405.    
  7406.   #--------------------------------------------------------------------------#
  7407.   # * alias-method :dispose
  7408.   #--------------------------------------------------------------------------#
  7409.   alias :ygg_anim_ssm_dispose :dispose unless $@
  7410.   def dispose( *args, &block )
  7411.     ygg_anim_ssm_dispose( *args, &block )
  7412.     @projectile_sprites.each { |spr| ; spr.dispose() } unless @projectile_sprites.nil?()
  7413.     @ygg_anims.each { |anim| ; anim.dispose()        } unless @ygg_anims.nil?()
  7414.     @range_sprites.each { |rng| ; rng.dispose()      } unless @range_sprites.nil?()
  7415.     @drop_sprites.each { |dr| ; dr.dispose()         } unless @drop_sprites.nil?()
  7416.     @projectile_sprites = nil ; @ygg_anims          = nil
  7417.     @range_sprites      = nil ; @drop_sprites       = nil
  7418.     @disposed = true
  7419.   end
  7420.  
  7421.   #--------------------------------------------------------------------------#
  7422.   # * new-method :create_drops
  7423.   #--------------------------------------------------------------------------#
  7424.   def create_drops()
  7425.     drops = $game_map.active_drops
  7426.     @drop_sprites = drops.inject([]) { |result, char|
  7427.       spr = YGG::Sprites::CharacterIcon.new( @viewport1, char )
  7428.       spr.self_timeout = char.icon_time_out
  7429.       result.push( spr )
  7430.     }
  7431.   end  
  7432.  
  7433.   #--------------------------------------------------------------------------#
  7434.   # * new-method :create_ranges
  7435.   #--------------------------------------------------------------------------#
  7436.   def create_ranges()
  7437.     @range_sprites = $game_map.active_ranges.inject([]) { |result, range|
  7438.       result.push( YGG::Sprites::Pos.new( range, @viewport1 ) )
  7439.     }
  7440.   end  
  7441.  
  7442.   #--------------------------------------------------------------------------#
  7443.   # * new-method :create_projectiles
  7444.   #--------------------------------------------------------------------------#
  7445.   def create_projectiles()
  7446.     @projectile_sprites = []
  7447.     $game_yggdrasil.new_projectiles.clear()
  7448.     $game_yggdrasil.projectiles.each { |pro| add_projectile_sprite( pro ) }
  7449.   end
  7450.  
  7451.   #--------------------------------------------------------------------------#
  7452.   # * new-method :create_anims
  7453.   #--------------------------------------------------------------------------#
  7454.   def create_anims()
  7455.     @ygg_anims = []
  7456.     for i in 0...YGG::TOTAL_WILD_ANIMS
  7457.       anim = ::YGG::Sprites::Animation.new( @anim_viewport )
  7458.       @ygg_anims.push( anim )
  7459.     end
  7460.   end
  7461.  
  7462.   #--------------------------------------------------------------------------#
  7463.   # * new-method :push_anim
  7464.   #--------------------------------------------------------------------------#
  7465.   def push_anim( anim_id, x, y, targets=[], looped=false )
  7466.     return if @disposed
  7467.     for anim in @ygg_anims#.compact()
  7468.       unless anim.animation?
  7469.         anim.setup_pos( x, y, looped )  
  7470.         anim.play_anim( anim_id,
  7471.           targets.inject([]) { |r, e| r << get_character( e ) } )  
  7472.         return anim
  7473.       end  
  7474.     end
  7475.   end
  7476.  
  7477.   #--------------------------------------------------------------------------#
  7478.   # * new-method :add_projectile_sprite
  7479.   #--------------------------------------------------------------------------#
  7480.   def add_projectile_sprite( projectile )
  7481.     return if @disposed
  7482.     return nil if projectile.nil?()
  7483.     spr = ::YGG::Sprites::Projectile.new( @viewport1, projectile )
  7484.     @projectile_sprites.push( spr )
  7485.     return spr
  7486.   end
  7487.  
  7488.   #--------------------------------------------------------------------------#
  7489.   # * new-method :range
  7490.   #--------------------------------------------------------------------------#
  7491.   def add_range_sprite( range )
  7492.     return if @disposed
  7493.     return nil if range.nil?()
  7494.     sprite = ::YGG::Sprites::Pos.new( range, @viewport1 )
  7495.     @range_sprites.push( sprite )
  7496.     return spr
  7497.   end  
  7498.  
  7499.   #--------------------------------------------------------------------------#
  7500.   # * new-method :add_drop_sprite
  7501.   #--------------------------------------------------------------------------#
  7502.   def add_drop_sprite( char )
  7503.     return if @disposed
  7504.     return nil if char.nil?()
  7505.     spr = YGG::Sprites::CharacterIcon.new( @viewport1, char )
  7506.     spr.self_timeout = char.icon_time_out
  7507.     @drop_sprites.push( spr )
  7508.     return spr
  7509.   end
  7510.  
  7511.   #--------------------------------------------------------------------------#
  7512.   # * alias-method :create_viewports
  7513.   #--------------------------------------------------------------------------#
  7514.   alias :ygg_anim_ssm_create_viewports :create_viewports unless $@
  7515.   def create_viewports( *args, &block )
  7516.     ygg_anim_ssm_create_viewports( *args, &block )
  7517.     @anim_viewport = Viewport.new( 0, 0, Graphics.width, Graphics.height )
  7518.     @anim_viewport.z = 100
  7519.   end
  7520.  
  7521.   #--------------------------------------------------------------------------#
  7522.   # * alias-method :update
  7523.   #--------------------------------------------------------------------------#
  7524.   alias :ygg_anim_ssm_update :update unless $@
  7525.   def update( *args, &block )
  7526.     return if @disposed
  7527.     ygg_anim_ssm_update( *args, &block )  
  7528.     update_anims()       unless @ygg_anims.nil?()
  7529.     update_projectiles() unless @projectile_sprites.nil?()  
  7530.     update_ranges()      unless @range_sprites.nil?()
  7531.     update_drops()       unless @drop_sprites.nil?()
  7532.   end
  7533.  
  7534.   #--------------------------------------------------------------------------#
  7535.   # * new-method :update_anims
  7536.   #--------------------------------------------------------------------------#
  7537.   def update_anims()
  7538.     @ygg_anims.each { |anim| anim.update() if anim.animation?() }
  7539.   end
  7540.  
  7541.   #--------------------------------------------------------------------------#
  7542.   # * new-method :update_projectiles
  7543.   #--------------------------------------------------------------------------#
  7544.   def update_projectiles()
  7545.     unless $game_yggdrasil.new_projectiles.empty?()
  7546.       $game_yggdrasil.new_projectiles.each { |pro| add_projectile_sprite( pro ) }
  7547.       $game_yggdrasil.new_projectiles.clear()
  7548.     end  
  7549.     @projectile_sprites = @projectile_sprites.inject([]) { |result, spr|
  7550.       spr.update() ; spr.dispose() if spr.character.terminated?()
  7551.       result << spr unless spr.disposed?() ; result
  7552.     } unless @projectile_sprites.empty?()
  7553.   end
  7554.  
  7555.   #--------------------------------------------------------------------------#
  7556.   # * new-method :update_ranges
  7557.   #--------------------------------------------------------------------------#
  7558.   def update_ranges()
  7559.     @range_sprites = @range_sprites.inject([]) { |result, rng|
  7560.       ran.update()
  7561.       if ran.completed()
  7562.         $game_map.active_ranges.delete( ran.pos_data ) ; ran.dispose()
  7563.       else ; ran.update() ; end  
  7564.       result << rng unless ran.disposed?() ; result
  7565.     } unless @range_sprites.empty?()
  7566.   end
  7567.  
  7568.   #--------------------------------------------------------------------------#
  7569.   # * new-method :update_drops
  7570.   #--------------------------------------------------------------------------#
  7571.   def update_drops()
  7572.     @drop_sprites = @drop_sprites.inject([]) { |result, dr|
  7573.       dr.ready_to_remove?() ? dr.dispose() : dr.update()
  7574.       result << dr unless dr.disposed?() ; result
  7575.     } unless @drop_sprites.empty?()
  7576.   end
  7577.  
  7578.   #--------------------------------------------------------------------------#
  7579.   # * alias-method :update_viewports
  7580.   #--------------------------------------------------------------------------#
  7581.   alias :ygg_anim_ssm_update_viewports :update_viewports unless $@
  7582.   def update_viewports( *args, &block )
  7583.     ygg_anim_ssm_update_viewports( *args, &block )
  7584.     @anim_viewport.update() unless @anim_viewport.nil?()
  7585.   end
  7586.  
  7587.   #--------------------------------------------------------------------------#
  7588.   # * alias-method :dispose_viewports
  7589.   #--------------------------------------------------------------------------#
  7590.   alias :ygg_anim_ssm_dispose_viewports :dispose_viewports unless $@
  7591.   def dispose_viewports( *args, &block )
  7592.     ygg_anim_ssm_dispose_viewports( *args, &block )
  7593.     @anim_viewport.dispose() unless @anim_viewport.nil?() ; @anim_viewport = nil
  7594.   end
  7595.  
  7596. end
  7597.  
  7598. # // (YGG_SC) - System Code
  7599. #==============================================================================#
  7600. # // Start Yggdrasil Main Code
  7601. #==============================================================================#
  7602. # ** Game System
  7603. #==============================================================================#
  7604. class Game_System
  7605.  
  7606.   #--------------------------------------------------------------------------#
  7607.   # * Public Instance Variable(s)
  7608.   #--------------------------------------------------------------------------#
  7609.   attr_accessor :ygg_hit_count
  7610.   attr_accessor :ygg_hit_down_wait
  7611.  
  7612.   attr_accessor :draw_damage_ranges
  7613.   attr_accessor :gameover_alldead
  7614.  
  7615.   #--------------------------------------------------------------------------#
  7616.   # * alias-method :initialize
  7617.   #--------------------------------------------------------------------------#
  7618.   alias :ygg_gs_initialize :initialize unless $@
  7619.   def initialize( *args, &block )
  7620.     ygg_gs_initialize( *args, &block )
  7621.     @ygg_hit_count      = 0
  7622.     @ygg_hit_down_wait  = 0
  7623.     @draw_damage_ranges = YGG::DRAW_RANGES
  7624.     @gameover_alldead   = YGG::ALL_DEAD_GAMEOVER
  7625.   end
  7626.  
  7627.   #--------------------------------------------------------------------------#
  7628.   # * new-method :gameover_alldead?
  7629.   #--------------------------------------------------------------------------#
  7630.   def gameover_alldead?() ; return @gameover_alldead end
  7631.    
  7632.   #--------------------------------------------------------------------------#
  7633.   # * alias-method :update
  7634.   #--------------------------------------------------------------------------#
  7635.   alias :ygg_gs_update :update unless $@
  7636.   def update( *args, &block )
  7637.     ygg_gs_update( *args, &block )
  7638.     unless $game_message.visible
  7639.       @ygg_hit_down_wait -= 1 unless @ygg_hit_down_wait == 0
  7640.       @ygg_hit_count = 0 if @ygg_hit_down_wait == 0
  7641.     end if $scene.is_a?( Scene_Map )
  7642.   end
  7643.  
  7644.   #--------------------------------------------------------------------------#
  7645.   # * mew-method :control_self_switch
  7646.   #--------------------------------------------------------------------------#
  7647.   def control_self_switch( map_id, event_id, switch, value )
  7648.     $game_self_switches[[map_id, event_id, switch]] = value
  7649.     $game_map.need_refresh = true
  7650.   end
  7651.  
  7652.   #--------------------------------------------------------------------------#
  7653.   # * new-method :yggdrasil_on?
  7654.   #--------------------------------------------------------------------------#
  7655.   def yggdrasil_on?() ; return $game_yggdrasil.on?() ; end
  7656.    
  7657. end
  7658.  
  7659. #==============================================================================#
  7660. # ** Game Battler
  7661. #==============================================================================#
  7662. class Game_Battler
  7663.  
  7664.   #--------------------------------------------------------------------------#
  7665.   # * Public Instance Variable(s)
  7666.   #--------------------------------------------------------------------------#
  7667.   attr_accessor :character_need_refresh
  7668.   attr_accessor :ygg_slip_counter
  7669.  
  7670.   attr_accessor :ygg_engage
  7671.  
  7672.   attr_accessor :skill_slot_size, :item_slot_size
  7673.  
  7674.   attr_accessor :ygg_guard
  7675.  
  7676.   #--------------------------------------------------------------------------#
  7677.   # * alias-method :initialize
  7678.   #--------------------------------------------------------------------------#
  7679.   alias :ygg_gb_initialize :initialize unless $@
  7680.   def initialize( *args, &block )
  7681.     ygg_gb_initialize( *args, &block )
  7682.     @state_ticks      = {}
  7683.     @ygg_slip_counter = 0
  7684.     @ygg_engage       = ::YGG::Handlers::Engage.new( self )
  7685.     @skill_slot_size, @item_slot_size =  5, 5
  7686.     @skill_slots    , @item_slots     = [], []
  7687.     @skill_handles  , @item_handles   = {}, {}
  7688.     @ygg_guard = false
  7689.     @cooldown, @cooldown_max, = 0, 300
  7690.     clear_stat_cache()
  7691.     clear_item_slots()
  7692.     clear_skill_slots()
  7693.   end
  7694.  
  7695.   #--------------------------------------------------------------------------#
  7696.   # * overwrite-method :skill_can_use?
  7697.   #--------------------------------------------------------------------------#
  7698.   def skill_can_use?( skill )
  7699.     return false unless skill.is_a?( RPG::Skill )
  7700.     return false unless movable?()
  7701.     return false if silent?() and skill.spi_f > 0
  7702.     return false if calc_mp_cost( skill ) > mp
  7703.     if $game_temp.in_battle  
  7704.       return skill.battle_ok?()
  7705.     elsif $game_system.yggdrasil_on?() and $scene.is_a?( Scene_Map )
  7706.       return skill.battle_ok?()
  7707.     else
  7708.       return skill.menu_ok?()
  7709.     end
  7710.   end
  7711.  
  7712.   #--------------------------------------------------------------------------#
  7713.   # * new-method :guarding?
  7714.   #--------------------------------------------------------------------------#
  7715.   def guarding?()
  7716.     return @action.guard?() || @ygg_guard
  7717.   end
  7718.  
  7719.   #--------------------------------------------------------------------------#
  7720.   # * new-method :get_action_by_id
  7721.   #--------------------------------------------------------------------------#
  7722.   def get_action_by_id( id )
  7723.     return []
  7724.   end
  7725.  
  7726.   #--------------------------------------------------------------------------#
  7727.   # ** new-method :ygg_range
  7728.   #--------------------------------------------------------------------------#
  7729.   def ygg_range ; return 0 end
  7730.  
  7731.   #--------------------------------------------------------------------------#
  7732.   # ** new-method :drops_attraction?
  7733.   #--------------------------------------------------------------------------#
  7734.   def drops_attraction? ; return false end
  7735.    
  7736.   #--------------------------------------------------------------------------#
  7737.   # ** new-method :equip_icon
  7738.   #--------------------------------------------------------------------------#
  7739.   def equip_icon( eq_id ) ; return 0 ; end
  7740.    
  7741.   #--------------------------------------------------------------------------#
  7742.   # * new-method :equip_atk_act_name
  7743.   #--------------------------------------------------------------------------#    
  7744.   def equip_atk_act_name( eq_id ) ; return "" ; end
  7745.  
  7746.   #--------------------------------------------------------------------------#
  7747.   # * new-method :equip_grd_act_name
  7748.   #--------------------------------------------------------------------------#    
  7749.   def equip_grd_act_name( eq_id ) ; return "" ; end
  7750.  
  7751.   #--------------------------------------------------------------------------#
  7752.   # * alias-method :maxhp/maxmp/atk/def/spi/agi
  7753.   #--------------------------------------------------------------------------#    
  7754.   [:maxhp, :maxmp, :atk, :def, :spi, :agi].each { |m|  
  7755.     module_eval( %Q(
  7756.     alias :ygg_gb_#{m.to_s} #{m} unless $@
  7757.     def #{m.to_s}( *args, &block )
  7758.       @cached_#{m.to_s} ||= ygg_gb_#{m.to_s}( *args, &block )
  7759.       return @cached_#{m.to_s}  
  7760.     end  
  7761.    
  7762.     alias :ygg_gb_#{m.to_s}_set #{m}= unless $@
  7763.     def #{m.to_s}=( new_value )
  7764.       @cached_#{m.to_s} = nil if new_value != @cached_#{m.to_s}
  7765.       ygg_gb_#{m.to_s}_set( new_value )
  7766.     end
  7767.     ) )
  7768.   }  
  7769.  
  7770.   #--------------------------------------------------------------------------#
  7771.   # * new-method :clear_stat_cache
  7772.   #--------------------------------------------------------------------------#  
  7773.   def clear_stat_cache()
  7774.     @cached_maxhp = nil
  7775.     @cached_maxmp = nil
  7776.     @cached_atk   = nil
  7777.     @cached_def   = nil
  7778.     @cached_spi   = nil
  7779.     @cached_agi   = nil
  7780.    
  7781.     @cached_move  = nil
  7782.     @cached_tone  = nil
  7783.     @cached_slip  = nil
  7784.     @cached_slip_freq = nil
  7785.    
  7786.     @cached_level_exp = nil
  7787.     @cached_next_level_exp = nil
  7788.    
  7789.     @character_need_refresh = true
  7790.   end
  7791.  
  7792.   #--------------------------------------------------------------------------#
  7793.   # * alias-method :recover_all
  7794.   #--------------------------------------------------------------------------#
  7795.   alias :ygg_gb_recover_all :recover_all unless $@
  7796.   def recover_all( *args, &block )
  7797.     clear_stat_cache()
  7798.     ygg_gb_recover_all( *args, &block )
  7799.   end
  7800.  
  7801. if ::YGG::FULL_INTEGRATION  
  7802.  
  7803.   #--------------------------------------------------------------------------#
  7804.   # * alias-method :add_state
  7805.   #--------------------------------------------------------------------------#  
  7806.   alias :ygg_gb_fi_add_state :add_state unless $@
  7807.   def add_state( state_id )
  7808.     sti = state_ignore?( state_id )
  7809.     ygg_gb_fi_add_state( state_id )
  7810.     state = $data_states[state_id]        
  7811.     return if state.nil?() ; return if sti
  7812.     @state_ticks[state_id] = state.hold_ticks unless state.id == 1
  7813.   end
  7814.  
  7815.   #--------------------------------------------------------------------------#
  7816.   # * alias-method :remove_state
  7817.   #--------------------------------------------------------------------------#  
  7818.   alias :ygg_gb_fi_remove_state :remove_state unless $@
  7819.   def remove_state( state_id )
  7820.     ygg_gb_fi_remove_state( state_id )
  7821.     @state_ticks.delete( state_id )
  7822.   end
  7823.  
  7824.   #--------------------------------------------------------------------------#
  7825.   # * alias-method :update_state_ticks
  7826.   #--------------------------------------------------------------------------#
  7827.   def update_state_ticks()
  7828.     @state_ticks.keys.clone.each { |key|
  7829.       state = $data_states[key]
  7830.       if state.nil?() ; @state_ticks.delete(key) ; next ; end
  7831.       @state_ticks[key] -= 1
  7832.       remove_state( key ) if @state_ticks[key] < 0 && rand(100) < state.auto_release_prob
  7833.     }
  7834.   end  
  7835.  
  7836.   #--------------------------------------------------------------------------#
  7837.   # * overwrite-method :slip_damage?
  7838.   #--------------------------------------------------------------------------#  
  7839.   def slip_damage?()
  7840.     @cached_slip ||= self.states.any?() { |s| s.slip_damage }
  7841.     return @cached_slip
  7842.   end
  7843.  
  7844.   #--------------------------------------------------------------------------#
  7845.   # * overwrite-method :slip_damage_effect
  7846.   #--------------------------------------------------------------------------#  
  7847.   def slip_damage_effect()
  7848.     self.hp -= 1 if slip_damage? and @hp > 0
  7849.   end
  7850.  
  7851. end # // Full Integration
  7852.  
  7853.   #--------------------------------------------------------------------------#
  7854.   # * overwrite-method :item_growth_effect
  7855.   #--------------------------------------------------------------------------#
  7856.   def item_growth_effect( user, item )
  7857.     if item.parameter_type > 0 and item.parameter_points != 0
  7858.       case item.parameter_type
  7859.       when 1  # Maximum HP
  7860.         @maxhp_plus += item.parameter_points
  7861.         @cached_maxhp = nil
  7862.       when 2  # Maximum MP
  7863.         @maxmp_plus += item.parameter_points
  7864.         @cached_maxmp = nil
  7865.       when 3  # Attack
  7866.         @atk_plus += item.parameter_points
  7867.         @cached_atk = nil
  7868.       when 4  # Defense
  7869.         @def_plus += item.parameter_points
  7870.         @cached_def = nil
  7871.       when 5  # Spirit
  7872.         @spi_plus += item.parameter_points
  7873.         @cached_spi = nil
  7874.       when 6  # Agility
  7875.         @agi_plus += item.parameter_points
  7876.         @cached_agi = nil
  7877.       end
  7878.     end
  7879.   end
  7880.  
  7881.   #--------------------------------------------------------------------------#
  7882.   # * alias-method :add_state
  7883.   #--------------------------------------------------------------------------#  
  7884.   alias :ygg_gb_add_state :add_state unless $@
  7885.   def add_state( *args, &block )
  7886.     old_states = self.states
  7887.     ygg_gb_add_state( *args, &block )
  7888.     clear_stat_cache() unless self.states == old_states
  7889.   end
  7890.  
  7891.   #--------------------------------------------------------------------------#
  7892.   # * alias-method :remove_state
  7893.   #--------------------------------------------------------------------------#  
  7894.   alias :ygg_gb_remove_state :remove_state unless $@
  7895.   def remove_state( *args, &block )
  7896.     old_states = self.states
  7897.     ygg_gb_remove_state( *args, &block )
  7898.     clear_stat_cache() unless self.states == old_states
  7899.   end
  7900.  
  7901.   #--------------------------------------------------------------------------#
  7902.   # * new-method :move_mod
  7903.   #--------------------------------------------------------------------------#  
  7904.   def move_mod()
  7905.     @cached_move ||= self.states.inject(0) { |r, s| r+s.move_mod }
  7906.     return @cached_move
  7907.   end
  7908.  
  7909.   #--------------------------------------------------------------------------#
  7910.   # * new-method :effect_tone
  7911.   #--------------------------------------------------------------------------#  
  7912.   def effect_tone()
  7913.     if @cached_tone.nil?()
  7914.       @cached_tone = ::Tone.new( 0, 0, 0, 0 )
  7915.       self.states.each { |s|
  7916.         if s.tone_effect ; @cached_tone = s.effect_tone ; break ; end }  
  7917.     end  
  7918.     return @cached_tone
  7919.   end
  7920.  
  7921.   #--------------------------------------------------------------------------#
  7922.   # * new-method :slip_frequency
  7923.   #--------------------------------------------------------------------------#  
  7924.   def slip_frequency()
  7925.     if @cached_slip_freq.nil?()
  7926.       r = 1 ; count = 1
  7927.       self.states.each { |s|
  7928.         if s.slip_freq != 0
  7929.           count += 1 ; r += s.slip_freq
  7930.         end  
  7931.       }  
  7932.       @cached_slip_freq = r / count
  7933.     end  
  7934.     return @cached_slip_freq
  7935.   end
  7936.  
  7937.   #--------------------------------------------------------------------------#
  7938.   # * new-method :update_states
  7939.   #--------------------------------------------------------------------------#  
  7940. if ::YGG::FULL_INTEGRATION
  7941.  
  7942.   def update_states()
  7943.     update_state_ticks()
  7944.     update_slip_damage()  if (Graphics.frame_count % slip_frequency) == 0
  7945.   end
  7946.  
  7947. else  
  7948.  
  7949.   def update_states()
  7950.     @ygg_slip_counter = [@ygg_slip_counter-1, 0].max
  7951.     if @ygg_slip_counter == 0
  7952.       remove_states_auto() ; update_slip_damage()
  7953.       @ygg_slip_counter = YGG::STATE_TURN_COUNTER        
  7954.     end
  7955.   end
  7956.  
  7957. end
  7958.  
  7959.   #--------------------------------------------------------------------------#
  7960.   # * new-method :update_slip_damage
  7961.   #--------------------------------------------------------------------------#
  7962.   def update_slip_damage()
  7963.     if slip_damage?()
  7964.       slip_damage_effect() ; self.ygg_engage.engage( 30 )
  7965.     end  
  7966.   end
  7967.  
  7968.   #--------------------------------------------------------------------------#
  7969.   # * new-method :skill_slot_valid?
  7970.   #--------------------------------------------------------------------------#
  7971.   def skill_slot_valid?( i )
  7972.     return i.between?( 0, @skill_slot_size-1 )
  7973.   end
  7974.  
  7975.   #--------------------------------------------------------------------------#
  7976.   # * new-method :item_slot_valid?
  7977.   #--------------------------------------------------------------------------#
  7978.   def item_slot_valid?( i )
  7979.     return i.between?( 0, @item_slot_size-1 )
  7980.   end
  7981.  
  7982.   #--------------------------------------------------------------------------#
  7983.   # * new-method :skill_slot
  7984.   #--------------------------------------------------------------------------#
  7985.   def skill_slot( i )
  7986.     return nil unless skill_slot_valid?( i )
  7987.     return $data_skills[(@skill_slots[i].obj_id)]
  7988.   end
  7989.  
  7990.   #--------------------------------------------------------------------------#
  7991.   # * new-method :skill_slots
  7992.   #--------------------------------------------------------------------------#
  7993.   def skill_slot_skills()
  7994.     result = []
  7995.     @skill_slot_size.times { |i| result << skill_slot( i ) } ; return result
  7996.   end
  7997.  
  7998.   #--------------------------------------------------------------------------#
  7999.   # * new-method :item_slot
  8000.   #--------------------------------------------------------------------------#
  8001.   def item_slot( i )
  8002.     return nil unless item_slot_valid?( i )
  8003.     return $data_items[(@item_slots[i].obj_id)]
  8004.   end
  8005.  
  8006.   #--------------------------------------------------------------------------#
  8007.   # * new-method :item_slot_items
  8008.   #--------------------------------------------------------------------------#
  8009.   def item_slot_items()
  8010.     result = []
  8011.     @item_slot_size.times { |i| result << item_slot( i ) } ; return result
  8012.   end
  8013.  
  8014.   #--------------------------------------------------------------------------#
  8015.   # * new-method :set_skill_slot
  8016.   #--------------------------------------------------------------------------#
  8017.   def set_skill_slot( i, sid )
  8018.     return unless skill_slot_valid?( i )
  8019.     @skill_slots[i] = get_skill_handle( sid )
  8020.   end
  8021.  
  8022.   #--------------------------------------------------------------------------#
  8023.   # * new-method :set_item_slot
  8024.   #--------------------------------------------------------------------------#
  8025.   def set_item_slot( i, iid )
  8026.     return unless item_slot_valid?( i )
  8027.     @item_slots[i] = get_item_handle( iid )
  8028.   end
  8029.  
  8030.   #--------------------------------------------------------------------------#
  8031.   # * new-method :clear_skill_slots
  8032.   #--------------------------------------------------------------------------#  
  8033.   def clear_skill_slots()
  8034.     @skill_slot_size.times { |i| set_skill_slot( i, 0 ) }
  8035.   end
  8036.  
  8037.   #--------------------------------------------------------------------------#
  8038.   # * new-method :clear_item_slots
  8039.   #--------------------------------------------------------------------------#  
  8040.   def clear_item_slots()  
  8041.     @item_slot_size.times { |i| set_item_slot( i, 0 ) }
  8042.   end
  8043.  
  8044.   #--------------------------------------------------------------------------#
  8045.   # * new-method :get_skill_handle
  8046.   #--------------------------------------------------------------------------#
  8047.   def get_skill_handle( sid )  
  8048.     @skill_handles[sid] ||= ::YGG::Handlers::BattleObj.new( sid, :skill )
  8049.     return @skill_handles[sid]
  8050.   end  
  8051.  
  8052.   #--------------------------------------------------------------------------#
  8053.   # * new-method :get_item_handle
  8054.   #--------------------------------------------------------------------------#
  8055.   def get_item_handle( iid )  
  8056.     @item_handles[iid] ||= ::YGG::Handlers::BattleObj.new( iid, :item )
  8057.     return @item_handles[iid]
  8058.   end  
  8059.  
  8060.   #--------------------------------------------------------------------------#
  8061.   # * new-method :update_obj_handles
  8062.   #--------------------------------------------------------------------------#
  8063.   def update_obj_handles()
  8064.     (@skill_slots+@item_slots).each { |hnd| hnd.update() }
  8065.   end
  8066.  
  8067.   #--------------------------------------------------------------------------#
  8068.   # * new-method :cooldown
  8069.   #--------------------------------------------------------------------------#
  8070.   attr_reader :cooldown
  8071.  
  8072.   #--------------------------------------------------------------------------#
  8073.   # * new-method :cooldown=
  8074.   #--------------------------------------------------------------------------#
  8075.   def cooldown=( cool )
  8076.     @cooldown = [cool, @cooldown_max].min
  8077.   end
  8078.  
  8079.   #--------------------------------------------------------------------------#
  8080.   # * new-method :cooldown_max
  8081.   #--------------------------------------------------------------------------#
  8082.   def cooldown_max() ; @cooldown_max ; end
  8083.  
  8084.   #--------------------------------------------------------------------------#
  8085.   # * new-method :cap_cooldown
  8086.   #--------------------------------------------------------------------------#
  8087.   def cap_cooldown()
  8088.     @cooldown = @cooldown_max
  8089.   end
  8090.  
  8091.   #--------------------------------------------------------------------------#
  8092.   # * new-method :update_cooldown
  8093.   #--------------------------------------------------------------------------#
  8094.   def update_cooldown()
  8095.     @cooldown = [@cooldown - 1, 0].max
  8096.   end
  8097.  
  8098.   #--------------------------------------------------------------------------#
  8099.   # * new-method :cooling_down?
  8100.   #--------------------------------------------------------------------------#
  8101.   def cooling_down?() ; return @cooldown > 0 ; end
  8102.  
  8103.   #--------------------------------------------------------------------------#
  8104.   # * new-method :ygg_can_attack?
  8105.   #--------------------------------------------------------------------------#
  8106.   def ygg_can_attack?() ;
  8107.     return false if cooling_down?()
  8108.     return true
  8109.   end
  8110.  
  8111.   #--------------------------------------------------------------------------#
  8112.   # * new-method :ygg_skill_can_use?
  8113.   #--------------------------------------------------------------------------#
  8114.   def ygg_skill_can_use?( obj )
  8115.     return false if cooling_down?()
  8116.     return false unless skill_can_use?( obj )
  8117.     return get_skill_handle( obj.id ).can_use?()
  8118.   end
  8119.  
  8120.   #--------------------------------------------------------------------------#
  8121.   # * new-method :ygg_item_can_use?
  8122.   #--------------------------------------------------------------------------#
  8123.   def ygg_item_can_use?( obj )
  8124.     return false if cooling_down?()
  8125.     return false unless item_can_use?( obj )
  8126.     return get_item_handle( obj.id ).can_use?()
  8127.   end
  8128.  
  8129.   #--------------------------------------------------------------------------#
  8130.   # * new-method :item_can_use?
  8131.   #--------------------------------------------------------------------------#
  8132.   def item_can_use?( obj )
  8133.     return $game_party.item_can_use?( obj )
  8134.   end unless method_defined? :item_can_use?
  8135.  
  8136.   #--------------------------------------------------------------------------#
  8137.   # * new-method :ygg_use_skill
  8138.   #--------------------------------------------------------------------------#
  8139.   def ygg_use_skill( obj )
  8140.     self.mp -= calc_mp_cost( obj )
  8141.   end
  8142.  
  8143.   #--------------------------------------------------------------------------#
  8144.   # * new-method :ygg_use_item
  8145.   #--------------------------------------------------------------------------#
  8146.   def ygg_use_item( obj )
  8147.     $game_party.consume_item( obj )
  8148.   end
  8149.  
  8150. end
  8151.  
  8152. #==============================================================================#
  8153. # ** Game Actor
  8154. #==============================================================================#
  8155. class Game_Actor < Game_Battler
  8156.  
  8157.   #--------------------------------------------------------------------------#
  8158.   # * alias-method :level_up
  8159.   #--------------------------------------------------------------------------#  
  8160.   alias :ygg_gb_level_up :level_up unless $@
  8161.   def level_up( *args, &block )
  8162.     clear_stat_cache()
  8163.     ygg_gb_level_up( *args, &block )
  8164.     clear_stat_cache()
  8165.   end
  8166.  
  8167.   #--------------------------------------------------------------------------#
  8168.   # * alias-method :level_down
  8169.   #--------------------------------------------------------------------------#  
  8170.   alias :ygg_gb_level_down :level_down unless $@
  8171.   def level_down( *args, &block )
  8172.     clear_stat_cache()
  8173.     ygg_gb_level_down( *args, &block )
  8174.     clear_stat_cache()
  8175.   end
  8176.  
  8177.   #--------------------------------------------------------------------------#
  8178.   # * alias-method :change_equip
  8179.   #--------------------------------------------------------------------------#  
  8180.   alias :ygg_gb_change_equip :change_equip unless $@
  8181.   def change_equip( *args, &block )
  8182.     clear_stat_cache()
  8183.     ygg_gb_change_equip( *args, &block )
  8184.     clear_stat_cache()
  8185.   end
  8186.  
  8187.   #--------------------------------------------------------------------------#
  8188.   # * ygg_target_range
  8189.   #--------------------------------------------------------------------------#
  8190.   def ygg_target_range()
  8191.     eq = weapons[0]
  8192.     eq.nil?() ? 0 : eq.ygg_target_range
  8193.   end  
  8194.    
  8195.   #--------------------------------------------------------------------------#
  8196.   # * new-method :drops_attraction?
  8197.   #--------------------------------------------------------------------------#
  8198.   def drops_attraction?() ; equips.compact.any? { |eq| eq.drops_attraction?() } ; end
  8199.    
  8200.   #--------------------------------------------------------------------------#
  8201.   # * new-method :equip_icon
  8202.   #--------------------------------------------------------------------------#
  8203.   def equip_icon( eq_id )
  8204.     if self.two_swords_style
  8205.       weps = weapons
  8206.       return weps[eq_id].nil?() ? 0 : weps[eq_id].icon_index
  8207.     else
  8208.       weps = [weapons[0], armors[0]]
  8209.       return weps[eq_id].nil?() ? 0 : weps[eq_id].icon_index
  8210.     end  
  8211.   end
  8212.  
  8213.   #--------------------------------------------------------------------------#
  8214.   # * new-method :equip_atk_act_name
  8215.   #--------------------------------------------------------------------------#    
  8216.   def equip_atk_act_name( eq_id )
  8217.     if self.two_swords_style
  8218.       weps = weapons
  8219.     else
  8220.       weps = [weapons[0], armors[0]]
  8221.     end
  8222.     return weps[eq_id].nil?() ? "" : weps[eq_id].atk_act_name
  8223.   end
  8224.  
  8225.   #--------------------------------------------------------------------------#
  8226.   # * new-method :equip_grd_act_name
  8227.   #--------------------------------------------------------------------------#    
  8228.   def equip_grd_act_name( eq_id )
  8229.     if self.two_swords_style
  8230.       weps = weapons
  8231.     else
  8232.       weps = [weapons[0], armors[0]]
  8233.     end
  8234.     return weps[eq_id].nil?() ? "" : weps[eq_id].grd_act_name
  8235.   end
  8236.  
  8237.   #--------------------------------------------------------------------------#
  8238.   # * alias-method :change_exp
  8239.   #--------------------------------------------------------------------------#    
  8240.   alias :ygg_gb_change_exp :change_exp unless $@
  8241.   def change_exp( *args, &block )
  8242.     ygg_gb_change_exp( *args, &block )
  8243.     @cached_level_exp = nil
  8244.     @cached_next_level_exp = nil
  8245.   end
  8246.  
  8247.   #--------------------------------------------------------------------------#
  8248.   # * new-method :level_exp
  8249.   #--------------------------------------------------------------------------#    
  8250.   def level_exp()
  8251.     @cached_level_exp ||= @exp - @exp_list[@level]
  8252.     return @cached_level_exp
  8253.   end
  8254.  
  8255.   #--------------------------------------------------------------------------#
  8256.   # * new-method :next_level_exp
  8257.   #--------------------------------------------------------------------------#  
  8258.   def next_level_exp()
  8259.     @cached_next_level_exp ||= @exp_list[@level+1] - @exp_list[@level]
  8260.     return @cached_next_level_exp
  8261.   end
  8262.  
  8263. end
  8264.  
  8265. #==============================================================================#
  8266. # ** Game Enemy
  8267. #==============================================================================#
  8268. class Game_Enemy < Game_Battler
  8269.  
  8270.   #--------------------------------------------------------------------------#
  8271.   # * alias-method :initialize
  8272.   #--------------------------------------------------------------------------#
  8273.   alias :ygg_gmen_initialize :initialize unless $@
  8274.   def initialize( *args, &block )
  8275.     ygg_gmen_initialize( *args, &block )
  8276.     @skill_slot_size = 0
  8277.     skillz = []
  8278.     enemy.actions.each { |act| if act.kind == 1 ; skillz << act.skill_id ; end }
  8279.     @skill_slot_size = skillz.size
  8280.     for i in 0...@skill_slot_size ; set_skill_slot( i, skillz[i] ) ; end
  8281.   end
  8282.  
  8283.   #--------------------------------------------------------------------------#
  8284.   # * overwrite-method :use_equipment
  8285.   #--------------------------------------------------------------------------#
  8286.   def use_equipment() ; return enemy.use_equipment ; end
  8287.    
  8288.   #--------------------------------------------------------------------------#
  8289.   # * new-method :equip_icon
  8290.   #--------------------------------------------------------------------------#
  8291.   def equip_icon( eq_id )
  8292.     return enemy.equip_icons[eq_id]  
  8293.   end
  8294.  
  8295.   #--------------------------------------------------------------------------#
  8296.   # * new-method :equip_atk_act_name
  8297.   #--------------------------------------------------------------------------#    
  8298.   def equip_atk_act_name( eq_id )
  8299.     return enemy.atk_act_name
  8300.   end
  8301.  
  8302.   #--------------------------------------------------------------------------#
  8303.   # * new-method :equip_grd_act_name
  8304.   #--------------------------------------------------------------------------#    
  8305.   def equip_grd_act_name( eq_id )
  8306.     return enemy.grd_act_name
  8307.   end
  8308.  
  8309.   #--------------------------------------------------------------------------#
  8310.   # * new-method :calc_gold
  8311.   #--------------------------------------------------------------------------#
  8312.   def calc_gold()
  8313.     return Integer( YGG::Random.variation( gold, enemy.gold_variation ) )
  8314.   end
  8315.  
  8316.   #--------------------------------------------------------------------------#
  8317.   # * new-method :gain_exp
  8318.   #--------------------------------------------------------------------------#
  8319.   def gain_exp( exp, show ) ; end unless method_defined? :gain_exp
  8320.    
  8321.   #--------------------------------------------------------------------------#
  8322.   # * new-method :get_action_by_id
  8323.   #--------------------------------------------------------------------------#
  8324.   def get_action_by_id( id )
  8325.     return enemy.ygg_actions[id]
  8326.   end
  8327.  
  8328.   #--------------------------------------------------------------------------#
  8329.   # * new-method :all_drops
  8330.   #--------------------------------------------------------------------------#
  8331.   def all_drops()
  8332.     dro = []
  8333.     for di in self.enemy.drop_items.compact
  8334.       next if di.kind == 0 ; next if rand(di.denominator) != 0
  8335.       case di.kind
  8336.       when 1 ; dro.push($data_items[di.item_id])
  8337.       when 2 ; dro.push($data_weapons[di.weapon_id])
  8338.       when 3 ; dro.push($data_armors[di.armor_id])
  8339.       end
  8340.     end
  8341.     more_drops.compact.each { |mri|
  8342.       for num in 1..mri[2] ; dro.push(mri[0]) if rand(mri[1]).to_i == 0 ; end
  8343.     } if $imported["IEX_Rand_Drop"]
  8344.     return dro
  8345.   end  
  8346.  
  8347.   #--------------------------------------------------------------------------#
  8348.   # * new-method :atk_animation_id
  8349.   #--------------------------------------------------------------------------#
  8350.   def atk_animation_id ; return enemy.atk_animation_id ; end
  8351.  
  8352.   #--------------------------------------------------------------------------#
  8353.   # * new-method :atk_animation_id2
  8354.   #--------------------------------------------------------------------------#
  8355.   def atk_animation_id2 ; return enemy.atk_animation_id2 ; end
  8356.  
  8357. end
  8358.  
  8359. #==============================================================================#
  8360. # ** Game_Party
  8361. #==============================================================================#
  8362. class Game_Party
  8363.  
  8364.   #--------------------------------------------------------------------------#
  8365.   # * alias-method :on_player_walk
  8366.   #--------------------------------------------------------------------------#
  8367.   alias :ygg1x6_gmpt_on_player_walk :on_player_walk unless $@
  8368.   def on_player_walk( *args, &block )
  8369.     unless $game_system.yggdrasil_on?()
  8370.       ygg1x6_gmpt_on_player_walk( *args, &block )
  8371.     end  
  8372.   end
  8373.  
  8374.   #--------------------------------------------------------------------------#
  8375.   # * new-method :ygg_slip_damage
  8376.   #--------------------------------------------------------------------------#
  8377.   def ygg_slip_damage()
  8378.     ($game_party.members-[$game_player.ygg_battler]).each { |m| m.update_states() }
  8379.   end
  8380.  
  8381. end  
  8382.  
  8383. #==============================================================================#
  8384. # ** Game Map
  8385. #==============================================================================#
  8386. class Game_Map
  8387.  
  8388.   #--------------------------------------------------------------------------#
  8389.   # * new-method :get_map
  8390.   #--------------------------------------------------------------------------#  
  8391.   def get_map( map_id )
  8392.     return load_data( sprintf("Data/Map%03d.rvdata", map_id) )
  8393.   end unless method_defined? :get_map
  8394.  
  8395.   #--------------------------------------------------------------------------#
  8396.   # * alias-method :events_xy
  8397.   #--------------------------------------------------------------------------#
  8398.   alias :ygg_gmm_events_xy :events_xy unless $@
  8399.   def events_xy( x, y )
  8400.     return ygg_gmm_events_xy( x, y ) + $game_yggdrasil.roam_xy( x, y )
  8401.   end
  8402.  
  8403.   #--------------------------------------------------------------------------#
  8404.   # * alias-method :setup
  8405.   #--------------------------------------------------------------------------#
  8406.   alias :ygg_gmm_setup :setup unless $@
  8407.   def setup( *args, &block )
  8408.     $game_player.ygg_unregister()
  8409.     ygg_gmm_setup( *args, &block )
  8410.     ygg_setup()
  8411.     $game_player.ygg_register()
  8412.   end
  8413.  
  8414.   #--------------------------------------------------------------------------#
  8415.   # * new-method :ygg_setup
  8416.   #--------------------------------------------------------------------------#
  8417.   def ygg_setup()
  8418.     $game_yggdrasil.setup_map( self.map_id )
  8419.   end
  8420.  
  8421.   #--------------------------------------------------------------------------#
  8422.   # * new-method :setup_itemmap
  8423.   #--------------------------------------------------------------------------#
  8424.   def setup_itemmap()
  8425.     $game_yggdrasil.setup_itemmap()  
  8426.   end
  8427.  
  8428.   #--------------------------------------------------------------------------#
  8429.   # * new-method :create_drops
  8430.   #--------------------------------------------------------------------------#
  8431.   def create_drops( x, y, dropee )
  8432.     $game_yggdrasil.create_drops( x, y, dropee )
  8433.   end  
  8434.  
  8435.   #--------------------------------------------------------------------------#
  8436.   # * new-method :place_drops
  8437.   #--------------------------------------------------------------------------#
  8438.   def place_drops( x, y, item_set, gold = nil )
  8439.     return $game_yggdrasil.place_drops( x, y, item_set, gold )
  8440.   end
  8441.  
  8442.   #--------------------------------------------------------------------------#
  8443.   # * new-method :items_map
  8444.   #--------------------------------------------------------------------------#
  8445.   def items_map() ; return $items_map ; end
  8446.  
  8447.   #--------------------------------------------------------------------------#
  8448.   # * alias-method :update
  8449.   #--------------------------------------------------------------------------#
  8450.   #alias :ygg_gm_update :update unless $@
  8451.   #def update( *args, &block )
  8452.   #  ygg_gm_update( *args, &block )
  8453.   #  update_drops()
  8454.   #end
  8455.  
  8456.   #--------------------------------------------------------------------------#
  8457.   # * new-method :active_drops
  8458.   #--------------------------------------------------------------------------#
  8459.   def active_drops() ; return $game_yggdrasil.active_drops ; end
  8460.    
  8461.   #--------------------------------------------------------------------------#
  8462.   # * new-method :active_ranges
  8463.   #--------------------------------------------------------------------------#  
  8464.   def active_ranges() ; return $game_yggdrasil.active_ranges ; end
  8465.    
  8466.   #--------------------------------------------------------------------------#
  8467.   # * new-method :projectiles
  8468.   #--------------------------------------------------------------------------#  
  8469.   def projectiles() ; return $game_yggdrasil.projectiles ; end
  8470.    
  8471.   #--------------------------------------------------------------------------#
  8472.   # * new-method :drops_xy
  8473.   #--------------------------------------------------------------------------#  
  8474.   def drops_xy( x, y )
  8475.     return $game_yggdrasil.drops_xy( x, y )
  8476.   end
  8477.  
  8478. end
  8479.  
  8480. #==============================================================================#
  8481. # ** Game Event
  8482. #==============================================================================#
  8483. class Game_Event < Game_Character
  8484.  
  8485.   #--------------------------------------------------------------------------#
  8486.   # * alias-method :initialize
  8487.   #--------------------------------------------------------------------------#
  8488.   alias :ygg_ge_initialize :initialize unless $@
  8489.   def initialize( *args, &block )
  8490.     ygg_ge_initialize( *args, &block )
  8491.     @ai_operated        = true
  8492.   end
  8493.  
  8494.   #--------------------------------------------------------------------------#
  8495.   # * alias-method :erase
  8496.   #--------------------------------------------------------------------------#
  8497.   alias :ygg_gme_erase :erase unless $@
  8498.   def erase( *args, &block )
  8499.     terminate_ai_engine()
  8500.     ygg_unregister() ; ygg_gme_erase( *args, &block )
  8501.   end
  8502.  
  8503.   #--------------------------------------------------------------------------#
  8504.   # * alias-method :setup
  8505.   #--------------------------------------------------------------------------#
  8506.   alias :ygg_gme_setup :setup unless $@
  8507.   def setup( *args, &block )
  8508.     @dont_scan_events = YGG::DONT_SCAN_EVENTS
  8509.     @ygg_cache_complete = false
  8510.     ygg_gme_setup( *args, &block )
  8511.     ygg_event_cache()
  8512.   end
  8513.  
  8514.   #--------------------------------------------------------------------------#
  8515.   # * new-method :pop_enabled?
  8516.   #--------------------------------------------------------------------------#  
  8517.   def pop_enabled?()
  8518.     return @ygg_pop_enabled
  8519.   end
  8520.  
  8521.   #--------------------------------------------------------------------------#
  8522.   # * new-method :ygg_event_cache
  8523.   #--------------------------------------------------------------------------#
  8524.   def ygg_event_cache()
  8525.     ygg_event_cache_start()
  8526.     for i in 0..@list.size
  8527.       next if @list[i].nil?()
  8528.       if [108, 408].include?( @list[i].code )
  8529.         @list[i].parameters.to_s.split(/[\r\n]+/).each { |line|
  8530.           ygg_event_cache_check( line )
  8531.         }
  8532.       end
  8533.     end unless @list.nil?()
  8534.     ygg_event_cache_end()
  8535.   end
  8536.  
  8537.   #--------------------------------------------------------------------------#
  8538.   # * new-method :ygg_event_cache_start
  8539.   #--------------------------------------------------------------------------#
  8540.   def ygg_event_cache_start()
  8541.     @ygg_cache_complete     = false
  8542.     @ygg_battler            = nil
  8543.     @ygg_ally               = false
  8544.     @ygg_enemy              = false
  8545.     @ygg_boss               = false
  8546.     @ygg_invincible         = false
  8547.     @ygg_pop_enabled        = true
  8548.     @hp_visible             = true
  8549.     @mp_visible             = true
  8550.     @ygg_ondeath            = []
  8551.    
  8552.     @ygg_fading_death       = true  # // Depreceated
  8553.     @ygg_instant_death      = false # // Depreceated
  8554.     @ygg_dead_switches      = []    # // Depreceated
  8555.     @ygg_dead_self_switches = []    # // Depreceated
  8556.     @ygg_dieing             = false # // Depreceated
  8557.     @die_count_down         = 255   # // Depreceated
  8558.     @ygg_death_anim         = 0     # // Depreceated
  8559.    
  8560.     setup_ai_engine( YGG::Handlers::AIEngines::Default, {} )
  8561.    
  8562.     @__aiengine, @__aieng_setup_data = nil, {}
  8563.     @__read_aiengine = 0
  8564.    
  8565.     @__read_ondeath = 0
  8566.   end
  8567.  
  8568.   #--------------------------------------------------------------------------#
  8569.   # * new-method :ygg_event_cache_check
  8570.   #--------------------------------------------------------------------------#
  8571.   def ygg_event_cache_check( line )  
  8572.     case line
  8573.     when YGG::REGEXP::EVENT::SELF_SWITCH
  8574.       @ygg_dead_self_switches.push($1.to_s.upcase)
  8575.     when YGG::REGEXP::EVENT::SWITCH
  8576.       @ygg_dead_switches.push([$1.to_i, $2.to_s])
  8577.     when YGG::REGEXP::EVENT::INVINCIBLE
  8578.       @ygg_invincible = true
  8579.     when YGG::REGEXP::EVENT::NO_FADE_DEATH  
  8580.       @ygg_fading_death = false
  8581.     when YGG::REGEXP::EVENT::INSTANT_DEATH
  8582.       @ygg_instant_death = true
  8583.     when YGG::REGEXP::EVENT::ABS_ALLY
  8584.       next if $game_actors[$1.to_i].nil?()
  8585.       setup_ygg_battler( $game_actors[$1.to_i], :actor )
  8586.     when YGG::REGEXP::EVENT::ABS_ENEMY
  8587.       next if $data_enemies[$1.to_i].nil?()
  8588.       setup_ygg_battler( Game_Enemy.new(0, $1.to_i), :enemy )  
  8589.     when YGG::REGEXP::EVENT::ABS_SET_AS_ALLY
  8590.       @ygg_enemy = !@ygg_ally = true
  8591.     when YGG::REGEXP::EVENT::ABS_SET_AS_ENEMY  
  8592.       @ygg_ally = !@ygg_enemy = true
  8593.     when YGG::REGEXP::EVENT::ABS_BOSS
  8594.       @ygg_boss = true
  8595.     when YGG::REGEXP::EVENT::DEATH_ANIM  
  8596.       @ygg_death_anim = $1.to_i
  8597.     when YGG::REGEXP::EVENT::AI_ENGINE1  
  8598.       @__aiengine = ::YGG::AI_ENGINES[$1.to_s.downcase]
  8599.       @__read_aiengine = 1
  8600.     when YGG::REGEXP::EVENT::AI_ENGINE2    
  8601.       @__read_aiengine = 0
  8602.     when YGG::REGEXP::EVENT::ENABLE_POP
  8603.       @ygg_pop_enabled = true
  8604.     when YGG::REGEXP::EVENT::DISABLE_POP
  8605.       @ygg_pop_enabled = false
  8606.     when YGG::REGEXP::EVENT::SHOW_HP_BAR
  8607.       @hp_visible = true
  8608.     when YGG::REGEXP::EVENT::HIDE_HP_BAR    
  8609.       @hp_visible = false
  8610.     when YGG::REGEXP::EVENT::SHOW_MP_BAR    
  8611.       @mp_visible = true
  8612.     when YGG::REGEXP::EVENT::HIDE_MP_BAR    
  8613.       @mp_visible = false
  8614.     when YGG::REGEXP::EVENT::ONDEATH1
  8615.       @__read_ondeath = 1
  8616.     when YGG::REGEXP::EVENT::ONDEATH2  
  8617.       @__read_ondeath = 0
  8618.     else
  8619.       if @__read_aiengine == 1
  8620.         case line
  8621.         when /(.*)\=[ ](.*)/i
  8622.           @__aieng_setup_data[$1] = $2
  8623.         end  
  8624.       elsif @__read_ondeath == 1
  8625.         @ygg_ondeath << ::YGG.get_action_from_line( line )
  8626.       end  
  8627.     end
  8628.   end
  8629.  
  8630.   #--------------------------------------------------------------------------#
  8631.   # * new-method :ygg_event_cache_end
  8632.   #--------------------------------------------------------------------------#
  8633.   def ygg_event_cache_end()
  8634.     setup_ai_engine( @__aiengine, @__aieng_setup_data ) unless @__aiengine.nil?()
  8635.     @__read_aiengine, @__aiengine, @__aieng_setup_data = 0, nil, {}
  8636.     @ygg_cache_complete = true
  8637.     #setup_target_group()
  8638.   end
  8639.  
  8640.   #--------------------------------------------------------------------------#
  8641.   # * new-method :setup_ygg_battler
  8642.   #--------------------------------------------------------------------------#  
  8643.   def setup_ygg_battler( battler, type=:actor )
  8644.     @ygg_battler = battler
  8645.     case type
  8646.     when :actor ; @ygg_enemy = !@ygg_ally = true
  8647.     when :enemy ; @ygg_ally  = !@ygg_enemy = true
  8648.     end  
  8649.   end
  8650.  
  8651.   #--------------------------------------------------------------------------#
  8652.   # * new-method :terminate_ygg_battler
  8653.   #--------------------------------------------------------------------------#
  8654.   def terminate_ygg_battler()
  8655.     @ygg_battler = nil
  8656.   end
  8657.  
  8658.   #--------------------------------------------------------------------------#
  8659.   # * new-method :ygg_attacker
  8660.   #--------------------------------------------------------------------------#
  8661.   def ygg_attacker() ; @ygg_battler || super ; end
  8662.  
  8663.   #--------------------------------------------------------------------------#
  8664.   # * new-method :ygg_ally?
  8665.   #--------------------------------------------------------------------------#
  8666.   def ygg_ally?() ; return @ygg_ally ; end
  8667.  
  8668.   #--------------------------------------------------------------------------#
  8669.   # * new-method :Is an enemy?
  8670.   #--------------------------------------------------------------------------#
  8671.   def ygg_enemy? ; return @ygg_enemy ; end
  8672.  
  8673.   #--------------------------------------------------------------------------#
  8674.   # * new-method :ygg_boss?
  8675.   #--------------------------------------------------------------------------#
  8676.   def ygg_boss? ; return @ygg_boss ; end
  8677.  
  8678.   #--------------------------------------------------------------------------#
  8679.   # * new-method :ygg_death
  8680.   #--------------------------------------------------------------------------#
  8681.   def ygg_death()
  8682.     ygg_enemy?() ? Sound.play_enemy_collapse() : Sound.play_actor_collapse()
  8683.     create_drops()
  8684.     @ygg_battler = nil
  8685.     @ygg_boss    = false
  8686.     @ygg_dieing  = true
  8687.   end
  8688.  
  8689.   #--------------------------------------------------------------------------#
  8690.   # * new-method :create_drops
  8691.   #--------------------------------------------------------------------------#
  8692.   def create_drops()
  8693.     $game_map.create_drops( self.x, self.y, ygg_battler.create_drops_object() )
  8694.   end
  8695.  
  8696.   #--------------------------------------------------------------------------#
  8697.   # * alias-method :update
  8698.   #--------------------------------------------------------------------------#
  8699.   alias :ygg_gme_update :update unless $@
  8700.   def update()
  8701.     ygg_gme_update()
  8702.     ygg_abs_update() if $game_system.yggdrasil_on?()
  8703.   end
  8704.  
  8705.   #--------------------------------------------------------------------------#
  8706.   # * new-method :ygg_abs_update
  8707.   #--------------------------------------------------------------------------#
  8708.   def ygg_abs_update()
  8709.     super()
  8710.     unless self.ygg_battler.nil?()
  8711.       update_battler()
  8712.       if ygg_attacker.dead? ; ygg_death()
  8713.       else                  ; ygg_update_ai()
  8714.       end
  8715.     end
  8716.     if @ygg_dieing
  8717.       if @ygg_instant_death  
  8718.         @die_count_down = 0
  8719.       elsif @ygg_fading_death
  8720.         @opacity = @die_count_down -= 255 / YGG::DIE_WAIT_TIME
  8721.       else
  8722.         @die_count_down -= 255 / YGG::DIE_WAIT_TIME
  8723.       end  
  8724.       if @die_count_down <= 0
  8725.         @ygg_dieing = false
  8726.         ygg_perform_death()
  8727.       end  
  8728.     end
  8729.   end
  8730.  
  8731.   #--------------------------------------------------------------------------#
  8732.   # * new-method :ygg_perform_death
  8733.   #--------------------------------------------------------------------------#
  8734.   # Hp == 0 .'. Dead. If no switch is present the event is simply erased
  8735.   # If IRME is present, and the event is generated the irme_die is called
  8736.   # Therefore the event is removed.
  8737.   #--------------------------------------------------------------------------#
  8738.   if $imported["IRME_Event_Generator"]
  8739.     def ygg_perform_death()
  8740.       ygg_death_operations()
  8741.       if @ygg_dead_self_switches.empty? and @ygg_dead_switches.empty? # If no switches are present do normal erasing
  8742.         unless @generator_id.nil?()
  8743.           self.irme_die()
  8744.         else
  8745.           self.erase
  8746.         end  
  8747.       end
  8748.     end  
  8749.   else
  8750.     def ygg_perform_death()
  8751.       ygg_death_operations()
  8752.       if @ygg_dead_self_switches.empty? and @ygg_dead_switches.empty? # If no switches are present do normal erasing
  8753.         self.erase()
  8754.       end
  8755.     end
  8756.   end
  8757.  
  8758.   #--------------------------------------------------------------------------#
  8759.   # * new-method :ygg_death_operations
  8760.   #--------------------------------------------------------------------------#
  8761.   def ygg_death_operations()
  8762.     @ygg_anims.push(@ygg_death_anim) if @ygg_death_anim > 0
  8763.     if !@ygg_dead_self_switches.empty?() or !@ygg_dead_switches.empty?()
  8764.       @ygg_dead_self_switches.compact.each { |selswit|
  8765.         $game_system.control_self_switch( $game_map.map_id, @id, selswit, true )
  8766.       }
  8767.       @ygg_dead_switches.compact.each { |swit|
  8768.         swit_id = swit[0]
  8769.         case swit[1].to_s
  8770.         when /(?:TRUE|ON)/i
  8771.           $game_switches[swit_id] = true
  8772.           $game_map.need_refresh = true
  8773.         when /(?:FALSE|OFF)/i  
  8774.           $game_switches[swit_id] = false
  8775.           $game_map.need_refresh = true
  8776.         end          
  8777.       }
  8778.       $game_map.need_refresh = true
  8779.     end
  8780.   end
  8781.  
  8782. end
  8783.  
  8784. #==============================================================================#
  8785. # ** Game Player
  8786. #==============================================================================#
  8787. class Game_Player < Game_Character
  8788.  
  8789.   #--------------------------------------------------------------------------#
  8790.   # * Public Instance Variable(s)
  8791.   #--------------------------------------------------------------------------#
  8792.   attr_accessor :ygg_gained_items
  8793.  
  8794.   #--------------------------------------------------------------------------#
  8795.   # * alias-method :initialize
  8796.   #--------------------------------------------------------------------------#
  8797.   alias :ygg_gmp_initialize :initialize unless $@
  8798.   def initialize( *args, &block )
  8799.     ygg_gmp_initialize( *args, &block )
  8800.     @ygg_targeting_mode = false
  8801.     @ygg_remote_sprite  = nil
  8802.     @ygg_old_actor      = nil
  8803.     @ygg_old_target_pos = [0, 0]
  8804.     @ygg_gained_items   = []
  8805.   end
  8806.    
  8807.   #--------------------------------------------------------------------------#
  8808.   # * alias-method :update
  8809.   #--------------------------------------------------------------------------#
  8810.   alias :ygg_gmp_update :update unless $@
  8811.   def update( *args, &block )
  8812.     abs_on = $game_system.yggdrasil_on?()  
  8813.     if abs_on    
  8814.       ygg_abs_update()
  8815.       ygg_update_pickup()
  8816.     end  
  8817.     ygg_gmp_update( *args, &block )
  8818.     if abs_on
  8819.       @ygg_old_actor = $game_party.members[0]
  8820.     end  
  8821.   end
  8822.  
  8823.   #--------------------------------------------------------------------------#
  8824.   # * new-method :ygg_update_pickup
  8825.   #--------------------------------------------------------------------------#
  8826.   def ygg_update_pickup()
  8827.     $game_map.drops_xy( self.x, self.y ).compact.each { |dr|
  8828.       self.ygg_gain_drop( dr.drop ) ; dr.drop_remove() }
  8829.   end
  8830.  
  8831.   #--------------------------------------------------------------------------#
  8832.   # * new-method :gain_drop
  8833.   #--------------------------------------------------------------------------#
  8834.   def ygg_gain_drop( drop )
  8835.     return if drop.nil?()
  8836.     drop.pickup_sfx.play() unless drop.pickup_sfx.nil?()
  8837.     @ygg_gained_items << drop
  8838.     @ygg_gained_items.shift() while @ygg_gained_items.size > 20 # // remove really old drops to save memory
  8839.     if drop.is_a?( YGG::Containers::GoldItem )
  8840.       $game_party.gain_gold( drop.gold_amount )
  8841.     else
  8842.       $game_party.gain_item( drop, 1 )
  8843.     end  
  8844.   end
  8845.  
  8846.   #--------------------------------------------------------------------------#
  8847.   # * new-method :ygg_abs_update
  8848.   #--------------------------------------------------------------------------#
  8849.   def ygg_abs_update()
  8850.     super()
  8851.     unless self.ygg_battler.nil?()
  8852.       update_battler() ; ygg_attack_input()
  8853.     end  
  8854.   end
  8855.  
  8856.   #--------------------------------------------------------------------------#
  8857.   # * new-method :ygg_attacker
  8858.   #--------------------------------------------------------------------------#
  8859.   def ygg_attacker() ; return $game_party.members[0] ; end
  8860.  
  8861.   #--------------------------------------------------------------------------#
  8862.   # * new-method :ygg_ally?, ygg_enemy?, ygg_wild?, ygg_boss?
  8863.   #--------------------------------------------------------------------------#
  8864.   def ygg_ally?  ; return true  ; end
  8865.   def ygg_enemy? ; return false ; end
  8866.   def ygg_wild?  ; return false ; end
  8867.   def ygg_boss?  ; return false ; end
  8868.    
  8869.   #--------------------------------------------------------------------------#
  8870.   # * new-method :ygg_can_move?
  8871.   #--------------------------------------------------------------------------#
  8872.   def ygg_can_move?() ; super() ; end
  8873.  
  8874.   #--------------------------------------------------------------------------#
  8875.   # * overwrite-method :use_equipment
  8876.   #--------------------------------------------------------------------------#
  8877.   def use_equipment ; return true ; end
  8878.      
  8879. end
  8880.  
  8881. #==============================================================================#
  8882. # ** YGG::Drop_Character
  8883. #==============================================================================#
  8884. class YGG::Drop_Character < YGG::Handlers::Screen
  8885.  
  8886.   #--------------------------------------------------------------------------#
  8887.   # * Public Instance Variable(s)
  8888.   #--------------------------------------------------------------------------#  
  8889.   attr_accessor :icon_index
  8890.   attr_accessor :ready_to_remove
  8891.   attr_accessor :icon_time_out
  8892.   attr_accessor :opacity
  8893.   attr_accessor :visible
  8894.  
  8895.   #--------------------------------------------------------------------------#
  8896.   # * super-method :initialize
  8897.   #--------------------------------------------------------------------------#
  8898.   def initialize( object, time = 640 )
  8899.     super( 0, 0, 0 )
  8900.     @drop_object     = object
  8901.     @icon_index      = @drop_object.icon_index
  8902.     @icon_time_out   = time
  8903.     @icon_fade_thres = YGG::DROP_FADE_THRESHOLD
  8904.     @opacity         = 255
  8905.     @visible         = true
  8906.   end
  8907.  
  8908.   #--------------------------------------------------------------------------#
  8909.   # * new-method :pos?
  8910.   #--------------------------------------------------------------------------#
  8911.   def pos?( tx, ty ) ; return (self.x == tx && self.y == ty) ; end
  8912.    
  8913.   #--------------------------------------------------------------------------#
  8914.   # * new-method :update
  8915.   #--------------------------------------------------------------------------#
  8916.   def update()
  8917.     @icon_time_out   = [@icon_time_out-1, 0].max
  8918.     @ready_to_remove = true if @icon_time_out <= 0
  8919.     @opacity -= 255 / 60 if @icon_time_out <= @icon_fade_thres
  8920.     if $game_player.drop_attraction?()
  8921.       if $game_player.x > self.x    ; self.x = [self.x-0.1, $game_player.x].min
  8922.       elsif $game_player.x < self.x ; self.x = [self.x-0.1, $game_player.x].max
  8923.       end  
  8924.       if $game_player.y > self.y    ; self.y = [self.y-0.1, $game_player.y].min
  8925.       elsif $game_player.y < self.y ; self.y = [self.y-0.1, $game_player.y].max
  8926.       end
  8927.       @real_x = self.x*256 ; @real_y = self.y*256
  8928.     end  
  8929.   end
  8930.  
  8931.   #--------------------------------------------------------------------------#
  8932.   # * super-method :drop_remove
  8933.   #--------------------------------------------------------------------------#
  8934.   def drop_remove()
  8935.     @drop_object = nil
  8936.     @icon_index = 0
  8937.     @icon_time_out = 0
  8938.   end
  8939.  
  8940.   #--------------------------------------------------------------------------#
  8941.   # * new-method :timeout?
  8942.   #--------------------------------------------------------------------------#
  8943.   def timeout? ; return @icon_time_out == 0 end
  8944.    
  8945.   #--------------------------------------------------------------------------#
  8946.   # * new-method :drop
  8947.   #--------------------------------------------------------------------------#
  8948.   def drop ; return @drop_object end
  8949.    
  8950. end
  8951.  
  8952. #==============================================================================#
  8953. # ** Scene_Title
  8954. #==============================================================================#  
  8955. class Scene_Title < Scene_Base
  8956.  
  8957.   #--------------------------------------------------------------------------#
  8958.   # * alias-method :load_database
  8959.   #--------------------------------------------------------------------------#  
  8960.   alias :ygg_sct_load_database :load_database unless $@
  8961.   def load_database()
  8962.     ygg_sct_load_database()
  8963.     load_ygg_database()
  8964.   end
  8965.  
  8966.   #--------------------------------------------------------------------------#
  8967.   # * alias-method :load_bt_database
  8968.   #--------------------------------------------------------------------------#  
  8969.   alias :ygg_sct_load_bt_database :load_bt_database unless $@
  8970.   def load_bt_database()
  8971.     ygg_sct_load_bt_database()
  8972.     load_ygg_database()
  8973.   end
  8974.  
  8975.   #--------------------------------------------------------------------------#
  8976.   # * alias-method :load_ygg_database
  8977.   #--------------------------------------------------------------------------#  
  8978.   def load_ygg_database()
  8979.     data = []
  8980.     data += $data_items
  8981.     data += $data_skills
  8982.     data += $data_enemies
  8983.     data += $data_weapons
  8984.     data += $data_armors
  8985.     data += $data_states
  8986.     data.compact.each { |obj| obj.yggdrasil_1x6_cache() }
  8987.   end
  8988.  
  8989.   #--------------------------------------------------------------------------#
  8990.   # * alias-method :create_game_objects
  8991.   #--------------------------------------------------------------------------#
  8992.   alias :ygg_sct_ptxt_create_game_objects :create_game_objects unless $@
  8993.   def create_game_objects()
  8994.     $game_yggdrasil = YGG::System.new()
  8995.     ygg_sct_ptxt_create_game_objects()
  8996.   end
  8997.  
  8998. end
  8999.  
  9000. #==============================================================================#
  9001. # ** Scene_Map
  9002. #==============================================================================#
  9003. class Scene_Map < Scene_Base
  9004.  
  9005.   #--------------------------------------------------------------------------#
  9006.   # * Public Instance Variable(s)
  9007.   #--------------------------------------------------------------------------#  
  9008.   attr_accessor :spriteset
  9009.        
  9010.   #--------------------------------------------------------------------------#
  9011.   # * new-method :push_ygg_anim
  9012.   #--------------------------------------------------------------------------#
  9013.   def push_ygg_anim( anim_id, x, y, targets=[], looped = false )
  9014.     @spriteset.push_anim( anim_id, x, y, targets, looped ) unless @spriteset.nil?()
  9015.   end  
  9016.  
  9017.   #--------------------------------------------------------------------------#
  9018.   # * alias-method :update
  9019.   #--------------------------------------------------------------------------#
  9020.   alias :ygg_scm_update :update unless $@
  9021.   def update( *args, &block )
  9022.     ygg_scm_update( *args, &block )
  9023.     $game_yggdrasil.update()
  9024.     $game_party.ygg_slip_damage() if $game_yggdrasil.on?()
  9025.     $game_yggdrasil.gameover_process() if $game_party.all_dead?() if $game_system.gameover_alldead?()
  9026.   end
  9027.  
  9028. if ::YGG::USE_DROPS_WINDOW
  9029.  
  9030.   #--------------------------------------------------------------------------#
  9031.   # * alias-method :start
  9032.   #--------------------------------------------------------------------------#  
  9033.   alias :ygg_drop_win_start :start unless $@
  9034.   def start( *args, &block )
  9035.     ygg_drop_win_start( *args, &block )
  9036.     create_drops_window()
  9037.   end
  9038.  
  9039.   #--------------------------------------------------------------------------#
  9040.   # * new-method :create_drops_window
  9041.   #--------------------------------------------------------------------------#
  9042.   def create_drops_window()
  9043.     size = YGG::DROPS_WINDOW_SIZE
  9044.     @drops_logging = YGG::Drops_Window.new(
  9045.       { :x => size[0], :y => size[1], :z => size[2], :width => size[3] }, nil )  
  9046.     @drops_logging.visible = $game_yggdrasil.drops_window_visible?()
  9047.   end
  9048.  
  9049.   #--------------------------------------------------------------------------#
  9050.   # * alias-method :terminate
  9051.   #--------------------------------------------------------------------------#
  9052.   alias :ygg_drop_win_terminate :terminate unless $@
  9053.   def terminate( *args, &block )
  9054.     @drops_logging.dispose() unless @drops_logging.nil?() ; @drops_logging = nil
  9055.     ygg_drop_win_terminate( *args, &block )
  9056.   end
  9057.  
  9058.   #--------------------------------------------------------------------------#
  9059.   # * alias-method :update
  9060.   #--------------------------------------------------------------------------#  
  9061.   alias :ygg_drop_win_update :update unless $@
  9062.   def update( *args, &block )
  9063.     unless @drops_logging.nil?()
  9064.       @drops_logging.visible = $game_yggdrasil.drops_window_visible?()
  9065.       @drops_logging.update()
  9066.     end
  9067.     ygg_drop_win_update( *args, &block )
  9068.   end
  9069.  
  9070. end # // Drops Window
  9071.  
  9072. end
  9073.  
  9074. # // (YGG_ShiftSystem)
  9075. if YGG::USE_SHIFT_SYSTEM
  9076. #==============================================================================#
  9077. # ** Game_Party
  9078. #==============================================================================#
  9079. class Game_Party < Game_Unit
  9080.  
  9081.   #--------------------------------------------------------------------------#
  9082.   # * Public Instance Variables
  9083.   #--------------------------------------------------------------------------#
  9084.   attr_accessor :actors
  9085.  
  9086. end
  9087.  
  9088. #==============================================================================#
  9089. # ** YGG::Handlers::Shift
  9090. #==============================================================================#
  9091. class YGG::Handlers::Shift
  9092.  
  9093.   #--------------------------------------------------------------------------#
  9094.   # * Public Instance Variables
  9095.   #--------------------------------------------------------------------------#  
  9096.   attr_accessor :shift_time
  9097.   attr_accessor :shift_cap
  9098.  
  9099.   #--------------------------------------------------------------------------#
  9100.   # * new-method :initialize
  9101.   #--------------------------------------------------------------------------#
  9102.   def initialize()
  9103.     @shift_time = 0
  9104.     @shift_cap  = Graphics.frame_rate*5
  9105.   end
  9106.  
  9107.   #--------------------------------------------------------------------------#
  9108.   # * new-method :reset_shift_time
  9109.   #--------------------------------------------------------------------------#
  9110.   def reset_shift_time() ; @shift_time = @shift_cap ; end
  9111.  
  9112.   #--------------------------------------------------------------------------#
  9113.   # * new-method :time
  9114.   #--------------------------------------------------------------------------#  
  9115.   def time() ; return @shift_time ; end
  9116.  
  9117.   #--------------------------------------------------------------------------#
  9118.   # * new-method :cap
  9119.   #--------------------------------------------------------------------------#  
  9120.   def cap() ; return @shift_cap ; end  
  9121.    
  9122.   #--------------------------------------------------------------------------#
  9123.   # * new-method :can_shift?
  9124.   #--------------------------------------------------------------------------#  
  9125.   def can_shift?() ; return @shift_time == 0 ; end
  9126.  
  9127.   #--------------------------------------------------------------------------#
  9128.   # * new-method :swap_actors
  9129.   #--------------------------------------------------------------------------#
  9130.   def swap_actors( target_index, swap_index )
  9131.     target_id = $game_party.actors[target_index]
  9132.     swap_id = $game_party.actors[swap_index]
  9133.   end
  9134.  
  9135.   #--------------------------------------------------------------------------#
  9136.   # * new-method :rotate_actors
  9137.   #--------------------------------------------------------------------------#
  9138.   def rotate_actors( n=1 )
  9139.     $game_party.actors.rotate!( n )
  9140.   end
  9141.  
  9142.   #--------------------------------------------------------------------------#
  9143.   # * new-method :perform_shift
  9144.   #--------------------------------------------------------------------------#
  9145.   def perform_shift( n )
  9146.     rotate_actors( n ) ;
  9147.     $game_player.ygg_anims << 81
  9148.     $game_player.thrust_backward()
  9149.     $game_player.refresh()
  9150.     reset_shift_time()
  9151.   end
  9152.  
  9153.   #--------------------------------------------------------------------------#
  9154.   # * new-method :update
  9155.   #--------------------------------------------------------------------------#
  9156.   def update()
  9157.     @shift_time = [@shift_time - 1, 0].max
  9158.     update_shift() if can_shift?
  9159.     perform_shift( 1 ) while $game_party.members[0].dead?() unless $game_party.all_dead?()
  9160.   end
  9161.  
  9162.   #--------------------------------------------------------------------------#
  9163.   # * new-method :update_shift
  9164.   #--------------------------------------------------------------------------#
  9165.   def update_shift()
  9166.     if Input.trigger?( Input::R )
  9167.       perform_shift( 1 )
  9168.     elsif Input.trigger?( Input::L )  
  9169.       perform_shift( -1 )
  9170.     end  
  9171.   end
  9172.  
  9173. end
  9174.  
  9175. #==============================================================================#
  9176. # ** YGG::System
  9177. #==============================================================================#
  9178. class YGG::System
  9179.  
  9180.   #--------------------------------------------------------------------------#
  9181.   # * Public Instance Variables
  9182.   #--------------------------------------------------------------------------#  
  9183.   attr_accessor :shift_system
  9184.  
  9185.   #--------------------------------------------------------------------------#
  9186.   # * alias-method :initialize
  9187.   #--------------------------------------------------------------------------#  
  9188.   alias :ygg_shift_sys_initialize :initialize unless $@
  9189.   def initialize( *args, &block )
  9190.     ygg_shift_sys_initialize( *args, &block )
  9191.     @shift_system = ::YGG::Handlers::Shift.new()
  9192.   end
  9193.  
  9194.   #--------------------------------------------------------------------------#
  9195.   # * alias-method :update
  9196.   #--------------------------------------------------------------------------#  
  9197.   alias :ygg_shift_sys_update :update unless $@
  9198.   def update( *args, &block )
  9199.     ygg_shift_sys_update( *args, &block )
  9200.     @shift_system.update()
  9201.   end
  9202.  
  9203. end
  9204.  
  9205. end
  9206.  
  9207. # // (YGG_LevelUpWindow)
  9208. if YGG::USE_LEVEL_UP_WINDOW > 0
  9209. #==============================================================================#
  9210. # ** YGG::Windows::Level_Up
  9211. #==============================================================================#
  9212. class YGG::Windows::Level_Up < ::Sprite
  9213.  
  9214.   #--------------------------------------------------------------------------#
  9215.   # * Constant(s)
  9216.   #--------------------------------------------------------------------------#  
  9217.   WLH = 20
  9218.   BORDER_SIZE = 2
  9219.  
  9220.   #--------------------------------------------------------------------------#
  9221.   # * super-method :initialize
  9222.   #--------------------------------------------------------------------------#  
  9223.   def initialize( x, y, width, viewport=nil )
  9224.     super( viewport )
  9225.     @background = Sprite.new( self.viewport )
  9226.     @background.bitmap = Bitmap.new( width, WLH )
  9227.     @background.bitmap.fill_rect( BORDER_SIZE, BORDER_SIZE,
  9228.       width-(BORDER_SIZE*2), WLH-(BORDER_SIZE*2),
  9229.       Color.new( 0, 0, 0 ) )
  9230.     @background.bitmap.blur() ; @background.bitmap.blur()
  9231.     @background.opacity = 198
  9232.     self.bitmap = Bitmap.new( width, WLH*7 )
  9233.     self.src_rect.set( 0, 0, width, WLH )
  9234.     @count = 0 ; @index = 0
  9235.     self.x, self.y, self.z = x, y, 9999
  9236.     @target_opacity = 0
  9237.   end
  9238.  
  9239.   #--------------------------------------------------------------------------#
  9240.   # * super-method :dispose
  9241.   #--------------------------------------------------------------------------#
  9242.   def dispose()
  9243.     unless @background.nil?()
  9244.       @background.bitmap.dispose() ; @background.dispose()
  9245.     end
  9246.     self.bitmap.dispose()
  9247.     super()
  9248.   end
  9249.  
  9250.   #--------------------------------------------------------------------------#
  9251.   # * super-method :x=
  9252.   #--------------------------------------------------------------------------#
  9253.   def x=( new_x )
  9254.     super( new_x )
  9255.     @background.x = self.x
  9256.   end
  9257.  
  9258.   #--------------------------------------------------------------------------#
  9259.   # * super-method :y=
  9260.   #--------------------------------------------------------------------------#
  9261.   def y=( new_y )
  9262.     super( new_y )
  9263.     @background.y = self.y
  9264.   end
  9265.  
  9266.   #--------------------------------------------------------------------------#
  9267.   # * super-method :z=
  9268.   #--------------------------------------------------------------------------#
  9269.   def z=( new_z )
  9270.     super( new_z+1 )
  9271.     @background.z = new_z
  9272.   end
  9273.  
  9274.   #--------------------------------------------------------------------------#
  9275.   # * super-method :viewport=
  9276.   #--------------------------------------------------------------------------#
  9277.   def viewport=( new_viewport )
  9278.     super( new_viewport )
  9279.     @background.viewport = self.viewport
  9280.   end
  9281.  
  9282.   #--------------------------------------------------------------------------#
  9283.   # * super-method :visible=
  9284.   #--------------------------------------------------------------------------#
  9285.   def visible=( new_visible )
  9286.     super( new_visible )
  9287.     @background.visible = self.visible
  9288.   end
  9289.  
  9290.   #--------------------------------------------------------------------------#
  9291.   # * super-method :show_level_up
  9292.   #--------------------------------------------------------------------------#
  9293.   def show_level_up( battler, old_level )
  9294.     self.bitmap.clear()
  9295.     @count = 0 ; @index = 0 ; @last_index = -1
  9296.     stats = [:maxhp, :maxmp, :atk, :def, :spi, :agi]
  9297.     self.bitmap.font.size = 16
  9298.     self.bitmap.draw_text( 0, 0, self.width, WLH,
  9299.       sprintf( "%s: %s > %s", Vocab.level, old_level, battler.level ) )
  9300.     for i in 0...stats.size
  9301.       stat = stats[i]
  9302.       self.bitmap.draw_text( 0, WLH+(WLH*i), self.width, 20,
  9303.         sprintf( "%s: %s", Vocab.send( stat ), battler.send( stat ) ) )
  9304.     end  
  9305.     @target_opacity = 198
  9306.     self.visible = true
  9307.   end
  9308.  
  9309.   #--------------------------------------------------------------------------#
  9310.   # * super-method :update
  9311.   #--------------------------------------------------------------------------#
  9312.   def update()
  9313.     super()
  9314.     return if @index >= 8
  9315.     @count += 1
  9316.     @index += 1 if @count % 60 == 0
  9317.     if @index >= 7
  9318.       @target_opacity = 0
  9319.       self.visible = false
  9320.     else  
  9321.       if @index != @last_index
  9322.         self.src_rect.set( 0, WLH*@index, self.width, WLH )
  9323.         @last_index = @index
  9324.       end  
  9325.     end  
  9326.     if @background.opacity > @target_opacity
  9327.       @background.opacity = [@background.opacity - (255/30.0), @target_opacity].max
  9328.     elsif @background.opacity < @target_opacity  
  9329.       @background.opacity = [@background.opacity + (255/30.0), @target_opacity].min
  9330.     end  
  9331.   end
  9332.  
  9333. end  
  9334.  
  9335. #==============================================================================#
  9336. # ** Scene_Map
  9337. #==============================================================================#
  9338. class Scene_Map < Scene_Base
  9339.  
  9340.   #--------------------------------------------------------------------------#
  9341.   # * Public Instance Variable(s)
  9342.   #--------------------------------------------------------------------------#
  9343.   attr_accessor :level_up_window
  9344.  
  9345.   #--------------------------------------------------------------------------#
  9346.   # * alias-method :start
  9347.   #--------------------------------------------------------------------------#
  9348.   alias :ygg_lvl_up_win_scm_start :start unless $@
  9349.   def start( *args, &block )
  9350.     ygg_lvl_up_win_scm_start( *args, &block )
  9351.     @level_up_window = YGG::Windows::Level_Up.new( 0, 0, 128 )
  9352.   end
  9353.  
  9354.   #--------------------------------------------------------------------------#
  9355.   # * alias-method :terminate
  9356.   #--------------------------------------------------------------------------#
  9357.   alias :ygg_lvl_up_win_scm_terminate :terminate unless $@
  9358.   def terminate( *args, &block )
  9359.     ygg_lvl_up_win_scm_terminate( *args, &block )
  9360.     @level_up_window.dispose() unless @level_up_window.nil?() ; @level_up_window = nil
  9361.   end
  9362.  
  9363.   #--------------------------------------------------------------------------#
  9364.   # * alias-method :update
  9365.   #--------------------------------------------------------------------------#
  9366.   alias :ygg_lvl_up_win_scm_update :update unless $@
  9367.   def update( *args, &block )
  9368.     ygg_lvl_up_win_scm_update( *args, &block )
  9369.     @level_up_window.update() unless @level_up_window.nil?()
  9370.   end
  9371.  
  9372. end
  9373.  
  9374. end # // Level Up Window
  9375.  
  9376. #==============================================================================#
  9377. # ** Scene_File
  9378. #==============================================================================#
  9379. class Scene_File < Scene_Base
  9380.  
  9381.   #--------------------------------------------------------------------------#
  9382.   # * alias-method :write_save_data
  9383.   #--------------------------------------------------------------------------#
  9384.   alias :ygg_scnf_ptxt_write_save_data :write_save_data unless $@
  9385.   def write_save_data( file )
  9386.     ygg_scnf_ptxt_write_save_data( file )
  9387.     Marshal.dump( $game_yggdrasil,      file )
  9388.   end  
  9389.  
  9390.   #--------------------------------------------------------------------------#
  9391.   # * alias-method :read_save_data
  9392.   #--------------------------------------------------------------------------#
  9393.   alias :ygg_scnf_ptxt_read_save_data :read_save_data unless $@
  9394.   def read_save_data( file )
  9395.     ygg_scnf_ptxt_read_save_data( file )
  9396.     $game_yggdrasil = Marshal.load( file )
  9397.     $game_yggdrasil.__on_load()
  9398.   end
  9399.  
  9400. end
  9401.  
  9402. # // (Skill/Item Setting) // #
  9403. #==============================================================================#
  9404. # ** YGG::Windows::ActorObjSlots
  9405. #==============================================================================#
  9406. class ::YGG::Windows::ActorObjSlots < ::Window_Selectable
  9407.  
  9408.   #--------------------------------------------------------------------------#
  9409.   # * super-method :initialize
  9410.   #--------------------------------------------------------------------------#  
  9411.   def initialize( actor, x, y, width, height )
  9412.     super( x, y, width, height )
  9413.     @actor = actor
  9414.     @column_max = 1
  9415.     self.active = false
  9416.     self.index  = 0
  9417.     refresh()
  9418.   end
  9419.  
  9420.   #--------------------------------------------------------------------------#
  9421.   # * new-method :enabled?
  9422.   #--------------------------------------------------------------------------#  
  9423.   def enabled?( index )
  9424.     return !@data[index].nil?()
  9425.   end
  9426.  
  9427.   #--------------------------------------------------------------------------#
  9428.   # * new-method :obj
  9429.   #--------------------------------------------------------------------------#  
  9430.   def obj( i=@index ) ; return @data[i] ; end
  9431.    
  9432.   #--------------------------------------------------------------------------#
  9433.   # * new-method :get_objs
  9434.   #--------------------------------------------------------------------------#  
  9435.   def get_objs()
  9436.     return []
  9437.   end
  9438.  
  9439.   #--------------------------------------------------------------------------#
  9440.   # * new-method :refresh
  9441.   #--------------------------------------------------------------------------#  
  9442.   def refresh()
  9443.     @data     = get_objs()
  9444.     @item_max = @data.size
  9445.     @data_enabled = []
  9446.     create_contents()
  9447.     for i in 0...@item_max
  9448.       @data_enabled[i] = enabled?( i )
  9449.       draw_item( i )
  9450.     end
  9451.   end
  9452.  
  9453.   #--------------------------------------------------------------------------#
  9454.   # * new-method :selective_refresh
  9455.   #--------------------------------------------------------------------------#  
  9456.   def selective_refresh()
  9457.     newdata   = get_objs()
  9458.     @item_max = newdata.size
  9459.     if @data.size != @item_max
  9460.       @data.clear()
  9461.       create_contents()
  9462.     end
  9463.     for i in 0...newdata.size
  9464.       if newdata[i] != @data[i] || @data_enabled[i] != enabled?( i )
  9465.         @data[i] = newdata[i]
  9466.         @data_enabled[i] = enabled?( i )
  9467.         draw_item( i )
  9468.       end  
  9469.     end
  9470.   end
  9471.  
  9472.   #--------------------------------------------------------------------------#
  9473.   # * new-method :draw_item
  9474.   #--------------------------------------------------------------------------#  
  9475.   def draw_item( index )
  9476.     rect = item_rect( index )
  9477.     obj  = @data[index]
  9478.     enabled = enabled?( index )
  9479.     self.contents.clear_rect( rect )
  9480.     self.contents.font.color = normal_color
  9481.     self.contents.font.color.alpha -= 128 unless enabled
  9482.     unless obj.nil?()
  9483.       draw_item_name( obj, rect.x, rect.y, enabled )
  9484.     else
  9485.       draw_icon( 98, rect.x, rect.y )
  9486.       rect.x += 24
  9487.       self.contents.draw_text( rect, "----------------" )
  9488.     end  
  9489.   end
  9490.  
  9491.   #--------------------------------------------------------------------------#
  9492.   # * kill-method :cursor_pagedown
  9493.   #--------------------------------------------------------------------------#  
  9494.   def cursor_pagedown() ; end
  9495.    
  9496.   #--------------------------------------------------------------------------#
  9497.   # * kill-method :cursor_pageup
  9498.   #--------------------------------------------------------------------------#    
  9499.   def cursor_pageup() ; end
  9500.    
  9501. end  
  9502.  
  9503. #==============================================================================#
  9504. # ** YGG::Windows::ItemList
  9505. #==============================================================================#
  9506. class ::YGG::Windows::ItemList < ::YGG::Windows::ActorObjSlots
  9507.  
  9508.   #--------------------------------------------------------------------------#
  9509.   # * new-method :item
  9510.   #--------------------------------------------------------------------------#    
  9511.   def item() ; return obj() ; end
  9512.    
  9513.   #--------------------------------------------------------------------------#
  9514.   # * new-method :enabled?
  9515.   #--------------------------------------------------------------------------#    
  9516.   def enabled?( index )
  9517.     return false if @actor.item_slot_items.include?( @data[index] )
  9518.     return false if @data[index].cant_equip_slot unless @data[index].nil?()
  9519.     return super( index )
  9520.   end
  9521.  
  9522.   #--------------------------------------------------------------------------#
  9523.   # * overwrite-method :get_objs
  9524.   #--------------------------------------------------------------------------#    
  9525.   def get_objs()
  9526.     return [nil] + ($game_party.items.inject([]) { |r, i| r << i if i.is_a?(RPG::Item) }) + [nil]
  9527.   end
  9528.  
  9529.   #--------------------------------------------------------------------------#
  9530.   # * overwrite-method :update_help
  9531.   #--------------------------------------------------------------------------#    
  9532.   def update_help()
  9533.     @help_window.set_text(item.nil?() ? "" : item.description)
  9534.   end
  9535.  
  9536. end
  9537.  
  9538. #==============================================================================#
  9539. # ** YGG::Windows::SkillList
  9540. #==============================================================================#
  9541. class ::YGG::Windows::SkillList < ::YGG::Windows::ActorObjSlots
  9542.  
  9543.   #--------------------------------------------------------------------------#
  9544.   # * new-method :skill
  9545.   #--------------------------------------------------------------------------#    
  9546.   def skill() ; return obj() ; end
  9547.    
  9548.   #--------------------------------------------------------------------------#
  9549.   # * super-method :enabled?
  9550.   #--------------------------------------------------------------------------#    
  9551.   def enabled?( index )
  9552.     return false if @actor.skill_slot_skills.include?( @data[index] )
  9553.     return false if @data[index].cant_equip_slot unless @data[index].nil?()
  9554.     return super( index )
  9555.   end
  9556.  
  9557.   #--------------------------------------------------------------------------#
  9558.   # * overwrite-method :get_objs
  9559.   #--------------------------------------------------------------------------#    
  9560.   def get_objs()
  9561.     return [nil] + @actor.skills() + [nil]
  9562.   end
  9563.  
  9564.   #--------------------------------------------------------------------------#
  9565.   # * overwrite-method :update_help
  9566.   #--------------------------------------------------------------------------#    
  9567.   def update_help()
  9568.     @help_window.set_text(skill.nil?() ? "" : skill.description)
  9569.   end
  9570.  
  9571. end
  9572.  
  9573. #==============================================================================#
  9574. # ** YGG::Windows::ActorItemSlots
  9575. #==============================================================================#
  9576. class ::YGG::Windows::ActorItemSlots < ::YGG::Windows::ActorObjSlots
  9577.  
  9578.   #--------------------------------------------------------------------------#
  9579.   # * new-method :item
  9580.   #--------------------------------------------------------------------------#    
  9581.   def item() ; return obj() ; end
  9582.    
  9583.   #--------------------------------------------------------------------------#
  9584.   # * overwrite-method :get_objs
  9585.   #--------------------------------------------------------------------------#    
  9586.   def get_objs()
  9587.     return @actor.item_slot_items()
  9588.   end
  9589.  
  9590.   #--------------------------------------------------------------------------#
  9591.   # * overwrite-method :update_help
  9592.   #--------------------------------------------------------------------------#    
  9593.   def update_help()
  9594.     @help_window.set_text(item.nil?() ? "" : item.description)
  9595.   end
  9596.  
  9597. end  
  9598.  
  9599. #==============================================================================#
  9600. # ** YGG::Windows::ActorSkillSlots
  9601. #==============================================================================#
  9602. class ::YGG::Windows::ActorSkillSlots < ::YGG::Windows::ActorObjSlots
  9603.  
  9604.   #--------------------------------------------------------------------------#
  9605.   # * new-method :skill
  9606.   #--------------------------------------------------------------------------#    
  9607.   def skill() ; return obj() ; end
  9608.    
  9609.   #--------------------------------------------------------------------------#
  9610.   # * overwrite-method :get_objs
  9611.   #--------------------------------------------------------------------------#    
  9612.   def get_objs()
  9613.     return @actor.skill_slot_skills()
  9614.   end
  9615.  
  9616.   #--------------------------------------------------------------------------#
  9617.   # * overwrite-method :update_help
  9618.   #--------------------------------------------------------------------------#    
  9619.   def update_help()
  9620.     @help_window.set_text(skill.nil?() ? "" : skill.description)
  9621.   end
  9622.  
  9623. end  
  9624.  
  9625. # // Is there a good reason why I haven't super classes these? YES
  9626. #==============================================================================#
  9627. # ** YGG::Scenes::ObjSet
  9628. #==============================================================================#
  9629. class ::YGG::Scenes::ObjSet < ::Scene_Base
  9630.  
  9631.   #--------------------------------------------------------------------------#
  9632.   # * super-method :initialize
  9633.   #--------------------------------------------------------------------------#
  9634.   def initialize( actor, called=:map, return_index=0 )
  9635.     super()
  9636.     # ---------------------------------------------------- #
  9637.     @actor = nil
  9638.     @act_index = 0
  9639.     @index_call = false
  9640.     # ---------------------------------------------------- #
  9641.     if actor.kind_of?( Game_Battler )
  9642.       @actor = actor
  9643.     elsif actor != nil  
  9644.       @actor = $game_party.members[actor]
  9645.       @act_index = actor
  9646.       @index_call = true
  9647.     end
  9648.     @calledfrom = called
  9649.     @return_index = return_index
  9650.   end
  9651.  
  9652.   #--------------------------------------------------------------------------#
  9653.   # * new-method :start
  9654.   #--------------------------------------------------------------------------#
  9655.   def start()
  9656.     super()
  9657.   end
  9658.  
  9659.   #--------------------------------------------------------------------------#
  9660.   # * new-method :return_scene
  9661.   #--------------------------------------------------------------------------#
  9662.   def return_scene()
  9663.     case @calledfrom
  9664.     when :map
  9665.       $scene = Scene_Map.new()
  9666.     when :menu
  9667.       $scene = Scene_Menu.new( @return_index )
  9668.     end  
  9669.   end
  9670.  
  9671.   #--------------------------------------------------------------------------#
  9672.   # * super-method :terminate
  9673.   #--------------------------------------------------------------------------#  
  9674.   def terminate()
  9675.     super()
  9676.     dispose_menu_background()
  9677.     @help_window.dispose() unless @help_window.nil?()     ; @help_window = nil
  9678.     @obj_window.dispose() unless @obj_window.nil?()       ; @obj_window = nil
  9679.     @slot_window.dispose() unless @slot_window.nil?()     ; @slot_window = nil
  9680.     @status_window.dispose() unless @status_window.nil?() ; @status_window = nil
  9681.   end
  9682.  
  9683.   #--------------------------------------------------------------------------#
  9684.   # * super-method :update
  9685.   #--------------------------------------------------------------------------#  
  9686.   def update()
  9687.     super()
  9688.     update_menu_background()
  9689.     @obj_window.update() ; @slot_window.update()
  9690.     # // Basic Update
  9691.     if Input.trigger?( Input::B )
  9692.       command_cancel()
  9693.     elsif Input.trigger?( Input::R ) && @index_call    
  9694.       command_next()
  9695.     elsif Input.trigger?( Input::L ) && @index_call
  9696.       command_prev()
  9697.     # // Actual Input    
  9698.     elsif Input.trigger?( Input::C )
  9699.       command_accept()
  9700.     elsif Input.trigger?( Input::Z )
  9701.       # // Used to pop extended help window, if I ever implement it
  9702.     elsif Input.trigger?( Input::X ) || Input.trigger?( Input::LEFT )  
  9703.       command_prevslot()
  9704.     elsif Input.trigger?( Input::Y ) || Input.trigger?( Input::RIGHT )  
  9705.       command_nextslot()
  9706.     end  
  9707.   end  
  9708.  
  9709.   #--------------------------------------------------------------------------#
  9710.   # * new-method :command_cancel
  9711.   #--------------------------------------------------------------------------#
  9712.   def command_cancel()
  9713.     Sound.play_cancel()
  9714.     return_scene()
  9715.   end
  9716.  
  9717.   #--------------------------------------------------------------------------#
  9718.   # * new-method :command_next
  9719.   #--------------------------------------------------------------------------#
  9720.   def command_next()
  9721.     Sound.play_decision()
  9722.     $scene = self.class.new(
  9723.       (@act_index+1) % $game_party.members.size, @calledfrom, @return_index )
  9724.   end
  9725.  
  9726.   #--------------------------------------------------------------------------#
  9727.   # * new-method :command_prev
  9728.   #--------------------------------------------------------------------------#
  9729.   def command_prev()
  9730.     Sound.play_decision()  
  9731.     $scene = self.class.new(
  9732.       (@act_index-1) % $game_party.members.size, @calledfrom, @return_index )
  9733.   end
  9734.  
  9735.   #--------------------------------------------------------------------------#
  9736.   # * new-method :command_nextslot
  9737.   #--------------------------------------------------------------------------#
  9738.   def command_nextslot()
  9739.     Sound.play_cursor()
  9740.     @slot_window.index = (@slot_window.index + 1) % @slot_window.item_max
  9741.   end
  9742.    
  9743.   #--------------------------------------------------------------------------#
  9744.   # * new-method :command_prevslot
  9745.   #--------------------------------------------------------------------------#
  9746.   def command_prevslot()
  9747.     Sound.play_cursor()
  9748.     @slot_window.index = (@slot_window.index - 1) % @slot_window.item_max
  9749.   end
  9750.    
  9751.   #--------------------------------------------------------------------------#
  9752.   # * new-method :command_accept
  9753.   #--------------------------------------------------------------------------#
  9754.   def command_accept()
  9755.   end
  9756.  
  9757. end  
  9758.  
  9759. #==============================================================================#
  9760. # ** YGG::Scenes::ItemSet
  9761. #==============================================================================#
  9762. class ::YGG::Scenes::ItemSet < ::YGG::Scenes::ObjSet
  9763.  
  9764.   #--------------------------------------------------------------------------#
  9765.   # * super-method :start
  9766.   #--------------------------------------------------------------------------#  
  9767.   def start()
  9768.     super()
  9769.     create_menu_background()
  9770.     @help_window   = ::Window_Help.new()
  9771.     @status_window = ::Window_SkillStatus.new( 0, 56, @actor )
  9772.     @obj_window   = ::YGG::Windows::ItemList.new(
  9773.       @actor,
  9774.       Graphics.width/2, 112,
  9775.       Graphics.width/2, Graphics.height-112 )
  9776.     @obj_window.help_window = @help_window  
  9777.     @slot_window   = ::YGG::Windows::ActorItemSlots.new(
  9778.       @actor,
  9779.       0, 112,
  9780.       Graphics.width/2, Graphics.height-112 )
  9781.     @obj_window.active = true  
  9782.   end
  9783.  
  9784.   #--------------------------------------------------------------------------#
  9785.   # * new-method :command_accept
  9786.   #--------------------------------------------------------------------------#
  9787.   def command_accept()
  9788.     if @obj_window.enabled?( @obj_window.index ) || @obj_window.obj.nil?()
  9789.       Sound.play_decision
  9790.       id = @obj_window.item.nil?() ? 0 : @obj_window.item.id
  9791.       @actor.set_item_slot( @slot_window.index, id )
  9792.       @obj_window.selective_refresh() #.draw_item( @obj_window.index )
  9793.       @slot_window.refresh()
  9794.     else
  9795.       Sound.play_buzzer()
  9796.     end  
  9797.   end
  9798.  
  9799. end
  9800.  
  9801. # // Scene_ItemSet.new( actor, called_from, [return_index)]
  9802. Scene_ItemSet = YGG::Scenes::ItemSet
  9803.  
  9804. #==============================================================================#
  9805. # ** YGG::Scenes::SkillSet
  9806. #==============================================================================#
  9807. class ::YGG::Scenes::SkillSet < ::YGG::Scenes::ObjSet
  9808.  
  9809.   #--------------------------------------------------------------------------#
  9810.   # * super-method :start
  9811.   #--------------------------------------------------------------------------#  
  9812.   def start()
  9813.     super()
  9814.     create_menu_background()
  9815.     @help_window   = ::Window_Help.new()
  9816.     @status_window = ::Window_SkillStatus.new( 0, 56, @actor )
  9817.     @obj_window    = ::YGG::Windows::SkillList.new(
  9818.       @actor,
  9819.       Graphics.width/2, 112,
  9820.       Graphics.width/2, Graphics.height-112 )
  9821.     @obj_window.help_window = @help_window  
  9822.     @slot_window   = ::YGG::Windows::ActorSkillSlots.new(
  9823.       @actor,
  9824.       0, 112,
  9825.       Graphics.width/2, Graphics.height-112 )
  9826.     @obj_window.active = true  
  9827.   end
  9828.    
  9829.   #--------------------------------------------------------------------------#
  9830.   # * new-method :command_accept
  9831.   #--------------------------------------------------------------------------#
  9832.   def command_accept()
  9833.     if @obj_window.enabled?( @obj_window.index ) || @obj_window.obj.nil?()
  9834.       Sound.play_decision
  9835.       id = @obj_window.skill.nil?() ? 0 : @obj_window.skill.id
  9836.       @actor.set_skill_slot( @slot_window.index, id )
  9837.       @obj_window.selective_refresh() #draw_item( @obj_window.index )
  9838.       @slot_window.refresh()
  9839.     else
  9840.       Sound.play_buzzer()
  9841.     end  
  9842.   end
  9843.  
  9844. end  
  9845. # // Scene_SkillSet.new( actor, called_from, [return_index)]
  9846. Scene_SkillSet = YGG::Scenes::SkillSet
  9847.  
  9848. # // (YGG_HudSetting) // #
  9849. module YGG ; end ; module YGG::Handlers ; end
  9850.  
  9851. #==============================================================================#
  9852. # ** YGG::Handlers::HudWrapper
  9853. #==============================================================================#    
  9854. class YGG::Handlers::HudWrapper
  9855.  
  9856.   #--------------------------------------------------------------------------#
  9857.   # * Constant(s)
  9858.   #--------------------------------------------------------------------------#        
  9859.   DEFAULTS = {
  9860.     :hp        => 0,
  9861.     :maxhp     => 1,
  9862.     :mp        => 0,
  9863.     :maxmp     => 1,
  9864.     :shift     => 0,
  9865.     :maxshift  => 1,
  9866.     :charge    => 0,
  9867.     :maxcharge => 1,
  9868.     :exp       => 0,
  9869.     :maxexp    => 1,
  9870.   }
  9871.  
  9872.   POSITIONS = YGG::HUD_POSITION_PROCS
  9873.  
  9874.   DEFAULTS.keys.each { |key| define_method(key) { return @values[key] } }
  9875.  
  9876.   #--------------------------------------------------------------------------#
  9877.   # * Public Instance Variable(s)
  9878.   #--------------------------------------------------------------------------#    
  9879.   attr_reader :actor
  9880.   attr_accessor :need_refresh
  9881.  
  9882.   #--------------------------------------------------------------------------#
  9883.   # * new-method :initialize
  9884.   #--------------------------------------------------------------------------#
  9885.   def initialize()
  9886.     @values = {}
  9887.     @actor  = nil
  9888.     @need_refresh = false
  9889.     load_defaults()
  9890.   end
  9891.  
  9892.   #--------------------------------------------------------------------------#
  9893.   # * new-method :load_defaults
  9894.   #--------------------------------------------------------------------------#
  9895.   def refresh()
  9896.     @need_refresh = false
  9897.   end
  9898.  
  9899.   #--------------------------------------------------------------------------#
  9900.   # * new-method :load_defaults
  9901.   #--------------------------------------------------------------------------#
  9902.   def load_defaults()
  9903.     DEFAULTS.each_pair { |key, value| @values[key] = value }
  9904.   end
  9905.  
  9906.   #--------------------------------------------------------------------------#
  9907.   # * new-method :actor=
  9908.   #--------------------------------------------------------------------------#
  9909.   def actor=( new_actor )
  9910.     if new_actor != @actor ; @actor = new_actor ; update() ; end
  9911.   end
  9912.    
  9913.   #--------------------------------------------------------------------------#
  9914.   # * new-method :update
  9915.   #--------------------------------------------------------------------------#    
  9916.   def update()
  9917.     if @actor != $game_player.ygg_battler
  9918.       @actor = $game_player.ygg_battler ; @need_refresh = true
  9919.     end
  9920.     if @actor.nil?()
  9921.       @values[:hp]        = DEFAULTS[:hp]
  9922.       @values[:maxhp]     = DEFAULTS[:maxhp]
  9923.       @values[:mp]        = DEFAULTS[:mp]
  9924.       @values[:maxmp]     = DEFAULTS[:maxmp]
  9925.       @values[:charge]    = DEFAULTS[:charge]
  9926.       @values[:maxcharge] = DEFAULTS[:maxcharge]
  9927.       @values[:exp]       = DEFAULTS[:exp]
  9928.       @values[:maxexp]    = DEFAULTS[:maxexp]
  9929.     else  
  9930.       @values[:hp]        = @actor.hp
  9931.       @values[:maxhp]     = @actor.maxhp
  9932.       @values[:mp]        = @actor.mp
  9933.       @values[:maxmp]     = @actor.maxmp
  9934.       @values[:charge]    = @actor.cooldown
  9935.       @values[:maxcharge] = @actor.cooldown_max
  9936.       @values[:exp]       = @actor.level_exp
  9937.       @values[:maxexp]    = @actor.next_level_exp
  9938.     end  
  9939.     if shift_valid?()
  9940.       @values[:shift]     = $game_yggdrasil.shift_system.time
  9941.       @values[:maxshift]  = $game_yggdrasil.shift_system.cap
  9942.     else
  9943.       @values[:shift]     = DEFAULTS[:shift]
  9944.       @values[:maxshift]  = DEFAULTS[:maxshift]
  9945.     end  
  9946.   end
  9947.  
  9948.   #--------------------------------------------------------------------------#
  9949.   # * new-method :shift_valid?
  9950.   #--------------------------------------------------------------------------#    
  9951.   def shift_valid?()
  9952.     return ::YGG::USE_SHIFT_SYSTEM
  9953.   end
  9954.    
  9955.   #--------------------------------------------------------------------------#
  9956.   # * new-method :get_obj_xyz
  9957.   #--------------------------------------------------------------------------#
  9958.   def get_obj_xyz( *args )
  9959.     return POSITIONS[args[0]].call( *args.slice( 1, args.size ) )
  9960.   end  
  9961.  
  9962. if ::YGG::HUD_SWITCH.nil?() || ::YGG::HUD_SWITCH == 0
  9963.  
  9964.   #--------------------------------------------------------------------------#
  9965.   # * new-method :hud_visible?
  9966.   #--------------------------------------------------------------------------#  
  9967.   def visible?() ; return true ; end
  9968.  
  9969. else
  9970.  
  9971.   #--------------------------------------------------------------------------#
  9972.   # * new-method :hud_visible?
  9973.   #--------------------------------------------------------------------------#  
  9974.   def visible?()
  9975.     return $game_switches[::YGG::HUD_SWITCH]
  9976.   end
  9977.  
  9978. end
  9979.  
  9980. end  
  9981.  
  9982. #==============================================================================#
  9983. # ** YGG::Handlers::Hud
  9984. #==============================================================================#
  9985. class ::YGG::Handlers::Hud
  9986. #==============================================================================#
  9987. # ** SpriteMix
  9988. #==============================================================================#    
  9989.   module SpriteMix
  9990.   #--------------------------------------------------------------------------#
  9991.   # * Public Instance Variables
  9992.   #--------------------------------------------------------------------------#  
  9993.     attr_accessor :add_x, :add_y, :add_z
  9994.    
  9995.   #--------------------------------------------------------------------------#
  9996.   # * super-method :set_add_xyz
  9997.   #--------------------------------------------------------------------------#    
  9998.     def set_add_xyz( ax, ay, az )
  9999.       @add_x, @add_y, @add_z = ax, ay, az
  10000.     end
  10001.    
  10002.   end  
  10003. #==============================================================================#
  10004. # ** Sprite_Back
  10005. #==============================================================================#  
  10006.   class Sprite_Back < ::Sprite  
  10007.    
  10008.     include SpriteMix
  10009.    
  10010.   #--------------------------------------------------------------------------#
  10011.   # * super-method :initialize
  10012.   #--------------------------------------------------------------------------#      
  10013.     def initialize( viewport )
  10014.       @add_x, @add_y, @add_z = 0, 0, 0
  10015.       super( viewport )
  10016.     end
  10017.    
  10018.   end
  10019.  
  10020. #==============================================================================#
  10021. # ** Sprite_Icon
  10022. #==============================================================================#    
  10023.   class Sprite_Icon < ::Sprite
  10024.    
  10025.     include SpriteMix
  10026.    
  10027.   #--------------------------------------------------------------------------#
  10028.   # * Constant(s)
  10029.   #--------------------------------------------------------------------------#    
  10030.     ICON_SIZE = [24, 24]
  10031.    
  10032.   #--------------------------------------------------------------------------#
  10033.   # * Public Instance Variable(s)
  10034.   #--------------------------------------------------------------------------#  
  10035.     attr_reader :icon_index
  10036.     attr_accessor :active_effect
  10037.    
  10038.   #--------------------------------------------------------------------------#
  10039.   # * super-method :initialize
  10040.   #--------------------------------------------------------------------------#      
  10041.     def initialize( viewport=nil )
  10042.       @add_x, @add_y, @add_z = 0, 0, 0
  10043.       super( viewport )
  10044.       self.bitmap = Cache.system( "Iconset" )
  10045.       self.icon_index = 0
  10046.       @active_effect = "none"
  10047.     end
  10048.  
  10049.   #--------------------------------------------------------------------------#
  10050.   # * new-method :icon_index=
  10051.   #--------------------------------------------------------------------------#  
  10052.     def icon_index=( new_index )
  10053.       return if @icon_index == new_index
  10054.       self.src_rect.set(
  10055.        new_index % 16 * ICON_SIZE[0], new_index / 16 * ICON_SIZE[1],
  10056.        ICON_SIZE[0], ICON_SIZE[1] )
  10057.       @icon_index = new_index
  10058.     end
  10059.    
  10060.   #--------------------------------------------------------------------------#
  10061.   # * overwrite-method :update
  10062.   #--------------------------------------------------------------------------#    
  10063.     def update()
  10064.       case @active_effect
  10065.       when "fadeout"
  10066.         self.opacity -= 255 / 30.0
  10067.         @active_effect = "none" if self.opacity == 0
  10068.       when "fadein"  
  10069.         self.opacity += 255 / 30.0
  10070.         @active_effect = "none" if self.opacity == 255
  10071.       end  
  10072.     end
  10073.    
  10074.   end
  10075.  
  10076. #==============================================================================#
  10077. # ** Sprite_ValueBar
  10078. #==============================================================================#      
  10079.   class Sprite_ValueBar < ::Sprite
  10080.    
  10081.     include SpriteMix
  10082.    
  10083.   #--------------------------------------------------------------------------#
  10084.   # * Public Instance Variables
  10085.   #--------------------------------------------------------------------------#  
  10086.     attr_accessor :value, :max
  10087.    
  10088.   #--------------------------------------------------------------------------#
  10089.   # * super-method :initialize
  10090.   #--------------------------------------------------------------------------#    
  10091.     def initialize( viewport=nil )
  10092.       @add_x, @add_y, @add_z = 0, 0, 0
  10093.       super( viewport )
  10094.       @value = 0 ; @max = 1
  10095.     end
  10096.  
  10097.   #--------------------------------------------------------------------------#
  10098.   # * super-method :update
  10099.   #--------------------------------------------------------------------------#    
  10100.     def update()
  10101.       super()
  10102.       self.src_rect.width = self.bitmap.width * @value / [@max, 1].max unless self.bitmap.nil?()
  10103.     end  
  10104.    
  10105.   end
  10106.  
  10107. #==============================================================================#
  10108. # ** Sprite_TinyPortrait
  10109. #==============================================================================#      
  10110.   class Sprite_TinyPortrait < ::Sprite
  10111.    
  10112.   include SpriteMix
  10113.  
  10114.   #--------------------------------------------------------------------------#
  10115.   # * super-method :initialize
  10116.   #--------------------------------------------------------------------------#
  10117.     def initialize( viewport=nil )
  10118.       @add_x, @add_y, @add_z = 0, 0, 0
  10119.       super( viewport )
  10120.     end
  10121.    
  10122.   #--------------------------------------------------------------------------#
  10123.   # * new-method :refresh
  10124.   #--------------------------------------------------------------------------#  
  10125.     def refresh( character_name, character_index )
  10126.       self.bitmap = Cache.character( character_name )
  10127.       sign = character_name[/^[\!\$]./]
  10128.       if sign != nil and sign.include?('$')
  10129.         cw = bitmap.width / 3
  10130.         ch = bitmap.height / 4
  10131.       else
  10132.         cw = bitmap.width / 12
  10133.         ch = bitmap.height / 8
  10134.       end
  10135.       n = character_index
  10136.       self.src_rect.set( (n%4*3+1)*cw, (n/4*4)*ch, cw, ch )
  10137.     end
  10138.    
  10139.   end
  10140.  
  10141.   #--------------------------------------------------------------------------#
  10142.   # * Public Instance Variables
  10143.   #--------------------------------------------------------------------------#  
  10144.   attr_reader :viewport
  10145.   attr_reader :x, :y, :z
  10146.   attr_reader :visible
  10147.  
  10148.   #--------------------------------------------------------------------------#
  10149.   # * new-method :initialize
  10150.   #--------------------------------------------------------------------------#  
  10151.   def initialize( x=0, y=0, z=0 )
  10152.     @visible = true
  10153.     @disposed = false
  10154.     @x, @y, @z = x, y, z
  10155.     create_all()
  10156.     refresh()
  10157.   end
  10158.  
  10159.   #--------------------------------------------------------------------------#
  10160.   # * new-method :create_all
  10161.   #--------------------------------------------------------------------------#
  10162.   def create_all()
  10163.     @skill_setsize = 5#@actor.skill_slot_size
  10164.     @item_setsize  = 5#@actor.item_slot_size
  10165.     create_skills()
  10166.     create_items()
  10167.     @back_sprite = Sprite_Back.new( self.viewport )
  10168.     @back_sprite.bitmap = Cache.system( "1x6Hud2" )
  10169.     @hp_sprite   = Sprite_ValueBar.new( self.viewport )
  10170.     @hp_sprite.bitmap = Cache.system( "1x6Hud_HpBar" )
  10171.     @mp_sprite   = Sprite_ValueBar.new( self.viewport )
  10172.     @mp_sprite.bitmap = Cache.system( "1x6Hud_MpBar" )
  10173.     # // Extended
  10174.     @exp_sprite   = Sprite_ValueBar.new( self.viewport )
  10175.     @exp_sprite.bitmap = Cache.system( "1x6Hud_ExpBar" )
  10176.     @shift_sprite   = Sprite_ValueBar.new( self.viewport )
  10177.     @shift_sprite.bitmap = Cache.system( "1x6Hud_ShiftBar" )
  10178.     @charge_sprite   = Sprite_ValueBar.new( self.viewport )
  10179.     @charge_sprite.bitmap = Cache.system( "1x6Hud_ChargeBar" )
  10180.     @portrait_sprite = Sprite_TinyPortrait.new( self.viewport )
  10181.     @sprites = [@back_sprite, @hp_sprite, @mp_sprite, @portrait_sprite]
  10182.     @sprites+= [@exp_sprite, @shift_sprite, @charge_sprite]
  10183.     @__hud_wrapper = $game_yggdrasil.hud
  10184.   end
  10185.  
  10186.   #--------------------------------------------------------------------------#
  10187.   # * new-method :disposed?
  10188.   #--------------------------------------------------------------------------#
  10189.   def disposed?() ; return @disposed ; end
  10190.    
  10191.   #--------------------------------------------------------------------------#
  10192.   # * new-method :dispose
  10193.   #--------------------------------------------------------------------------#
  10194.   def dispose()
  10195.     each_sprite { |s| s.dispose() }
  10196.     @back_sprite = nil ; @hp_sprite = nil ; @mp_sprite = nil
  10197.     @skills = nil ; @items = nil
  10198.     @disposed = true
  10199.   end
  10200.  
  10201.   #--------------------------------------------------------------------------#
  10202.   # * new-method :refresh
  10203.   #--------------------------------------------------------------------------#
  10204.   def refresh()
  10205.     @portrait_sprite.refresh(
  10206.       @__hud_wrapper.actor.nil?() ? "" : @__hud_wrapper.actor.character_name,
  10207.       @__hud_wrapper.actor.nil?() ?  0 : @__hud_wrapper.actor.character_index )
  10208.     refresh_add_xyz()
  10209.     refresh_xyz()
  10210.   end
  10211.  
  10212.   #--------------------------------------------------------------------------#
  10213.   # * new-method :create_skills
  10214.   #--------------------------------------------------------------------------#  
  10215.   def create_skills()
  10216.     @skills = Array.new( @skill_setsize ).map! { Sprite_Icon.new( self.viewport ) }
  10217.     for i in 0...@skills.size
  10218.       @skills[i].bush_opacity = 48
  10219.     end  
  10220.   end
  10221.  
  10222.   #--------------------------------------------------------------------------#
  10223.   # * new-method :create_items
  10224.   #--------------------------------------------------------------------------#  
  10225.   def create_items()
  10226.     @items = Array.new( @item_setsize ).map! { Sprite_Icon.new( self.viewport ) }
  10227.     for i in 0...@items.size
  10228.       @items[i].bush_opacity = 48
  10229.     end
  10230.   end
  10231.  
  10232.   #--------------------------------------------------------------------------#
  10233.   # * new-method :each_sprite
  10234.   #--------------------------------------------------------------------------#  
  10235.   def each_sprite()
  10236.     (@sprites+@skills.to_a+@items.to_a).each { |s| yield s unless s.nil?() }
  10237.   end
  10238.  
  10239.   #--------------------------------------------------------------------------#
  10240.   # * new-method :x=
  10241.   #--------------------------------------------------------------------------#  
  10242.   def x=( new_x )
  10243.     @x = new_x ; refresh_x()
  10244.   end
  10245.  
  10246.   #--------------------------------------------------------------------------#
  10247.   # * new-method :visible=
  10248.   #--------------------------------------------------------------------------#  
  10249.   def visible=( new_visible )
  10250.     @visible = new_visible ; refresh_visible()
  10251.   end
  10252.  
  10253.   #--------------------------------------------------------------------------#
  10254.   # * new-method :y=
  10255.   #--------------------------------------------------------------------------#  
  10256.   def y=( new_y )
  10257.     @y = new_y ; refresh_y()
  10258.   end
  10259.  
  10260.   #--------------------------------------------------------------------------#
  10261.   # * new-method :z=
  10262.   #--------------------------------------------------------------------------#  
  10263.   def z=( new_z )
  10264.     @z = new_z ; refresh_z()
  10265.   end
  10266.  
  10267.   #--------------------------------------------------------------------------#
  10268.   # * new-method :viewport=
  10269.   #--------------------------------------------------------------------------#  
  10270.   def viewport=( new_viewport )
  10271.     @viewport = new_viewport
  10272.     each_sprite { |s| s.viewport = @viewport }
  10273.   end
  10274.  
  10275.   #--------------------------------------------------------------------------#
  10276.   # * new-method :refresh_x
  10277.   #--------------------------------------------------------------------------#
  10278.   def refresh_x()
  10279.     each_sprite { |s| s.x = @x + s.add_x }
  10280.   end
  10281.  
  10282.   #--------------------------------------------------------------------------#
  10283.   # * new-method :refresh_y
  10284.   #--------------------------------------------------------------------------#
  10285.   def refresh_y()
  10286.     each_sprite { |s| s.y = @y + s.add_y }
  10287.   end
  10288.  
  10289.   #--------------------------------------------------------------------------#
  10290.   # * new-method :refresh_z
  10291.   #--------------------------------------------------------------------------#
  10292.   def refresh_z()
  10293.     each_sprite { |s| s.z = @z + s.add_z }
  10294.   end
  10295.  
  10296.   #--------------------------------------------------------------------------#
  10297.   # * new-method :refresh_add_xyz
  10298.   #--------------------------------------------------------------------------#
  10299.   def refresh_add_xyz()
  10300.     @back_sprite.set_add_xyz(     *@__hud_wrapper.get_obj_xyz( :back ) )
  10301.     @hp_sprite.set_add_xyz(       *@__hud_wrapper.get_obj_xyz( :hp_bar ) )
  10302.     @mp_sprite.set_add_xyz(       *@__hud_wrapper.get_obj_xyz( :mp_bar ) )
  10303.     @portrait_sprite.set_add_xyz( *@__hud_wrapper.get_obj_xyz( :sprite ) )
  10304.     @exp_sprite.set_add_xyz(      *@__hud_wrapper.get_obj_xyz( :exp_bar ) )
  10305.     @shift_sprite.set_add_xyz(    *@__hud_wrapper.get_obj_xyz( :shift_bar ) )
  10306.     @charge_sprite.set_add_xyz(   *@__hud_wrapper.get_obj_xyz( :charge_bar ) )
  10307.     for i in 0...@skills.size
  10308.       @skills[i].set_add_xyz(     *@__hud_wrapper.get_obj_xyz( :skill_icon, i ) )
  10309.     end  
  10310.     for i in 0...@items.size
  10311.       @items[i].set_add_xyz(      *@__hud_wrapper.get_obj_xyz( :item_icon, i ) )
  10312.     end
  10313.   end
  10314.  
  10315.   #--------------------------------------------------------------------------#
  10316.   # * new-method :refresh_xyz
  10317.   #--------------------------------------------------------------------------#
  10318.   def refresh_xyz()
  10319.     each_sprite { |s| s.x, s.y, s.z = @x + s.add_x, @y + s.add_y, @z + s.add_z }
  10320.   end
  10321.  
  10322.   #--------------------------------------------------------------------------#
  10323.   # * new-method :refresh_visible
  10324.   #--------------------------------------------------------------------------#
  10325.   def refresh_visible()
  10326.     each_sprite { |s| s.visible = @visible }
  10327.   end
  10328.  
  10329.   #--------------------------------------------------------------------------#
  10330.   # * new-method :update
  10331.   #--------------------------------------------------------------------------#
  10332.   def update()
  10333.     if @__hud_wrapper.need_refresh
  10334.       @__hud_wrapper.refresh() ; refresh()
  10335.     end  
  10336.     @hp_sprite.value, @hp_sprite.max = @__hud_wrapper.hp, @__hud_wrapper.maxhp
  10337.     @mp_sprite.value, @mp_sprite.max = @__hud_wrapper.mp, @__hud_wrapper.maxmp
  10338.     @exp_sprite.value, @exp_sprite.max = @__hud_wrapper.exp, @__hud_wrapper.maxexp
  10339.     @shift_sprite.value, @shift_sprite.max = @__hud_wrapper.shift, @__hud_wrapper.maxshift
  10340.     @charge_sprite.value, @charge_sprite.max = @__hud_wrapper.charge, @__hud_wrapper.maxcharge
  10341.     @hp_sprite.update()
  10342.     @mp_sprite.update()
  10343.     @exp_sprite.update()
  10344.     @shift_sprite.update()
  10345.     @charge_sprite.update()
  10346.     unless @__hud_wrapper.actor.nil?()
  10347.       for i in 0...@skills.size
  10348.         obj = @__hud_wrapper.actor.skill_slot( i )
  10349.         hnd = @__hud_wrapper.actor.get_skill_handle( obj.nil?() ? 0 : obj.id )
  10350.         sprite = @skills[i]
  10351.         sprite.tone.gray = 255.0 * hnd.time.to_f / [hnd.cap, 1].max
  10352.         sprite.bush_depth = sprite.height * hnd.time.to_f / [hnd.cap, 1].max
  10353.         icon_index = obj.nil?() ? 0 : obj.icon_index
  10354.         if sprite.icon_index != icon_index
  10355.           if sprite.active_effect == "none" && sprite.opacity == 0
  10356.             sprite.icon_index = icon_index
  10357.             sprite.active_effect = "fadein"
  10358.           elsif sprite.active_effect == "none" && sprite.opacity > 0
  10359.             sprite.opacity = 0 if sprite.icon_index == 0
  10360.             sprite.active_effect = "fadeout"
  10361.           end  
  10362.         end  
  10363.         sprite.update()
  10364.       end
  10365.       for i in 0...@items.size
  10366.         obj = @__hud_wrapper.actor.item_slot( i )
  10367.         hnd = @__hud_wrapper.actor.get_item_handle( obj.nil?() ? 0 : obj.id )
  10368.         sprite = @items[i]
  10369.         sprite.tone.gray = 255.0 * hnd.time.to_f / [hnd.cap, 1].max
  10370.         sprite.bush_depth = sprite.height * hnd.time.to_f / [hnd.cap, 1].max
  10371.         icon_index = obj.nil?() ? 0 : obj.icon_index
  10372.         if sprite.icon_index != icon_index
  10373.           if sprite.active_effect == "none" && sprite.opacity == 0
  10374.             sprite.icon_index = icon_index
  10375.             sprite.active_effect = "fadein"
  10376.           elsif sprite.active_effect == "none" && sprite.opacity > 0
  10377.             sprite.opacity = 0 if sprite.icon_index == 0
  10378.             sprite.active_effect = "fadeout"
  10379.           end  
  10380.         end  
  10381.         sprite.update()
  10382.       end  
  10383.     end  
  10384.   end
  10385.  
  10386. end
  10387.  
  10388. #==============================================================================#
  10389. # ** YGG::System
  10390. #==============================================================================#
  10391. class YGG::System
  10392.  
  10393. if YGG::DROPS_WINDOW_SWITCH.nil?() || YGG::DROPS_WINDOW_SWITCH == 0
  10394.  
  10395.   #--------------------------------------------------------------------------#
  10396.   # * new-method :drops_window_visible?
  10397.   #--------------------------------------------------------------------------#
  10398.   def drops_window_visible?() ; return true ; end
  10399.  
  10400. else
  10401.  
  10402.   #--------------------------------------------------------------------------#
  10403.   # * new-method :drops_window_visible?
  10404.   #--------------------------------------------------------------------------#
  10405.   def drops_window_visible?()
  10406.     return $game_switches[::YGG::DROPS_WINDOW_SWITCH]
  10407.   end
  10408.  
  10409. end
  10410.  
  10411. end
  10412.  
  10413. if YGG::USE_HUD
  10414. #==============================================================================#
  10415. # ** Scene_Map
  10416. #==============================================================================#
  10417. class Scene_Map < Scene_Base
  10418.  
  10419.   #--------------------------------------------------------------------------#
  10420.   # * Class Variable(s)
  10421.   #--------------------------------------------------------------------------#  
  10422.   @@__temp = 0
  10423.  
  10424.   #--------------------------------------------------------------------------#
  10425.   # * alias-method :start
  10426.   #--------------------------------------------------------------------------#
  10427.   alias :ygg1x6_hud_start :start unless $@
  10428.   def start( *args, &block )
  10429.     ygg1x6_hud_start( *args, &block )
  10430.     create_ygg_hud()
  10431.   end
  10432.  
  10433.   #--------------------------------------------------------------------------#
  10434.   # * new-method :create_ygg_hud
  10435.   #--------------------------------------------------------------------------#
  10436.   def create_ygg_hud()
  10437.     @ygg_hud = ::YGG::Handlers::Hud.new( *$game_yggdrasil.hud.get_obj_xyz( :main ) )
  10438.     update_ygg_hud()
  10439.   end
  10440.  
  10441.   #--------------------------------------------------------------------------#
  10442.   # * alias-method :update
  10443.   #--------------------------------------------------------------------------#
  10444.   alias :ygg1x6_hud_update :update unless $@
  10445.   def update( *args, &block )
  10446.     ygg1x6_hud_update( *args, &block )
  10447.     update_ygg_hud()
  10448.   end
  10449.  
  10450.   #--------------------------------------------------------------------------#
  10451.   # * new-method :update_ygg_hud
  10452.   #--------------------------------------------------------------------------#
  10453.   def update_ygg_hud()
  10454.     @@__temp = $game_yggdrasil.hud.visible?()
  10455.     @ygg_hud.visible = @@__temp if @ygg_hud.visible != @@__temp
  10456.     @ygg_hud.update()
  10457.   end
  10458.  
  10459.   #--------------------------------------------------------------------------#
  10460.   # * alias-method :terminate
  10461.   #--------------------------------------------------------------------------#
  10462.   alias :ygg1x6_hud_terminate :terminate unless $@
  10463.   def terminate( *args, &block )
  10464.     ygg1x6_hud_terminate( *args, &block )
  10465.     @ygg_hud.dispose() unless @ygg_hud.nil?() ; @ygg_hud = nil
  10466.   end
  10467.  
  10468. end  
  10469.  
  10470. end
  10471.  
  10472. #==============================================================================#
  10473. # ** YGG::System
  10474. #==============================================================================#
  10475. class YGG::System
  10476.  
  10477.   #--------------------------------------------------------------------------#
  10478.   # * new-method :start_target_selection
  10479.   #--------------------------------------------------------------------------#  
  10480.   def start_target_selection( target_count=1, targets=[] )
  10481.     return [] if targets.empty?()
  10482.     darken_sprite = Sprite.new()
  10483.     darken_sprite.bitmap = Cache.picture( "BlackSheet" )
  10484.     darken_sprite.opacity = 96
  10485.     target_cursor = Sprite.new()
  10486.     target_cursor.bitmap = Cache.picture( "YGG2_Cursor" )
  10487.     target_cursor.ox, target_cursor.oy = 16, 64
  10488.     hold_cursors = [] ; target_index = 0
  10489.     targets.sort!() { |a, b| a.screen_x <=> b.screen_x }
  10490.     target = targets[target_index]
  10491.     selected_targets = []
  10492.     target_cursor.x, target_cursor.y = target.screen_x, target.screen_y unless target.nil?()
  10493.     loop do
  10494.       Graphics.update()
  10495.       Input.update()
  10496.       if Input.trigger?( Input::RIGHT ) || Input.trigger?( Input::DOWN )
  10497.         Sound.play_cursor()
  10498.         target_index = (target_index + 1) % [targets.size, 1].max
  10499.         target = targets[target_index]
  10500.       elsif Input.trigger?( Input::LEFT ) || Input.trigger?( Input::UP )
  10501.         Sound.play_cursor()
  10502.         target_index = (target_index - 1) % [targets.size, 1].max
  10503.         target = targets[target_index]
  10504.       end
  10505.       if Input.trigger?( Input::C )
  10506.         Sound.play_decision()
  10507.         selected_targets << target
  10508.         if selected_targets.size == target_count
  10509.           break
  10510.         else
  10511.           sp = Sprite.new()
  10512.           sp.bitmap = Cache.picture( "YGG2_Cursor" )
  10513.           sp.ox, sp.oy = 16, 64
  10514.           sp.zoom_x, sp.zoom_y = 0.75, 0.75
  10515.           sp.x, sp.y = target.screen_x, target.screen_y
  10516.           hold_cursors << sp
  10517.         end  
  10518.       elsif Input.trigger?( Input::B )
  10519.         Sound.play_cancel()
  10520.         selected_targets.pop()
  10521.         sp = hold_cursors.pop() ; sp.dispose() unless sp.nil?()
  10522.         break if selected_targets.empty?()
  10523.       end  
  10524.       unless target.nil?()
  10525.         if target.screen_x > target_cursor.x
  10526.           target_cursor.x = [target_cursor.x + Graphics.width/30.0, target.screen_x].min
  10527.         elsif target.screen_x < target_cursor.x  
  10528.           target_cursor.x = [target_cursor.x - Graphics.width/30.0, target.screen_x].max
  10529.         end  
  10530.         if target.screen_y > target_cursor.y
  10531.           target_cursor.y = [target_cursor.y + Graphics.height/30.0, target.screen_y].min
  10532.         elsif target.screen_y < target_cursor.y
  10533.           target_cursor.y = [target_cursor.y - Graphics.height/30.0, target.screen_y].max
  10534.         end
  10535.       end  
  10536.     end  
  10537.     hold_cursors.each { |s| s.dispose unless s.nil?() } ; hold_cursors = nil
  10538.     target_cursor.dispose() ; darken_sprite.dispose()
  10539.     Graphics.update()
  10540.     Input.update() # // Double trigger fix
  10541.     return selected_targets
  10542.   end
  10543.  
  10544.   #--------------------------------------------------------------------------#
  10545.   # * new-method :start_xy_selection
  10546.   #--------------------------------------------------------------------------#  
  10547.   def start_xy_selection()
  10548.   end
  10549.  
  10550.   #--------------------------------------------------------------------------#
  10551.   # * new-method :gameover_process
  10552.   #--------------------------------------------------------------------------#  
  10553.   def gameover_process()
  10554.     $game_temp.next_scene = "gameover"
  10555.   end
  10556.  
  10557.   #--------------------------------------------------------------------------#
  10558.   # * new-method :__on_load
  10559.   #--------------------------------------------------------------------------#
  10560.   def __on_load()
  10561.     self.flush_battlers()
  10562.     $game_player.ygg_unregister()
  10563.     $game_player.refresh_handles()
  10564.     $game_map.events.values.each { |ev|
  10565.       ev.refresh_handles() ;
  10566.       ev.ygg_unregister() ; ev.update()
  10567.     }
  10568.     $game_player.ygg_register()
  10569.     self.projectiles.each { |pro|
  10570.       pro.refresh_handles()
  10571.       pro.__reload() }
  10572.   end
  10573.  
  10574. end  
  10575.  
  10576. #=*==========================================================================*=#
  10577. # ** END OF FILE
  10578. #=*==========================================================================*=#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement