Want more features on Pastebin? Sign Up, it's FREE!
Guest

Yggdrasil 1.6c

By: IceDragon200 on Mar 17th, 2012  |  syntax: Ruby  |  size: 411.90 KB  |  views: 251  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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].e