Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Yggdrasil 1.6b

By: IceDragon200 on Dec 2nd, 2011  |  syntax: Ruby  |  size: 399.72 KB  |  views: 268  |  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/02/2011
  9. # ** Version       : 1.6b
  10. #------------------------------------------------------------------------------#
  11. #==============================================================================#
  12. # ** INTRODUCTION
  13. #------------------------------------------------------------------------------#
  14. # So hello there, thank you for looking at Yggdrasil 1.6 (or 1x6)
  15. # This is NOT an update for the 1.x series really.
  16. # This was meant to be Yggdrasil 2, but I scrapped that.
  17. # Anyway 1.6 removes the "Attack" system that was present in the older versions.
  18. # Also the Action system as been directly implemented into it.
  19. # All nessecary scripts are included (Such as Hud, Item, Skills etc..etc)
  20. # In addition, the engine has a built in Stat Cache (!!!)
  21. # Overall this version was meant to be a performance update/ungrade.
  22. #
  23. #------------------------------------------------------------------------------#
  24. #==============================================================================#
  25. # ** FEATURES
  26. #------------------------------------------------------------------------------#
  27. #  *I'll fill this when I feel like it*
  28. #------------------------------------------------------------------------------#
  29. #==============================================================================#
  30. # ** RECOMMENDED
  31. #------------------------------------------------------------------------------#
  32. #
  33. # IRME - Icy Random Map Encounters
  34. #
  35. # YEM Keyboard Input (Has been merged with the current Yggdrasil Version)
  36. #
  37. #------------------------------------------------------------------------------#
  38. #==============================================================================#
  39. # ** CHANGE LOG
  40. #------------------------------------------------------------------------------#
  41. #
  42. # (MM/DD/YYYY)
  43. #  10/11/2010 - BETA  Started Script
  44. #  11/09/2010 - V1.0  Finished Script
  45. #  11/15/2010 - V1.1  A whole lot of stuff happened
  46. #                     Several bug fixes, new features (Too many to list)
  47. #  ??/??/???? - V1.2  Several Improvements and BugFixes
  48. #  12/17/2010 - V1.3  AI improvements, AI can now use skills
  49. #  02/19/2011 - V1.4  So many changes, I tottaly forgot,
  50. #                     Main things though, Targetting has been changed slightly
  51. #                     Some fixes (Which I don't remember) have been done.
  52. #  07/01/2011 - V1.59 Started Revamping entire code.
  53. #  10/14/2011 - V1.6  Finished 1.6
  54. #  11/30/2011 - V1.6a Fixed 3 bugs, added 5 new feature:
  55. #                     BUGS:
  56. #                       Stats didn't change when equipment was changed.
  57. #                       Disabling the Shift System would cause an error.
  58. #                       Disabling the level up window would cause an error
  59. #                     NEW:
  60. #                       Added pickup sounds:
  61. #                         <pksfx: filename, vol, pit>
  62. #                       Added popup enabling and disabling (For event comments)
  63. #                         <enable pop>
  64. #                         <disable pop> or <no pop>
  65. #                       Added Bar Hiding (For event comments)
  66. #                         <hide hp bar> ; <show hp bar>
  67. #                         <hide mp bar> ; <show mp bar>
  68. #                       Added changable attack animation for enemies:
  69. #                         <atk animation id: n>
  70. #                       Added extended drops for enemies:
  71. #                         <drop item n>
  72. #                         item_id: n
  73. #                         weapon_id: n
  74. #                         armor_id: n
  75. #                         prob: n
  76. #                         </drop item>
  77. # 12/02/2011 - V1.6b  Added 4 new features, fixed 1 bug, housekeeping
  78. #                     BUGS:
  79. #                       Event Bars would hang in top right hand corner
  80. #                     NEW:  
  81. #                       Wrote Hud Wrapper, added hud position procs
  82. #                       Added Random class (for whatever reason)
  83. #                       Added gold randomization for enemies. (BAM)
  84. #                         <gold variation: n>
  85. #                       Added Guarding: (How long will the guard action take)
  86. #                         action_guard
  87. #                         ["GUARD", [frames]]
  88. #                         guard: frames
  89. #                         While Guarding all other actions are blocked.
  90. #
  91. #                     CLEAN:
  92. #                       Rewrote Introduction
  93. #                       Removed unused constants
  94. #                      
  95. #------------------------------------------------------------------------------#
  96. #==============================================================================#
  97. # ** KNOWN ISSUES
  98. #------------------------------------------------------------------------------#
  99. #  Becareful when using:
  100. #  <action n>
  101. #  </action>
  102. #  It is very sensitive (even whitespace can destroy your action) D:
  103. #  If you aren't confident stick to the <action n= string> method
  104. #
  105. #  Due to the size of the script, any error that occurs in the script MAY
  106. #  not be located on the correct line.
  107. #  I will split the script (AGAIN) later, to fix this problem.
  108. #
  109. #------------------------------------------------------------------------------#
  110. #==============================================================================#  
  111. # ** YGG
  112. #==============================================================================#
  113. module YGG
  114. #==============================================================================#
  115. #                           Start Customization
  116. #------------------------------------------------------------------------------#
  117. #==============================================================================#
  118.   #--------------------------------------------------------------------------#
  119.   # * ABS_SYSTEM_SWITCH
  120.   #--------------------------------------------------------------------------#
  121.   # This is the switch which controls Yggdrasil
  122.   # If you set this constant to nil, Yggdrasil will always be active.
  123.   #--------------------------------------------------------------------------#
  124.     ABS_SYSTEM_SWITCH = 2
  125.  
  126.   #--------------------------------------------------------------------------#
  127.   # * ITEM_MAP
  128.   #--------------------------------------------------------------------------#
  129.   # Currently this is not used for 1.6, but its still nice to have it
  130.   # just in case XD
  131.   #--------------------------------------------------------------------------#
  132.     ITEM_MAP = 2
  133.        
  134.   #--------------------------------------------------------------------------#
  135.   # * DONT_SCAN_EVENTS
  136.   #--------------------------------------------------------------------------#
  137.   # Because events can either be allies or enemies, this tends to be a
  138.   # bit slow for each event, you can disable event scanning,
  139.   # so the events can only target the player.
  140.   #--------------------------------------------------------------------------#  
  141.     DONT_SCAN_EVENTS = true
  142.  
  143.   #--------------------------------------------------------------------------#
  144.   # * FULL_FIELD_SCAN
  145.   #--------------------------------------------------------------------------#
  146.   # *Warning this may cause Lag*
  147.   # Events will scan all around them for targets
  148.   # That means infront, behind, and beside
  149.   #--------------------------------------------------------------------------#  
  150.     FULL_FIELD_SCAN = true
  151.    
  152.   #--------------------------------------------------------------------------#
  153.   # * DIE_WAIT_TIME
  154.   #--------------------------------------------------------------------------#
  155.   # Time in frames for events to die.
  156.   # Default is 30
  157.   #--------------------------------------------------------------------------#  
  158.     DIE_WAIT_TIME = 30
  159.  
  160.   #--------------------------------------------------------------------------#
  161.   # * DRAW_RANGES
  162.   #--------------------------------------------------------------------------#
  163.   # Should the ranges for attacks/skills/etc be drawn?
  164.   #--------------------------------------------------------------------------#  
  165.     DRAW_RANGES = false
  166.    
  167.   #--------------------------------------------------------------------------#
  168.   # * ALL_DEAD_GAMEOVER
  169.   #--------------------------------------------------------------------------#
  170.   # >.> Quite Obviously you will set this to true..
  171.   # I don't even know why I made a constant for it anyway...
  172.   # When this is true, if all party members are dead, the Gameover will
  173.   # be triggered.
  174.   #--------------------------------------------------------------------------#  
  175.     ALL_DEAD_GAMEOVER = true  
  176.            
  177.   #--------------------------------------------------------------------------#
  178.   # * TOTAL_WILD_ANIMS
  179.   #--------------------------------------------------------------------------#
  180.   # In addition to each characters own animations, Yggdrasil has a wild anim
  181.   # set, where these animations are stand alone and can be triggered from
  182.   # anywhere on the map.
  183.   # Note greater numbers means more anims that can be shown at a time
  184.   # This will increase the number of updates and may result in Lagging.
  185.   # I reccomend keeping it around 8 to 16
  186.   #--------------------------------------------------------------------------#  
  187.     TOTAL_WILD_ANIMS = 16
  188.  
  189.   #--------------------------------------------------------------------------#
  190.   # * STATE_TURN_COUNTER
  191.   #--------------------------------------------------------------------------#
  192.   # This is used for state turns, in other words how many frames make a turn
  193.   # Default is 240
  194.   #--------------------------------------------------------------------------#
  195.     STATE_TURN_COUNTER = 480 #240
  196.  
  197.   #--------------------------------------------------------------------------#
  198.   # * SLIP_DAMAGE_FREQUENCY
  199.   #--------------------------------------------------------------------------#
  200.   # How often should slip damage occur
  201.   #--------------------------------------------------------------------------#
  202.     SLIP_DAMAGE_FREQUENCY = 5
  203.    
  204.   #--------------------------------------------------------------------------#
  205.   # * ACTION_BUTTONS
  206.   #--------------------------------------------------------------------------#
  207.   # Yggdrasil 1x6 uses unlimited buttons instead of 3 ( 1.0..1.5 series )
  208.   #--------------------------------------------------------------------------#
  209.     # // Jump to (YGG_PlayerInputConfig)
  210.    
  211.   #--------------------------------------------------------------------------#
  212.   # * TEXT_POP
  213.   #--------------------------------------------------------------------------#
  214.   # As of 1.6 TEXT POP is now built into the main script.
  215.   #--------------------------------------------------------------------------#  
  216.     USE_TEXT_POP = true
  217.     # Copied from BEM So you can recycle
  218.     POPUP_SETTINGS = {
  219.       :hp_dmg     => "%s",        # SprintF for HP damage.
  220.       :hp_heal    => "+%s",       # SprintF for HP healing.
  221.       :mp_dmg     => "%s SP",     # SprintF for MP damage.
  222.       :mp_heal    => "+%s SP",    # SprintF for MP healing.
  223.       :critical   => "CRITICAL!", # Text display for critical hit.
  224.       :missed     => "MISS",      # Text display for missed attack.
  225.       :evaded     => "EVADE!",    # Text display for evaded attack.
  226.       :nulled     => "NULLED",    # Text display for nulled attack.
  227.       :add_state  => "+%s",       # SprintF for added states.
  228.       :rem_state  => "-%s",       # SprintF for removed states.
  229.      
  230.       :exp_pop    => "Exp: %s",   # SprintF for Exp Pops.
  231.       :lvl_pop    => "Level %s",  # SprintF for Level Pops.
  232.       :guard      => "Guard!!!",
  233.     } # Do Not Remove
  234.    
  235.   #--------------------------------------------------------------------------#
  236.   # * POPUP_RULES
  237.   #--------------------------------------------------------------------------#
  238.   # Text Properties
  239.   # "Bold"      = Pop will be drawn Bold
  240.   # "Italic"    = Pop will be drawn with Italics
  241.   # "Shadow"    = Pop will be drawn with Shadows
  242.   # "No Bold"   = Pop will not be drawn Bold
  243.   # "No Italic" = Pop will not be drawn with Italics
  244.   # "No Shadow" = Pop will not be drawn with Shadow
  245.   #
  246.   # Font names is an array of font names (If the first one isn't present on
  247.   # the system, the next one is used, if non are present from the array
  248.   # the default is used)
  249.   #--------------------------------------------------------------------------#
  250.     COLOR_SETS = {#Ally                      Damage
  251.       :hp_no_dmg => [Color.new(180, 205, 180), Color.new(180, 205, 180)],
  252.       :hp_dmg    => [Color.new(128, 128, 240), Color.new(240, 128, 128)],
  253.       :hp_heal   => [Color.new(144, 238, 144), Color.new(198, 238, 144)],
  254.    
  255.       :mp_no_dmg => [Color.new(180, 180, 205), Color.new(180, 180, 205)],
  256.       :mp_dmg    => [Color.new(199, 21 , 112), Color.new(199, 21 , 112)],
  257.       :mp_heal   => [Color.new(173, 216, 230), Color.new(173, 216, 230)],
  258.     }
  259.    
  260.     POPUP_RULES = {
  261.     #                        
  262.    #"something"=> [fontsize, [color, color], [text_properties], [font_names]]
  263.       "HP_NO_DMG"=> [16, COLOR_SETS[:hp_no_dmg]  , [           ], [          ]],
  264.       "HP_DMG"   => [21, COLOR_SETS[:hp_dmg]     , [           ], [          ]],
  265.       "HP_HEAL"  => [21, COLOR_SETS[:hp_heal]    , ["Italic"   ], [          ]],
  266.    
  267.       "MP_NO_DMG"=> [16, COLOR_SETS[:mp_no_dmg]  , [           ], [          ]],
  268.       "MP_DMG"   => [21, COLOR_SETS[:mp_dmg]     , [           ], [          ]],
  269.       "MP_HEAL"  => [21, COLOR_SETS[:mp_heal]    , ["Italic"   ], [          ]],
  270.    
  271.       "MISSED"   => [19, Color.new(176, 196, 222), ["Italic"   ], [          ]],
  272.       "EVADED"   => [19, Color.new(198, 198, 198), ["Italic"   ], [          ]],
  273.       "NULLED"   => [19, Color.new(255, 160, 122), ["Bold"     ], [          ]],
  274.    
  275.       "ADD_STATE"=> [26, Color.new(255, 255, 224), ["No Shadow"], [          ]],
  276.       "REM_STATE"=> [26, Color.new(250, 250, 210), ["No Shadow"], [          ]],
  277.    
  278.       "EXP_POP"  => [18, Color.new(255, 215, 0  ), [           ], [          ]],
  279.       "LVL_POP"  => [21, Color.new(180, 215, 255), [           ], [          ]],
  280.    
  281.       "CRITICAL" => [24, Color.new(220, 20 , 60 ), ["Bold"     ], [          ]],
  282.      
  283.       "GUARD"    => [21, Color.new(198, 198, 202), ["Bold"     ], [          ]],
  284.     } # Do Not Remove
  285.    
  286.   #--------------------------------------------------------------------------#
  287.   # * CRITICAL_FONTSIZE_ADD
  288.   #--------------------------------------------------------------------------#
  289.   # When a critcial is done how much should be added to the Damage pop's
  290.   # font size
  291.   #--------------------------------------------------------------------------#
  292.     CRITICAL_FONTSIZE_ADD = 4
  293.    
  294.   #--------------------------------------------------------------------------#
  295.   # * SHOW_CRITICAL
  296.   #--------------------------------------------------------------------------#
  297.   # Should the "Critical" text be drawn when it is done?
  298.   #--------------------------------------------------------------------------#  
  299.     SHOW_CRITICAL = true
  300.  
  301.   #--------------------------------------------------------------------------#
  302.   # * SHOW_GUARD
  303.   #--------------------------------------------------------------------------#
  304.   # Should the "Guard" text be drawn when it is done?
  305.   #--------------------------------------------------------------------------#  
  306.     SHOW_GUARD = true
  307.    
  308.   #--------------------------------------------------------------------------#
  309.   # * LEVEL_UP_ALERT
  310.   #--------------------------------------------------------------------------#
  311.   # Should something happen on level up?
  312.   #--------------------------------------------------------------------------#
  313.     LEVEL_UP_ALERT = false
  314.    
  315.   #--------------------------------------------------------------------------#
  316.   # * ANIM_ON_LEVEL
  317.   #--------------------------------------------------------------------------#
  318.   # Animation used for level up. If set to 0, no anim is played
  319.   # This is disabled if LEVEL_UP_ALERT = false
  320.   #--------------------------------------------------------------------------#  
  321.     ANIM_ON_LEVEL = 0 # 257
  322.    
  323.   #--------------------------------------------------------------------------#
  324.   # * POP_LEVEL_UP
  325.   #--------------------------------------------------------------------------#
  326.   # Should a text pop with Level Up be used?
  327.   # This is disabled if LEVEL_UP_ALERT = false
  328.   #--------------------------------------------------------------------------#  
  329.     POP_LEVEL_UP = false
  330.  
  331.   #--------------------------------------------------------------------------#
  332.   # * POP_EXP
  333.   #--------------------------------------------------------------------------#
  334.   # Should a text pop be used for EXP?
  335.   #--------------------------------------------------------------------------#  
  336.     POP_EXP = true
  337.  
  338.   #--------------------------------------------------------------------------#
  339.   # * EXP_GAINING_METHOD
  340.   #--------------------------------------------------------------------------#
  341.   # 0 Dead   - When the target is defeated the character gains EXP
  342.   # 1 Per Hit- On every successful hit, exp is gained
  343.   #--------------------------------------------------------------------------#  
  344.     EXP_GAINING_METHOD = 0
  345.    
  346.   #--------------------------------------------------------------------------#
  347.   # * EXP_PER_HIT_FORMULA
  348.   #--------------------------------------------------------------------------#
  349.   # If you have no idea about scripting, don't touch this.
  350.   #--------------------------------------------------------------------------#  
  351.     EXP_PER_HIT_FORMULA = Proc.new { |damage, atker, defer| defer.exp * damage / defer.maxhp}
  352.    
  353.   #--------------------------------------------------------------------------#
  354.   # * EXP_SAHRE_METHOD
  355.   #--------------------------------------------------------------------------#
  356.   # 0 Active Member Only - Only the active member gains EXP
  357.   # 1 All Members Equal  - All members gain EXP
  358.   # 2 All Members Split  - The EXP is split amongst all Members
  359.   #--------------------------------------------------------------------------#  
  360.     # 0 Only Active Member, 1 All Members Equal, 2 All Members Spilt
  361.     EXP_SAHRE_METHOD = 1
  362.  
  363.   #--------------------------------------------------------------------------#
  364.   # * GOLD_DROP_ICON
  365.   #--------------------------------------------------------------------------#
  366.   # This is the icon that is used for gold drops
  367.   #--------------------------------------------------------------------------#
  368.     GOLD_DROP_ICON = 147
  369.    
  370.   #--------------------------------------------------------------------------#
  371.   # * DROP_SCATTER_DISTANCE
  372.   #--------------------------------------------------------------------------#
  373.   # This is how far a drop can be placed from its origin
  374.   #--------------------------------------------------------------------------#    
  375.     DROP_SCATTER_DISTANCE = 3
  376.    
  377.   #--------------------------------------------------------------------------#
  378.   # * ITEM_FADE_TIME
  379.   #--------------------------------------------------------------------------#
  380.   # How long, in frames until an item drop fades out
  381.   #--------------------------------------------------------------------------#    
  382.     ITEM_FADE_TIME = 480
  383.    
  384.   #--------------------------------------------------------------------------#
  385.   # * GOLD_FADE_TIME
  386.   #--------------------------------------------------------------------------#
  387.   # How long, in frames until an gold drop fades out
  388.   #--------------------------------------------------------------------------#    
  389.     GOLD_FADE_TIME = 640
  390.    
  391.   #--------------------------------------------------------------------------#
  392.   # * DROP_FADE_THRESHOLD
  393.   #--------------------------------------------------------------------------#
  394.   # When this frame is reached the drop will begin to fade out
  395.   #--------------------------------------------------------------------------#  
  396.     DROP_FADE_THRESHOLD = 60
  397.   #--------------------------------------------------------------------------#
  398.   # * USE_SHIFT_SYSTEM (YGG_ShiftSystem)
  399.   #--------------------------------------------------------------------------#
  400.   # Unlike its predecessors, 1.6 has a built-in Shift System
  401.   # This simply allows the quick changing between characters
  402.   #--------------------------------------------------------------------------#
  403.     USE_SHIFT_SYSTEM = false
  404.  
  405.   #--------------------------------------------------------------------------#
  406.   # * HUD
  407.   #--------------------------------------------------------------------------#
  408.   # Options for HUD
  409.   #--------------------------------------------------------------------------#
  410.     USE_HUD = true
  411.     HUD_SWITCH = 1
  412.    
  413.     HUD_POSITION_PROCS = {
  414.     # :symbol     => Proc.new { [   x,   y,   z] },
  415.       :main       => Proc.new { [ -12, Graphics.height-48, 1000] },
  416.       :back       => Proc.new { [   0,   0,   0] },
  417.       :hp_bar     => Proc.new { [ 232,  12,   3] },
  418.       :mp_bar     => Proc.new { [ 232,  28,   3] },
  419.       :exp_bar    => Proc.new { [  40,   9,   3] },
  420.       :shift_bar  => Proc.new { [ 384,   9,   3] },
  421.       :charge_bar => Proc.new { [ 472,   9,   3] },
  422.       :sprite     => Proc.new { [ 196,   8,   3] },
  423.       :skill_icon => Proc.new { |i| [  36 + i * 32,  16,   3] },
  424.       :item_icon  => Proc.new { |i| [ 376 + i * 32,  16,   3] }
  425.     }
  426.  
  427.   #--------------------------------------------------------------------------#
  428.   # * HP/MP Bars
  429.   #--------------------------------------------------------------------------#
  430.   # Options for HP/MP Bars
  431.   #--------------------------------------------------------------------------#
  432.     USE_STAT_BARS = true # // Use Bars?
  433.     USE_HPBAR     = true  
  434.     USE_MPBAR     = false
  435.  
  436.   #--------------------------------------------------------------------------#
  437.   # * DROPS_WINDOW (YGG_DropsWindow)
  438.   #--------------------------------------------------------------------------#
  439.   # Options for drops window
  440.   #--------------------------------------------------------------------------#
  441.     USE_DROPS_WINDOW    = true
  442.     # //                  [ x, y, z, width ]
  443.     DROPS_WINDOW_SIZE   = [ 544-164, 416-72, 200, 160 ]
  444.     DROPS_WINDOW_SWITCH = 1 # // Currently Linked with Hud
  445.    
  446.   #--------------------------------------------------------------------------#
  447.   # * DROPS_SFX (Special Thanks to Nicke (Niclas) for the idea)
  448.   #--------------------------------------------------------------------------#
  449.   # Options for SFX when a drop is taken up
  450.   # (You can override this using: <pickup sfx: filename, vol, pitch>)
  451.   #--------------------------------------------------------------------------#
  452.   # // Set any of these to nil to disable it                              // #
  453.     SOUND_MONEY = RPG::SE.new( "SYS-Shop002", 60, 100 )    # // Sound effect for acquiring money.
  454.     SOUND_ITEM  = RPG::SE.new( "XINFX-Pickup02", 50, 100 ) # // Sound effect for acquiring items.
  455.    
  456.   #--------------------------------------------------------------------------#
  457.   # * USE_LEVEL_UP_WINDOW (YGG_LevelUpWindow)
  458.   #--------------------------------------------------------------------------#
  459.   # 0 - No Window (OFF), 1 - Small Strip, 2 - Stop Frame Full Info
  460.   #--------------------------------------------------------------------------#
  461.     USE_LEVEL_UP_WINDOW = 0
  462.    
  463.   #--------------------------------------------------------------------------#
  464.   # * FULL_INTEGRATION
  465.   #--------------------------------------------------------------------------#
  466.   # Allow Yggdrasil to overwrite many core methods, to optimize is performance
  467.   #--------------------------------------------------------------------------#
  468.   # // Enabling this may cause normal battle operations to malfunction
  469.   # // This option is reccommend for a strict YGG game
  470.   #--------------------------------------------------------------------------#
  471.     FULL_INTEGRATION = true
  472.    
  473. # oo========================================================================oo #    
  474. # // Actions \\                                                             // #
  475. # oo========================================================================oo #
  476.   ACTION_LIST = {}
  477. # oo========================================================================oo #    
  478. # // Default Actions \\ DO NOT MESS WITH THESE                              // #
  479. # oo========================================================================oo #
  480.  
  481. # oo========================================================================oo #    
  482. # // Normal Attack # For Default
  483.   ACTION_LIST["NULL_ACTION"] = []
  484.  
  485.   ACTION_LIST["NORMAL_ATTACK"] = [
  486.     ["RANGE"        , ["ADD", 0, 1]                   ],
  487.     ["TARGET"       , ["RANGE"]                       ],
  488.     ["SUBTARGET"    , ["ALLIES"]                      ],
  489.     ["ANIMATION"    , ["ATTACK", "POS", "WILD", 0, 1] ],
  490.     ["ATTACK EFFECT", ["USER", "TARGETS"]             ]
  491.   ]
  492.  
  493.   ACTION_LIST["GUARD_ACTION"] = [
  494.     ["ANIMATION"    , [85, "USER", "WILD"]            ],
  495.     ["GUARD"    , [3]                                 ], # // Set Guard for 3 frames
  496.   ]
  497.  
  498.   ACTION_LIST["ESCAPE_ACTION"] = [
  499.   ]
  500.  
  501.   ACTION_LIST["WAIT_ACTION"] = [
  502.     ["PARENT WAIT"  , [20]                            ]
  503.   ]
  504.  
  505. # oo========================================================================oo #    
  506. # // Normal Attack # For Enemies  
  507.   ACTION_LIST["NULL_ACTION_EN"] = [] # // Unused D:
  508.  
  509.   ACTION_LIST["NORMAL_ATTACK_EN"] = [
  510.     ["RANGE"        , ["ADD", 0, 1]                   ],
  511.     ["TARGET"       , ["RANGE"]                       ],
  512.     ["SUBTARGET"    , ["ALLIES"]                      ],
  513.     ["ANIMATION"    , ["ATTACK", "POS", "WILD", 0, 1] ],
  514.     ["ATTACK EFFECT", ["USER", "TARGETS"]             ]
  515.   ]
  516.  
  517.   ACTION_LIST["GUARD_ACTION_EN"] = [
  518.     ["GUARD"    , [3]                                 ], # // Set Guard for 3 frames
  519.   ]
  520.  
  521.   ACTION_LIST["ESCAPE_ACTION_EN"] = [
  522.   ]
  523.  
  524.   ACTION_LIST["WAIT_ACTION_EN"] = [
  525.     ["PARENT WAIT"  , [20]                            ]
  526.   ]
  527. # oo========================================================================oo #    
  528. # // Skill Scopes                                                           // #
  529.   # // None Scope Skill
  530.   ACTION_LIST["NORMAL_OBJ0"] = [
  531.     ["TARGET"      , ["USER"]                      ],
  532.     ["ANIMATION"   , ["OBJ", "POS", "WILD", 0, 0]  ],
  533.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  534.   ]
  535.  
  536.   # // User Skill
  537.   ACTION_LIST["NORMAL_OBJ1"] = [
  538.     ["TARGET"      , ["USER"]                      ],
  539.     ["ANIMATION"   , ["OBJ", "POS", "WILD", 0, 0]  ],
  540.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  541.   ]
  542.  
  543.   # // Enemy Skill Single
  544.   ACTION_LIST["NORMAL_OBJ2_1"] = [
  545.     ["RANGE"       , ["ADD", 0, 1]                 ],
  546.     ["TARGET"      , ["RANGE"]                     ],
  547.     ["SUBTARGET"   , ["ALLIES"]                    ],
  548.     ["ANIMATION"   , ["OBJ", "POS", "WILD", 0, 1]  ],
  549.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  550.   ]
  551.  
  552.   # // Enemy Skill Dual
  553.   ACTION_LIST["NORMAL_OBJ2_2"] = [
  554.     ["RANGE"       , ["ADD", 0, 1]                 ],
  555.     ["TARGET"      , ["RANGE"]                     ],
  556.     ["SUBTARGET"   , ["ALLIES"]                    ],
  557.     ["ANIMATION"   , ["OBJ", "POS", "WILD", 0, 1]  ],
  558.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  559.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  560.   ]
  561.  
  562.   # // Enemy Skill Triple
  563.   ACTION_LIST["NORMAL_OBJ2_3"] = [
  564.     ["RANGE"       , ["ADD", 0, 1]                 ],
  565.     ["TARGET"      , ["RANGE"]                     ],
  566.     ["SUBTARGET"   , ["ALLIES"]                    ],
  567.     ["ANIMATION"   , ["OBJ", "POS", "WILD", 0, 1]  ],
  568.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  569.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  570.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  571.   ]
  572.  
  573.   # // Enemy Skill Random 1
  574.   ACTION_LIST["NORMAL_OBJ2_R1"] = [
  575.     ["TARGET"      , ["SCREEN"]                    ],
  576.     ["SUBTARGET"   , ["ALLIES"]                    ],
  577.     ["TARGET"      , ["RANDTARGET"]                ],
  578.     ["ANIMATION"   , ["OBJ", "TARGET", "WILD"]     ],
  579.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  580.   ]
  581.  
  582.   # // Enemy Skill Random 2
  583.   ACTION_LIST["NORMAL_OBJ2_R2"] = [
  584.     ["ACTION", ["NORMAL_OBJ2_R1"] ],
  585.     ["ACTION", ["NORMAL_OBJ2_R1"] ]
  586.   ]
  587.  
  588.   # // Enemy Skill Random 3
  589.   ACTION_LIST["NORMAL_OBJ2_R3"] = [
  590.     ["ACTION", ["NORMAL_OBJ2_R1"] ],
  591.     ["ACTION", ["NORMAL_OBJ2_R1"] ],
  592.     ["ACTION", ["NORMAL_OBJ2_R1"] ]
  593.   ]
  594.  
  595.   # // Ally Skill
  596.   ACTION_LIST["NORMAL_OBJ3_1"] = [
  597.     ["RANGE"       , ["ADD", 0, 1]                 ],
  598.     ["TARGET"      , ["RANGE"]                     ],
  599.     ["SUBTARGET"   , ["ENEMIES"]                   ],
  600.     ["ANIMATION"   , ["OBJ", "POS", "WILD", 0, 1]  ],
  601.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  602.   ]
  603.  
  604.   # // Ally Skill Dual
  605.   ACTION_LIST["NORMAL_OBJ3_2"] = [
  606.     ["RANGE"       , ["ADD", 0, 1]                 ],
  607.     ["TARGET"      , ["RANGE"]                     ],
  608.     ["SUBTARGET"   , ["ENEMIES"]                   ],
  609.     ["ANIMATION"   , ["OBJ", "POS", "WILD", 0, 1]  ],
  610.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  611.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  612.   ]
  613.  
  614.   # // Ally Skill Triple
  615.   ACTION_LIST["NORMAL_OBJ3_3"] = [
  616.     ["RANGE"       , ["ADD", 0, 1]                 ],
  617.     ["TARGET"      , ["RANGE"]                     ],
  618.     ["SUBTARGET"   , ["ENEMIES"]                   ],
  619.     ["ANIMATION"   , ["OBJ", "POS", "WILD", 0, 1]  ],
  620.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  621.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  622.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  623.   ]
  624.  
  625.   # // Ally Skill Random 1
  626.   ACTION_LIST["NORMAL_OBJ3_R1"] = [
  627.     ["TARGET"      , ["SCREEN"]                    ],
  628.     ["SUBTARGET"   , ["ENEMIES"]                   ],
  629.     ["TARGET"      , ["RANDTARGET"]                ],
  630.     ["ANIMATION"   , ["OBJ", "TARGET", "WILD"]     ],
  631.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  632.   ]
  633.  
  634.   # // Ally Obj Random 2
  635.   ACTION_LIST["NORMAL_OBJ3_R2"] = [
  636.     ["ACTION", ["NORMAL_OBJ3_R1"] ],
  637.     ["ACTION", ["NORMAL_OBJ3_R1"] ],
  638.   ]
  639.  
  640.   # // Enemy Obj Random 3
  641.   ACTION_LIST["NORMAL_OBJ3_R3"] = [
  642.     ["ACTION", ["NORMAL_OBJ3_R1"] ],
  643.     ["ACTION", ["NORMAL_OBJ3_R1"] ],
  644.     ["ACTION", ["NORMAL_OBJ3_R1"] ],
  645.   ]
  646.  
  647.   # // All Enemies
  648.   ACTION_LIST["NORMAL_OBJ4"] = [
  649.     ["TARGET"      , ["SCREEN"]                    ],
  650.     ["SUBTARGET"   , ["ALLIES"]                    ],
  651.     ["ANIMATION"   , ["OBJ", "TARGETS", "WILD"]    ],
  652.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  653.   ]
  654.  
  655.   # // All Allies
  656.   ACTION_LIST["NORMAL_OBJ5"] = [
  657.     ["TARGET"      , ["SCREEN"]                    ],
  658.     ["SUBTARGET"   , ["ENEMIES"]                   ],
  659.     ["ANIMATION"   , ["OBJ", "TARGETS", "WILD"]    ],
  660.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  661.   ]
  662.  
  663.   # // Target Enemy Skill Single
  664.   ACTION_LIST["NORMAL_OBJ2_T1"] = [
  665.     ["TARGET"      , ["SCREEN"]                    ],
  666.     ["SUBTARGET"   , ["ALLIES"]                    ],
  667.     ["TARGET SELECT",[1, "TARGETS"]                ],
  668.     ["ANIMATION"   , ["OBJ", "TARGETS", "WILD"]    ],
  669.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  670.   ]
  671.  
  672.   # // Target Enemy Skill Dual
  673.   ACTION_LIST["NORMAL_OBJ2_T2"] = [
  674.     ["TARGET"      , ["SCREEN"]                    ],
  675.     ["SUBTARGET"   , ["ALLIES"]                    ],
  676.     ["TARGET SELECT",[1, "TARGETS"]                ],
  677.     ["ANIMATION"   , ["OBJ", "TARGETS", "WILD"]    ],
  678.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  679.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  680.   ]
  681.  
  682.   # // Target Enemy Skill Triple
  683.   ACTION_LIST["NORMAL_OBJ2_T3"] = [
  684.     ["TARGET"      , ["SCREEN"]                    ],
  685.     ["SUBTARGET"   , ["ALLIES"]                    ],
  686.     ["TARGET SELECT",[1, "TARGETS"]                ],
  687.     ["ANIMATION"   , ["OBJ", "TARGETS", "WILD"]    ],
  688.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  689.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  690.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  691.   ]
  692.  
  693.   # // Target Ally Skill
  694.   ACTION_LIST["NORMAL_OBJ3_T1"] = [
  695.     ["TARGET"      , ["SCREEN"]                    ],
  696.     ["SUBTARGET"   , ["ENEMIES"]                   ],
  697.     ["TARGET SELECT",[1, "TARGETS"]                ],
  698.     ["ANIMATION"   , ["OBJ", "TARGETS", "WILD"]    ],
  699.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  700.   ]
  701.  
  702.   # // Target Ally Skill Dual
  703.   ACTION_LIST["NORMAL_OBJ3_T2"] = [
  704.     ["TARGET"      , ["SCREEN"]                    ],
  705.     ["SUBTARGET"   , ["ENEMIES"]                   ],
  706.     ["TARGET SELECT",[1, "TARGETS"]                ],
  707.     ["ANIMATION"   , ["OBJ", "TARGETS", "WILD"]    ],
  708.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  709.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  710.   ]
  711.  
  712.   # // Target Ally Skill Triple
  713.   ACTION_LIST["NORMAL_OBJ3_T3"] = [
  714.     ["TARGET"      , ["SCREEN"]                    ],
  715.     ["SUBTARGET"   , ["ENEMIES"]                   ],
  716.     ["TARGET SELECT",[1, "TARGETS"]                ],
  717.     ["ANIMATION"   , ["OBJ", "TARGETS", "WILD"]    ],
  718.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  719.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  720.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  721.   ]
  722.  
  723.   # // Breath all targets in range
  724.   ACTION_LIST["BREATH_ATTACK1"] = [
  725.     ["RANGE"       , ["CREATE", 3, 0, 3, 2]        ], # // Point Range downward
  726.     ["TARGET"      , ["RANGE"]                     ], # // Get all targets within range
  727.     ["ANIMATION"   , ["OBJ", "POS", 0, 1]          ], # // Show animation infront
  728.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ], # // Object Damage
  729.   ]
  730.  
  731. # oo========================================================================oo #    
  732. # \\ End Default Actions //                                                 // #
  733. # oo========================================================================oo #
  734. #==============================================================================#
  735. #                           End Customization
  736. #------------------------------------------------------------------------------#
  737. #==============================================================================#  
  738. end
  739. #==============================================================================#
  740. # ** YGG # // Forward Declarations
  741. #==============================================================================#
  742. module YGG
  743. #==============================================================================#
  744. # ** Handlers
  745. #==============================================================================#
  746.   module Handlers   ; end
  747. #==============================================================================#
  748. # ** Containers
  749. #==============================================================================#    
  750.   module Containers ; end
  751. #==============================================================================#
  752. # ** MixIns
  753. #==============================================================================#    
  754.   module MixIns     ; end
  755. #==============================================================================#
  756. # ** Objects
  757. #==============================================================================#        
  758.   module Objects    ; end      
  759. #==============================================================================#
  760. # ** Scenes
  761. #==============================================================================#            
  762.   module Scenes     ; end  
  763. #==============================================================================#
  764. # ** Sprites
  765. #==============================================================================#        
  766.   module Sprites    ; end  
  767. #==============================================================================#
  768. # ** REGEXP
  769. #==============================================================================#            
  770.   module REGEXP     ; end
  771. #==============================================================================#
  772. # ** Windows
  773. #==============================================================================#                
  774.   module Windows    ; end  
  775. #==============================================================================#
  776. # ** Pos
  777. #==============================================================================#                
  778.   class Pos ; end
  779. #==============================================================================#
  780. # ** Handlers::Screen
  781. #==============================================================================#    
  782.   class Handlers::Screen < Pos ; end
  783. #==============================================================================#
  784. # ** Objects::Projectiles
  785. #==============================================================================#      
  786.   module Objects::Projectiles ; end
  787. #==============================================================================#
  788. # ** Random
  789. #==============================================================================#
  790.   module Random
  791.    
  792.   #--------------------------------------------------------------------------#
  793.   # * new-method :min_max
  794.   #--------------------------------------------------------------------------#      
  795.     def self.min_max( min, max )
  796.       return min + rand( max - min )
  797.     end
  798.    
  799.   #--------------------------------------------------------------------------#
  800.   # * new-method :variation
  801.   #--------------------------------------------------------------------------#        
  802.     def self.variation( value, percent )
  803.       new_value = rand(Integer(value * percent / 100.0))
  804.       new_value = value + (rand(2) == 0 ? new_value : -new_value)
  805.       return new_value
  806.     end
  807.    
  808.   end
  809. end    
  810.  
  811. #==============================================================================#  
  812. # ** Input # // DONT MESS WITH THIS
  813. #==============================================================================#
  814. module Input
  815.   #--------------------------------------------------------------------------#
  816.   # * Constants - Created by OriginalWij and Yanfly
  817.   #--------------------------------------------------------------------------#
  818.   LETTERS = {}        
  819.   LETTERS['A'] = 65; LETTERS['B'] = 66; LETTERS['C'] = 67; LETTERS['D'] = 68
  820.   LETTERS['E'] = 69; LETTERS['F'] = 70; LETTERS['G'] = 71; LETTERS['H'] = 72
  821.   LETTERS['I'] = 73; LETTERS['J'] = 74; LETTERS['K'] = 75; LETTERS['L'] = 76
  822.   LETTERS['M'] = 77; LETTERS['N'] = 78; LETTERS['O'] = 79; LETTERS['P'] = 80
  823.   LETTERS['Q'] = 81; LETTERS['R'] = 82; LETTERS['S'] = 83; LETTERS['T'] = 84
  824.   LETTERS['U'] = 85; LETTERS['V'] = 86; LETTERS['W'] = 87; LETTERS['X'] = 88
  825.   LETTERS['Y'] = 89; LETTERS['Z'] = 90
  826.   NUMBERS = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57]
  827.   NUMPAD = [96, 97, 98, 99, 100, 101, 102, 103, 104, 105]
  828.   BACK   = 138; ENTER  = 143; SPACE  = 32;  SCOLON = 186; ESC    = 157
  829.   QUOTE  = 222; EQUALS = 187; COMMA  = 188; USCORE = 189; PERIOD = 190
  830.   SLASH  = 191; LBRACE = 219; RBRACE = 221; BSLASH = 220; TILDE  = 192
  831.   F10    = 121; F11    = 122; CAPS   = 20;  NMUL   = 106; NPLUS  = 107
  832.   NSEP   = 108; NMINUS = 109; NDECI  = 110; NDIV   = 111; Extras =
  833.   [USCORE, EQUALS, LBRACE, RBRACE, BSLASH, SCOLON, QUOTE, COMMA, PERIOD, SLASH,
  834.    NMUL, NPLUS, NSEP, NMINUS, NDECI, NDIV]
  835. end
  836.  
  837. #==============================================================================#
  838. # ** YGG::MixIns::Player (YGG_PlayerInputConfig)
  839. #==============================================================================#
  840. module YGG::MixIns::Player
  841.  
  842.   #--------------------------------------------------------------------------#
  843.   # * new-method :get_obj_actions
  844.   #--------------------------------------------------------------------------#  
  845.   def get_obj_actions( obj, id )
  846.     return [],[] if obj.nil?()
  847.     return obj.ygg_actions[id].to_a(), obj.ygg_pre_actions[id].to_a()
  848.   end
  849.  
  850.   #--------------------------------------------------------------------------#
  851.   # * new-method :ygg_attack_input
  852.   #--------------------------------------------------------------------------#
  853.   def ygg_attack_input()
  854.     #return unless ygg_can_attack?()
  855.     return if $game_map.interpreter.running?()
  856.     return if ygg_battler.nil?()
  857.     if @guard_time > 0
  858.       @guard_time += 1 if Input.press?( Input::LETTERS["D"] )
  859.       return
  860.     end  
  861.     return if @action_handle.busy?()
  862.     acthand_ret = ygg_attack_input1()              # // ASD Input
  863.     acthand_ret = ygg_attack_input2( acthand_ret ) # // Skill Input 1..5
  864.     ygg_attack_input3( acthand_ret )               # // Item Input 6..9 and 0
  865.   end
  866.  
  867.   #--------------------------------------------------------------------------#
  868.   # * new-method :ygg_attack_input1
  869.   #--------------------------------------------------------------------------#
  870.   def ygg_attack_input1()
  871.     act, pact = nil, nil
  872.     obj = nil
  873.     if Input.trigger?( Input::LETTERS["A"] )
  874.       return 0 unless ygg_battler.ygg_can_attack?()
  875.       obj = ygg_battler.weapons[0]
  876.       act, pact = *get_obj_actions( obj, 1 )
  877.     elsif Input.trigger?( Input::LETTERS["S"] ) && ygg_battler.two_swords_style  
  878.       return 0 unless ygg_battler.ygg_can_attack?()
  879.       obj = ygg_battler.weapons[1]
  880.       act, pact = *get_obj_actions( obj, 1 )
  881.     elsif Input.press?( Input::LETTERS["D"] ) && !ygg_battler.two_swords_style  
  882.       return 0 unless ygg_battler.ygg_can_attack?()
  883.       obj = ygg_battler.armors[0]
  884.       act, pact = *get_obj_actions( obj, 0 )
  885.     end  
  886.     return 0 if act.nil?() || pact.nil?()
  887.     return 0 if act.empty?() && pact.empty?()
  888.     if pact.empty?()
  889.       @action_handle.setup( act )
  890.     else  
  891.       @action_handle.list_stack << act
  892.       @action_handle.setup( pact )
  893.     end  
  894.     @action_handle.execute( self )
  895.     ygg_battler.cooldown += obj.user_charge_cap
  896.     return 1
  897.   end
  898.  
  899.   #--------------------------------------------------------------------------#
  900.   # * new-method :ygg_attack_input2
  901.   #--------------------------------------------------------------------------#
  902.   def ygg_attack_input2( acthand_ret )
  903.     for i in 1..5
  904.       act, pact, obj = nil, nil, nil
  905.       if Input.trigger?( Input::NUMBERS[i] )
  906.         slot_id = i-1
  907.         obj = ygg_battler.skill_slot( slot_id )
  908.         next unless ygg_battler.ygg_skill_can_use?( obj )
  909.         act, pact = *get_obj_actions( obj, 0 )
  910.       end
  911.       next if act.nil?() || pact.nil?() || obj.nil?()
  912.       next if act.empty?() && pact.empty?()
  913.       next unless skill_can_use?( obj )
  914.       if pact.empty?()
  915.         hnd = ::YGG::Handlers::Action.new( self, [] ) ; hnd.setup( act )
  916.         hnd.execute( self, [], { :skill_id => obj.id } )
  917.         @free_act_handles << hnd
  918.       else  
  919.         next if acthand_ret == 1
  920.         @action_handle.list_stack << act
  921.         @action_handle.setup( pact )
  922.         @action_handle.execute( self, [], { :skill_id => obj.id } )
  923.         acthand_ret = 1
  924.       end  
  925.       ygg_battler.get_skill_handle( obj.id ).reset_time()
  926.       ygg_battler.cooldown += obj.user_charge_cap
  927.       ygg_battler.ygg_use_skill( obj )
  928.     end  
  929.     return acthand_ret
  930.   end
  931.  
  932.   #--------------------------------------------------------------------------#
  933.   # * new-method :ygg_attack_input3
  934.   #--------------------------------------------------------------------------#
  935.   def ygg_attack_input3( acthand_ret )
  936.     for i in (6..9).to_a+[0]
  937.       act, pact, obj = nil, nil, nil
  938.       if Input.trigger?( Input::NUMBERS[i] )
  939.         slot_id = i==0 ? 10-6 : i-6
  940.         obj = ygg_battler.item_slot( slot_id )
  941.         next unless ygg_battler.ygg_item_can_use?( obj )
  942.         act, pact = *get_obj_actions( obj, 0 )
  943.       end
  944.       next if act.nil?() || pact.nil?() || obj.nil?()
  945.       next if act.empty?() && pact.empty?()
  946.       next unless item_can_use?( obj )
  947.       if pact.empty?()
  948.         hnd = ::YGG::Handlers::Action.new( self, [] ) ; hnd.setup( act )
  949.         hnd.execute( self, [], { :item_id => obj.id } )
  950.         @free_act_handles << hnd
  951.       else  
  952.         next if acthand_ret == 1
  953.         @action_handle.list_stack << act
  954.         @action_handle.setup( pact )
  955.         @action_handle.execute( self, [], { :item_id => obj.id } )
  956.         acthand_ret = 1
  957.       end  
  958.       ygg_battler.get_item_handle( obj.id ).reset_time()
  959.       ygg_battler.cooldown += obj.user_charge_cap
  960.       ygg_battler.ygg_use_item( obj )
  961.     end  
  962.     return acthand_ret
  963.   end
  964.  
  965.   #--------------------------------------------------------------------------#
  966.   # * new-method :skill_can_use?
  967.   #--------------------------------------------------------------------------#  
  968.   def skill_can_use?( obj )
  969.     return false if obj.nil?()
  970.     return false if ygg_battler.nil?()
  971.     return ygg_battler.skill_can_use?( obj )
  972.   end
  973.  
  974.   #--------------------------------------------------------------------------#
  975.   # * new-method :item_can_use?
  976.   #--------------------------------------------------------------------------#  
  977.   def item_can_use?( obj )
  978.     return false if obj.nil?()
  979.     return false if ygg_battler.nil?()
  980.     return $game_party.item_can_use?( obj )
  981.   end
  982.  
  983. end  
  984.  
  985. # // (YGG_AIEngine_Setup)
  986. #==============================================================================#
  987. # ** YGG::Handlers::AIEngines
  988. #==============================================================================#
  989. module YGG::Handlers::AIEngines
  990. #==============================================================================#
  991. # ** Base (Forward Declaration)
  992. #==============================================================================#  
  993.   class Base           ; end
  994. #==============================================================================#
  995. # ** Default (Forward Declaration)
  996. #==============================================================================#      
  997.   class Default < Base ; end
  998. #==============================================================================#
  999. # ** Guard (Forward Declaration)
  1000. #==============================================================================#      
  1001.   class Guard < Base   ; end
  1002. #==============================================================================#
  1003. # ** Wall (Forward Declaration)
  1004. #==============================================================================#      
  1005.   class Wall < Base    ; end  
  1006. #==============================================================================#
  1007. # ** ImmortalVarBoss (Forward Declaration)
  1008. #==============================================================================#          
  1009.   class ImmortalVarBoss < Base  ; end
  1010.    
  1011.   #--------------------------------------------------------------------------#
  1012.   # * ENGINES
  1013.   #--------------------------------------------------------------------------#
  1014.   # This hash contains references to the Engine's Class, NOT AN INSTANCE
  1015.   # of the class.
  1016.   #--------------------------------------------------------------------------#  
  1017.   ENGINES = {
  1018.     # // Default AI that uses the Game_Battler's make_action
  1019.     # // to attack
  1020.     "default" => Default,         # // Default (Make Action) AI
  1021.     # // An AI that only attacks/moves/acts when an enemy enters its field
  1022.     "guard"   => Guard,           # // Specialized AI
  1023.     # // An AI that does nothing, but its HP slowly depletes
  1024.     "wall"    => Wall,            
  1025.     # // An invincible boss, thats hp is controlled by a variable
  1026.     # // This is a 2nd level subclass
  1027.     "ivboss"  => ImmortalVarBoss,
  1028.   }
  1029.  
  1030. end
  1031.  
  1032. #==============================================================================#
  1033. # ** YGG::AI_ENGINES
  1034. #==============================================================================#
  1035. YGG::AI_ENGINES = YGG::Handlers::AIEngines::ENGINES
  1036.  
  1037. #==============================================================================#
  1038. # ** YGG::Handlers::AIEngines::Base
  1039. #==============================================================================#
  1040. class YGG::Handlers::AIEngines::Base
  1041.  
  1042.   #--------------------------------------------------------------------------#
  1043.   # * Public Instance Variables
  1044.   #--------------------------------------------------------------------------#  
  1045.   attr_accessor :parent
  1046.  
  1047.   #--------------------------------------------------------------------------#
  1048.   # * new-method :initialize
  1049.   #--------------------------------------------------------------------------#  
  1050.   def initialize( parent, setup_data={} )
  1051.     @parent = parent
  1052.     @update_time = 0
  1053.   end
  1054.  
  1055.   #--------------------------------------------------------------------------#
  1056.   # * new-method :pause
  1057.   #--------------------------------------------------------------------------#  
  1058.   def pause()
  1059.     @paused = true
  1060.   end
  1061.  
  1062.   #--------------------------------------------------------------------------#
  1063.   # * new-method :unpause
  1064.   #--------------------------------------------------------------------------#  
  1065.   def unpause()
  1066.     @paused = false
  1067.   end
  1068.  
  1069.   #--------------------------------------------------------------------------#
  1070.   # * new-method :update
  1071.   #--------------------------------------------------------------------------#  
  1072.   def update()
  1073.     return if @paused
  1074.     return if @parent.guard_time > 0
  1075.     @update_time = [@update_time - 1, 0].max
  1076.     ai_update() if @update_time == 0
  1077.   end
  1078.  
  1079. end  
  1080.  
  1081. #==============================================================================#
  1082. # ** YGG::Handlers::AIEngines::Default
  1083. #==============================================================================#
  1084. class YGG::Handlers::AIEngines::Default
  1085.  
  1086.   #--------------------------------------------------------------------------#
  1087.   # * super-method :initialize
  1088.   #--------------------------------------------------------------------------#
  1089.   def initialize( parent, setup_data={} )
  1090.     super( parent, setup_data )
  1091.     @update_time_cap = (setup_data["update_time"] || 90).to_i
  1092.   end
  1093.  
  1094.   #--------------------------------------------------------------------------#
  1095.   # * new-method :ai_update
  1096.   #--------------------------------------------------------------------------#  
  1097.   def ai_update()
  1098.     #return # // Remove this later
  1099.     return if @parent.ygg_battler.cooldown > 0
  1100.     return if @parent.ygg_battler.nil?()  
  1101.     @parent.ygg_battler.make_action()
  1102.     case @parent.ygg_battler.action.kind
  1103.     when 0 # // Basic
  1104.       case @parent.ygg_battler.action.basic
  1105.       when 0 # // Attack      
  1106.         @update_time = @update_time_cap / 3
  1107.         t = @parent.get_targets_nearby( 1, @parent.ygg_correct_target( "ENEMY" ) )
  1108.         return @update_time = @update_time_cap / 4 if t[0].nil?()
  1109.         @parent.turn_to_coord( t[0].x, t[0].y )
  1110.         @parent.action_handle.setup( @parent.ygg_battler.get_action_by_id( 0 ) )
  1111.         @parent.action_handle.execute( @parent )
  1112.       when 1 # // Guard
  1113.         @parent.action_handle.setup( @parent.ygg_battler.get_action_by_id( 1 ) )
  1114.         @parent.action_handle.execute( @parent )
  1115.       when 2 # // Escape
  1116.         @parent.action_handle.setup( @parent.ygg_battler.get_action_by_id( 2 ) )
  1117.         @parent.action_handle.execute( @parent )
  1118.       when 3 # // Wait  
  1119.         @parent.action_handle.setup( @parent.ygg_battler.get_action_by_id( 3 ) )
  1120.         @parent.action_handle.execute( @parent )
  1121.       end  
  1122.     when 1 # // Skill
  1123.       obj = $data_skills[@parent.ygg_battler.action.skill_id]
  1124.       next unless @parent.ygg_battler.ygg_skill_can_use?( obj )
  1125.       if obj.for_opponent?()
  1126.         t = @parent.get_targets_nearby( 1, @parent.ygg_correct_target( "ENEMY" ) )
  1127.       elsif obj.for_friend?()  
  1128.         t = @parent.get_targets_nearby( 1, @parent.ygg_correct_target( "ALLY" ) )
  1129.       else  
  1130.         t = @parent.get_targets_nearby( 1, "ALL" )
  1131.       end  
  1132.       return @update_time = @update_time_cap / 4 if t[0].nil?()
  1133.       @parent.ygg_battler.ygg_use_skill( obj )
  1134.       @parent.turn_to_coord( t[0].x, t[0].y )
  1135.       @parent.action_handle.setup( obj.ygg_actions[0] )
  1136.       @parent.action_handle.execute( @parent, [],
  1137.         { :skill_id=> @parent.ygg_battler.action.skill_id } )
  1138.     when 2 # // Item Enemies cant use items
  1139.     end  
  1140.     @update_time = @update_time_cap
  1141.   end
  1142.  
  1143. end  
  1144.  
  1145. #==============================================================================#
  1146. # ** YGG::Handlers::AIEngines::Guard
  1147. #==============================================================================#
  1148. class YGG::Handlers::AIEngines::Guard
  1149.  
  1150.   #--------------------------------------------------------------------------#
  1151.   # * super-method :initialize
  1152.   #--------------------------------------------------------------------------#  
  1153.   def initialize( parent, setup_data={} )
  1154.     sd = setup_data
  1155.     super( parent, sd )
  1156.     setup_area( sd )
  1157.     @update_time_cap = (sd["update_time"] || 90).to_i
  1158.     @__temprect = []
  1159.   end
  1160.  
  1161.   #--------------------------------------------------------------------------#
  1162.   # * new-method :setup_area
  1163.   #--------------------------------------------------------------------------#  
  1164.   def setup_area( setup_data={} )
  1165.     # // area_id (id)
  1166.     @prox = setup_data["proxy_area"].to_i == 1
  1167.     if !setup_data["area_id"].nil?()
  1168.       @guard_area = Rect.new( *$data_areas[setup_data["area_id"].to_i].rect.to_a )
  1169.     # // area_x (center), area_y (center), area_range (center, relative side)
  1170.     elsif !setup_data["area_range"].nil?()
  1171.       ax  = (!setup_data["area_x"].nil?()) ? setup_data["area_x"].to_i : 0
  1172.       ay  = (!setup_data["area_y"].nil?()) ? setup_data["area_y"].to_i : 0
  1173.       rng = (!setup_data["area_range"].nil?()) ? setup_data["area_range"].to_i : 0
  1174.       @guard_area = Rect.new( ax-rng, ay-rng, rng*2, rng*2 )
  1175.     # // area_x (left), area_y (left), area_width (left), area_height (left)    
  1176.     else  
  1177.       @guard_area = Rect.new(
  1178.         (!setup_data["area_x"].nil?()) ? setup_data["area_x"].to_i : 0,
  1179.         (!setup_data["area_y"].nil?()) ? setup_data["area_y"].to_i : 0,
  1180.         (!setup_data["area_width"].nil?()) ? setup_data["area_width"].to_i : 0,
  1181.         (!setup_data["area_height"].nil?()) ? setup_data["area_height"].to_i : 0
  1182.       )
  1183.     end
  1184.     @__guardarea_data ||= {} ; @__guardarea_data.clear()
  1185.     @__guardarea_data["proxy_area"]  = setup_data["proxy_area"]
  1186.     @__guardarea_data["area_id"]     = setup_data["area_id"]
  1187.     @__guardarea_data["area_range"]  = setup_data["area_range"]
  1188.     @__guardarea_data["area_x"]      = setup_data["area_x"]
  1189.     @__guardarea_data["area_y"]      = setup_data["area_y"]
  1190.     @__guardarea_data["area_width"]  = setup_data["area_width"]
  1191.     @__guardarea_data["area_height"] = setup_data["area_height"]
  1192.   end
  1193.  
  1194.   #--------------------------------------------------------------------------#
  1195.   # * new-method :reset_area
  1196.   #--------------------------------------------------------------------------#  
  1197.   def reset_area()
  1198.     setup_area( @__guardarea_data )
  1199.   end
  1200.  
  1201.   #--------------------------------------------------------------------------#
  1202.   # * new-method :ai_update
  1203.   #--------------------------------------------------------------------------#  
  1204.   def ai_update()
  1205.     return if @parent.ygg_battler.nil?()
  1206.     @__temprect = @guard_area.to_vector4_a()
  1207.     @__temprect[0] += @prox ? @parent.x : 0
  1208.     @__temprect[1] += @prox ? @parent.y : 0
  1209.     @__temprect[2] += @prox ? @parent.x : 0
  1210.     @__temprect[3] += @prox ? @parent.y : 0
  1211.     bats = $game_yggdrasil.battlers_range( *@__temprect )  
  1212.     unless bats.empty?()
  1213.       bats -= [@parent]
  1214.       unless bats.empty?()
  1215.         @parent.balloon_id = 1
  1216.         pro = Projectiles::Homing.new( @parent,
  1217.           ::YGG::PROJETILE_SETUP["ProjectileTest"].merge(
  1218.             { :target => bats[rand(bats.size)] } )
  1219.         )    
  1220.         pro.moveto( @parent.x, @parent.y ) ; pro.set_direction( @parent.direction )
  1221.         $game_yggdrasil.add_projectile( pro )
  1222.       end  
  1223.     end  
  1224.     @update_time = @update_time_cap
  1225.   end
  1226.  
  1227. end  
  1228.  
  1229. #==============================================================================#
  1230. # ** YGG::Handlers::AIEngines::Wall
  1231. #==============================================================================#
  1232. class YGG::Handlers::AIEngines::Wall
  1233.  
  1234.   #--------------------------------------------------------------------------#
  1235.   # * super-method :initialize
  1236.   #--------------------------------------------------------------------------#
  1237.   def initialize( parent, setup_data={} )
  1238.     super( parent, setup_data )
  1239.     @burn_time = @burn_cap = setup_data["burn_cap"].to_i
  1240.     @death_anim = (setup_data["death_anim"] || 0).to_i
  1241.   end
  1242.  
  1243.   #--------------------------------------------------------------------------#
  1244.   # * overwrite-method :ai_update
  1245.   #--------------------------------------------------------------------------#
  1246.   def ai_update()
  1247.     return if @parent.ygg_battler.nil?()
  1248.     @burn_time = [@burn_time - 1, 0].max
  1249.     @parent.ygg_battler.hp -= [Integer(@parent.ygg_battler.maxhp / @burn_cap.to_f), 1].max + [@burn_time, 0].min.abs
  1250.     @parent.ygg_engage.engage( 300 )
  1251.     if @parent.ygg_battler.dead?()
  1252.       @parent.ygg_anims << @death_anim if @death_anim > 0
  1253.       $game_map.remove_event( @parent.id )
  1254.     end  
  1255.   end
  1256.  
  1257. end  
  1258.  
  1259. #==============================================================================#
  1260. # ** YGG::Handlers::AIEngines::Wall
  1261. #==============================================================================#
  1262. class YGG::Handlers::AIEngines::ImmortalVarBoss
  1263.  
  1264.   #--------------------------------------------------------------------------#
  1265.   # * super-method :initialize
  1266.   #--------------------------------------------------------------------------#  
  1267.   def initialize( parent, setup_data )
  1268.     super( parent, setup_data )
  1269.     @hp_var    = setup_data["hp_var"].to_i
  1270.     @maxhp_var = setup_data["maxhp_var"].to_i
  1271.     @mp_var    = setup_data["mp_var"].nil?() ? nil : setup_data["mp_var"].to_i
  1272.     @maxmp_var = setup_data["maxmp_var"].nil?() ? nil : setup_data["maxmp_var"].to_i
  1273.     @parent.ygg_invincible = true
  1274.     set_variables()
  1275.   end
  1276.  
  1277.   #--------------------------------------------------------------------------#
  1278.   # * new-method :set_variables
  1279.   #--------------------------------------------------------------------------#  
  1280.   def set_variables()
  1281.     return if @parent.ygg_battler.nil?()
  1282.     $game_variables[@hp_var] = @parent.ygg_battler.hp
  1283.     $game_variables[@maxhp_var] = @parent.ygg_battler.maxhp
  1284.     $game_variables[@mp_var] = @parent.ygg_battler.mp unless @mp_var.nil?()
  1285.     $game_variables[@maxmp_var] = @parent.ygg_battler.maxmp unless @maxmp_var.nil?()
  1286.   end
  1287.  
  1288.   #--------------------------------------------------------------------------#
  1289.   # * overwrite-method :ai_update
  1290.   #--------------------------------------------------------------------------#  
  1291.   def ai_update()
  1292.     return if @parent.ygg_battler.nil?()
  1293.     @parent.ygg_battler.hp = $game_variables[@hp_var]
  1294.     $game_variables[@maxhp_var] = @parent.ygg_battler.maxhp
  1295.     $game_variables[@mp_var] = @parent.ygg_battler.mp unless @mp_var.nil?()
  1296.     $game_variables[@maxmp_var] = @parent.ygg_battler.maxmp unless @maxmp_var.nil?()
  1297.   end
  1298.  
  1299. end  
  1300.  
  1301. # // (YGG_Projectiles)
  1302. Projectiles = YGG::Objects::Projectiles
  1303. #==============================================================================#
  1304. # ** YGG::Objects::Projectiles::Base
  1305. #==============================================================================#
  1306. class YGG::Objects::Projectiles::Base < ::Game_Character
  1307.  
  1308.   #--------------------------------------------------------------------------#
  1309.   # * Public Instance Variables
  1310.   #--------------------------------------------------------------------------#  
  1311.   attr_accessor :character_name
  1312.   attr_accessor :character_index
  1313.  
  1314.   attr_accessor :through
  1315.   attr_accessor :action_name
  1316.   attr_accessor :direction
  1317.   attr_accessor :detonate_cap
  1318.   attr_accessor :move_cap
  1319.   attr_accessor :target_type
  1320.  
  1321.   attr_accessor :registered
  1322.   attr_accessor :action
  1323.  
  1324.   #--------------------------------------------------------------------------#
  1325.   # * new-method :initialize
  1326.   #--------------------------------------------------------------------------#  
  1327.   def initialize( parent, assignments )
  1328.     @parent          = parent
  1329.     super()
  1330.     # // Main Properties
  1331.     @character_name  = assignments[:character_name] || ""
  1332.     @character_index = (assignments[:character_index] || 0).to_i
  1333.     @through         = assignments[:through].nil?() ? true : assignments[:through]
  1334.     @move_speed      = (assignments[:move_speed] || 5).to_i
  1335.    
  1336.     # // Projectile Properties
  1337.     @detonate_cap    = (assignments[:detonate_cap] || -1).to_i
  1338.     @move_cap        = (assignments[:move_cap] || 5).to_i
  1339.     @target_type     = assignments[:target_type] || ""
  1340.    
  1341.     @terminated      = false
  1342.     @detonate_count  = 0
  1343.     @move_count      = 0
  1344.    
  1345.     @action_name     = assignments[:action_name] || ""
  1346.     @action          = assignments[:action] || ::YGG.get_action_list( @action_name )
  1347.    
  1348.     @affect_passage  = assignments[:affect_passage].nil?() ? false : assignments[:affect_passage]
  1349.    
  1350.     @registered      = false
  1351.    
  1352.     #assignments.keys.each { |key| self.send( key.to_s+"=", assignments[key] ) }
  1353.   end
  1354.  
  1355.   #--------------------------------------------------------------------------#
  1356.   # * new-method :hp_visible?
  1357.   #--------------------------------------------------------------------------#
  1358.   def hp_visible?() ; return false ; end
  1359.    
  1360.   #--------------------------------------------------------------------------#
  1361.   # * new-method :mp_visible?
  1362.   #--------------------------------------------------------------------------#
  1363.   def mp_visible?() ; return false ; end
  1364.  
  1365.   #--------------------------------------------------------------------------#
  1366.   # * new-method :registered?
  1367.   #--------------------------------------------------------------------------#
  1368.   def registered?()
  1369.     return @registered
  1370.   end
  1371.  
  1372.   #--------------------------------------------------------------------------#
  1373.   # * new-method :pro_register
  1374.   #--------------------------------------------------------------------------#
  1375.   def pro_register()
  1376.     @registered = true ; $game_yggdrasil.add_passage_obj( self ) if @affect_passage
  1377.   end
  1378.  
  1379.   #--------------------------------------------------------------------------#
  1380.   # * new-method :pro_unregister
  1381.   #--------------------------------------------------------------------------#
  1382.   def pro_unregister()
  1383.     @registered = false ; $game_yggdrasil.remove_passage_obj( self )
  1384.   end
  1385.  
  1386.   #--------------------------------------------------------------------------#
  1387.   # * new-method :ygg_register
  1388.   #--------------------------------------------------------------------------#
  1389.   def ygg_register()
  1390.     @ygg_registered = true
  1391.   end  
  1392.  
  1393.   #--------------------------------------------------------------------------#
  1394.   # * new-method :ygg_unregister
  1395.   #--------------------------------------------------------------------------#
  1396.   def ygg_unregister()
  1397.     $game_yggdrasil.remove_battler( self )
  1398.     @ygg_registered = false
  1399.   end
  1400.  
  1401.   #--------------------------------------------------------------------------#
  1402.   # * new-method :ygg_attacker
  1403.   #--------------------------------------------------------------------------#  
  1404.   def ygg_attacker()
  1405.     return @parent.ygg_attacker
  1406.   end
  1407.  
  1408.   #--------------------------------------------------------------------------#
  1409.   # * new-method :ygg_boss
  1410.   #--------------------------------------------------------------------------#  
  1411.   def ygg_boss?() ; return false ; end
  1412.  
  1413.   #--------------------------------------------------------------------------#
  1414.   # * new-method :ygg_ally?
  1415.   #--------------------------------------------------------------------------#  
  1416.   def ygg_ally?()
  1417.     return @parent.ygg_ally?()
  1418.   end
  1419.  
  1420.   #--------------------------------------------------------------------------#
  1421.   # * new-method :ygg_enemy?
  1422.   #--------------------------------------------------------------------------#  
  1423.   def ygg_enemy?()
  1424.     return @parent.ygg_enemy?()
  1425.   end
  1426.  
  1427.   #--------------------------------------------------------------------------#
  1428.   # * new-method :passable?
  1429.   #--------------------------------------------------------------------------#  
  1430.   def passable?( x, y )
  1431.     x = $game_map.round_x(x)                        
  1432.     y = $game_map.round_y(y)                        
  1433.     return false unless $game_map.valid?(x, y)      
  1434.     return true if @through or debug_through?      
  1435.     return false unless map_passable?( x, y )          
  1436.     return true                                    
  1437.   end
  1438.  
  1439.   #--------------------------------------------------------------------------#
  1440.   # * overwrite-method :check_event_trigger_touch
  1441.   #--------------------------------------------------------------------------#  
  1442.   def check_event_trigger_touch( *args, &block ) ; end
  1443.  
  1444.   #--------------------------------------------------------------------------#
  1445.   # * super-method :update
  1446.   #--------------------------------------------------------------------------#  
  1447.   def update()
  1448.     update_projectile() unless @wait_count > 0
  1449.     super()
  1450.   end
  1451.  
  1452.   #--------------------------------------------------------------------------#
  1453.   # * overwrite-method :update_states
  1454.   #--------------------------------------------------------------------------#  
  1455.   def update_states() ; end
  1456.  
  1457.   #--------------------------------------------------------------------------#
  1458.   # * overwrite-method :move_speed
  1459.   #--------------------------------------------------------------------------#  
  1460.   def move_speed() ; return @move_speed ; end
  1461.    
  1462.   #--------------------------------------------------------------------------#
  1463.   # * new-method :update_projectile
  1464.   #--------------------------------------------------------------------------#  
  1465.   def update_projectile()
  1466.     process_move() if can_move?()
  1467.     process_detonate() if can_detonate?()
  1468.     process_terminate() if can_terminate?()
  1469.   end
  1470.  
  1471.   #--------------------------------------------------------------------------#
  1472.   # * new-method :actual_*x/y
  1473.   #--------------------------------------------------------------------------#  
  1474.   def actual_x() ; return @real_x / 256 ; end
  1475.   def actual_y() ; return @real_y / 256 ; end
  1476.  
  1477.   #--------------------------------------------------------------------------#
  1478.   # * new-method :pos?
  1479.   #--------------------------------------------------------------------------#  
  1480.   def pos?( x, y )  
  1481.     return (actual_x == x && actual_y == y)
  1482.   end
  1483.  
  1484.   #--------------------------------------------------------------------------#
  1485.   # * new-method :target_xy?
  1486.   #--------------------------------------------------------------------------#  
  1487.   def target_xy?( x, y )
  1488.     return !ygg_get_targets( x, y, ygg_correct_target( @target_type ), true ).empty?()
  1489.   end
  1490.  
  1491.   #--------------------------------------------------------------------------#
  1492.   # * new-method :terminated?
  1493.   #--------------------------------------------------------------------------#  
  1494.   def terminated?()
  1495.     return @terminated
  1496.   end
  1497.  
  1498.   #--------------------------------------------------------------------------#
  1499.   # * new-method :can_move?
  1500.   #--------------------------------------------------------------------------#  
  1501.   def can_move?()
  1502.     return false if self.terminated?()
  1503.     return false if jumping?()
  1504.     return false if moving?()
  1505.     return false if (@move_cap > 0 && @move_count >= @move_cap)
  1506.     return true
  1507.   end
  1508.  
  1509.   #--------------------------------------------------------------------------#
  1510.   # * new-method :can_detonate?
  1511.   #--------------------------------------------------------------------------#  
  1512.   def can_detonate?()
  1513.     return false if self.terminated?()
  1514.     return false if (@detonate_cap > 0 && @detonate_count >= @detonate_cap)
  1515.     return target_xy?( self.actual_x, self.actual_y )
  1516.   end
  1517.  
  1518.   #--------------------------------------------------------------------------#
  1519.   # * new-method :can_terminate?
  1520.   #--------------------------------------------------------------------------#  
  1521.   def can_terminate?()
  1522.     return false if self.terminated?()
  1523.     return true if (@detonate_cap > 0 && @detonate_count >= @detonate_cap )
  1524.     return (@move_cap > 0 && @move_count >= @move_cap && !moving?())  
  1525.   end
  1526.  
  1527.   #--------------------------------------------------------------------------#
  1528.   # * new-method :process_move
  1529.   #--------------------------------------------------------------------------#  
  1530.   def process_move()
  1531.     @move_count += 1
  1532.   end
  1533.  
  1534.   #--------------------------------------------------------------------------#
  1535.   # * new-method :process_detonate
  1536.   #--------------------------------------------------------------------------#  
  1537.   def process_detonate()
  1538.     @detonate_count += 1
  1539.     @action_handle.setup( @action )
  1540.     @action_handle.execute( self )
  1541.   end
  1542.  
  1543.   #--------------------------------------------------------------------------#
  1544.   # * new-method :process_terminate
  1545.   #--------------------------------------------------------------------------#  
  1546.   def process_terminate()
  1547.     @terminated = true ; ygg_unregister()
  1548.   end
  1549.  
  1550.   #--------------------------------------------------------------------------#
  1551.   # * new-method :force_terminate
  1552.   #--------------------------------------------------------------------------#  
  1553.   def force_terminate()
  1554.     @terminated = true
  1555.   end
  1556.  
  1557. end
  1558.  
  1559. #==============================================================================#
  1560. # ** YGG::Objects::Projectiles::Linear
  1561. #==============================================================================#
  1562. class YGG::Objects::Projectiles::Linear < ::YGG::Objects::Projectiles::Base
  1563.  
  1564.   #--------------------------------------------------------------------------#
  1565.   # * super-method :initialize
  1566.   #--------------------------------------------------------------------------#  
  1567.   def initialize( parent, assignments )
  1568.     super( parent, assignments )
  1569.   end
  1570.  
  1571.   #--------------------------------------------------------------------------#
  1572.   # * super-method :process_move
  1573.   #--------------------------------------------------------------------------#  
  1574.   def process_move()
  1575.     move_forward()
  1576.     super()
  1577.   end
  1578.  
  1579. end
  1580.  
  1581. #==============================================================================#
  1582. # ** YGG::Objects::Projectiles::Hopping
  1583. #==============================================================================#
  1584. class YGG::Objects::Projectiles::Hopping < ::YGG::Objects::Projectiles::Base
  1585.  
  1586.   #--------------------------------------------------------------------------#
  1587.   # * Public Instance Variables
  1588.   #--------------------------------------------------------------------------#
  1589.   attr_accessor :jump_amount
  1590.  
  1591.   #--------------------------------------------------------------------------#
  1592.   # * super-method :initialize
  1593.   #--------------------------------------------------------------------------#  
  1594.   def initialize( parent, assignments )
  1595.     @jump_amount = (assignments[:jump_amount] || 1).to_i
  1596.     super( parent, assignments )
  1597.   end
  1598.  
  1599.   #--------------------------------------------------------------------------#
  1600.   # * super-method :process_move
  1601.   #--------------------------------------------------------------------------#  
  1602.   def process_move()
  1603.     jump_forward( @jump_amount, 0 )
  1604.     super()
  1605.   end
  1606.  
  1607. end
  1608.  
  1609. #==============================================================================#
  1610. # ** YGG::Objects::Projectiles::Homing
  1611. #==============================================================================#
  1612. class YGG::Objects::Projectiles::Homing < ::YGG::Objects::Projectiles::Base
  1613.  
  1614.   #--------------------------------------------------------------------------#
  1615.   # * Public Instance Variables
  1616.   #--------------------------------------------------------------------------#
  1617.   attr_accessor :target
  1618.   attr_accessor :homing_range
  1619.  
  1620.   #--------------------------------------------------------------------------#
  1621.   # * super-method :initialize
  1622.   #--------------------------------------------------------------------------#  
  1623.   def initialize( parent, assignments )
  1624.     @homing_range = (assignments[:homing_range] || 5).to_i
  1625.     @target = assignments[:target]
  1626.     super( parent, assignments )
  1627.     set_target() if @target.nil?()
  1628.   end
  1629.  
  1630.   #--------------------------------------------------------------------------#
  1631.   # * new-method :target_xy?
  1632.   #--------------------------------------------------------------------------#  
  1633.   def target_xy?( x, y )
  1634.     self.pos?( @target.x, @target.y )
  1635.   end
  1636.  
  1637.   #--------------------------------------------------------------------------#
  1638.   # * new-method :set_target
  1639.   #--------------------------------------------------------------------------#  
  1640.   def set_target()
  1641.     @target = get_targets_nearby( @homing_range, ygg_correct_target( @target_type ) )[0]
  1642.   end
  1643.  
  1644.   #--------------------------------------------------------------------------#
  1645.   # * new-method :target_oor? # // target_out_of_range?
  1646.   #--------------------------------------------------------------------------#  
  1647.   def target_oor?()
  1648.     return @homing_range == -1 ? false : (@target.distance_from( self ) > @homing_range)
  1649.   end
  1650.  
  1651.   #--------------------------------------------------------------------------#
  1652.   # * super-method :process_move
  1653.   #--------------------------------------------------------------------------#  
  1654.   def process_move()
  1655.     move_toward_char( @target )
  1656.     super()
  1657.   end
  1658.  
  1659.   #--------------------------------------------------------------------------#
  1660.   # * super-method :can_terminate?
  1661.   #--------------------------------------------------------------------------#
  1662.   def can_terminate?()
  1663.     return true if target_oor?()
  1664.     super()
  1665.   end
  1666.    
  1667. end
  1668.  
  1669. #==============================================================================#
  1670. # ** YGG::Objects::Projectiles::Bomb
  1671. #==============================================================================#
  1672. class YGG::Objects::Projectiles::Bomb < ::YGG::Objects::Projectiles::Base
  1673.  
  1674.   #--------------------------------------------------------------------------#
  1675.   # * Public Instance Variables
  1676.   #--------------------------------------------------------------------------#  
  1677.   attr_accessor :time
  1678.  
  1679.   #--------------------------------------------------------------------------#
  1680.   # * super-method :initialize
  1681.   #--------------------------------------------------------------------------#  
  1682.   def initialize( parent, assignments )
  1683.     @time = (assignments[:time] || 60).to_i
  1684.     super( parent, assignments )
  1685.   end
  1686.  
  1687.   #--------------------------------------------------------------------------#
  1688.   # * overwrite-method :target_xy?
  1689.   #--------------------------------------------------------------------------#  
  1690.   def target_xy?( x, y )
  1691.     return true
  1692.   end
  1693.  
  1694.   #--------------------------------------------------------------------------#
  1695.   # * super-method :update_projectile
  1696.   #--------------------------------------------------------------------------#  
  1697.   def update_projectile()
  1698.     @time = [@time-1, 0].max
  1699.     super()
  1700.   end
  1701.  
  1702.   #--------------------------------------------------------------------------#
  1703.   # * super-method :can_detonate?
  1704.   #--------------------------------------------------------------------------#  
  1705.   def can_detonate?()
  1706.     return false unless super()
  1707.     return true if @time == 0
  1708.     return false
  1709.   end
  1710.  
  1711. end
  1712.  
  1713. #==============================================================================#
  1714. # ** YGG::Objects::Projectiles::GhostBullet
  1715. #==============================================================================#
  1716. class YGG::Objects::Projectiles::GhostBullet < ::YGG::Objects::Projectiles::Base
  1717.  
  1718.   #--------------------------------------------------------------------------#
  1719.   # * super-method :initialize
  1720.   #--------------------------------------------------------------------------#  
  1721.   def initialize( parent, assignments )
  1722.     super( parent, assignments )
  1723.   end
  1724.  
  1725. end
  1726.  
  1727. #==============================================================================#
  1728. # ** YGG::Objects::Projectiles::ActionPilot
  1729. #==============================================================================#
  1730. class YGG::Objects::Projectiles::ActionPilot < ::YGG::Objects::Projectiles::Base
  1731.  
  1732.   #--------------------------------------------------------------------------#
  1733.   # * Public Instance Variables
  1734.   #--------------------------------------------------------------------------#  
  1735.   attr_accessor :pilot_list
  1736.  
  1737.   #--------------------------------------------------------------------------#
  1738.   # * super-method :update_projectile
  1739.   #--------------------------------------------------------------------------#  
  1740.   def initialize( parent, assignments )
  1741.     @pilot_list = assignments[:pilot_list] || []
  1742.     super( parent, assignments )
  1743.     @pilot_index = 0
  1744.   end
  1745.  
  1746.   #--------------------------------------------------------------------------#
  1747.   # * new-method :update_projectile
  1748.   #--------------------------------------------------------------------------#  
  1749.   def update_projectile()
  1750.     @sleep_count = [@sleep_count - 1, 0].max
  1751.     return unless @sleep_count == 0
  1752.     while @pilot_index < @pilot_list.size
  1753.       act_set     = @pilot_list[@pilot_index]
  1754.       @action     = act_set[0]
  1755.       @parameters = act_set[1]
  1756.       for i in 0...@parameters.size() ; @parameters[i] = @parameters[i].to_s() ; end
  1757.       act_result = -1
  1758.       case @action.upcase()
  1759.       when "MOVE"
  1760.         act_result = pilot_move( @action, @parameters )
  1761.       when "DETONATE"  
  1762.         act_result = pilot_detonate( @action, @parameters )
  1763.       when "TERMINATE"  
  1764.         act_result = pilot_terminate( @action, @parameters )
  1765.       when "SEND"  
  1766.         act_result = pilot_send( @action, @parameters )
  1767.       when "SLEEP"  
  1768.         act_result = pilot_sleep( @action, @parameters )
  1769.       when "SCRIPT"  
  1770.         act_result = pilot_script( @action, @parameters )
  1771.       when "WAIT"  
  1772.         act_result = pilot_wait( @action, @parameters )
  1773.       end
  1774.       if act_result == -1
  1775.         puts "ERROR: -1 returned for pilot action #{self}"
  1776.       else
  1777.         puts "BING: #{act_result} returned for pilot action #{self}"
  1778.       end if YGG.debug_mode?
  1779.       @pilot_index += 1
  1780.       break if act_result == 1
  1781.     end  
  1782.     return
  1783.   end
  1784.  
  1785.   #--------------------------------------------------------------------------#
  1786.   # * new-method :pilot_move
  1787.   #--------------------------------------------------------------------------#  
  1788.   def pilot_move( action, parameters )
  1789.     character = self
  1790.     case parameters[0].upcase
  1791.     when "FORWARD"
  1792.       character.move_forward()
  1793.     when "BACKWARD"
  1794.       character.move_backward()  
  1795.     when "UP"
  1796.       character.move_up()
  1797.     when "DOWN"
  1798.       character.move_down()
  1799.     when "LEFT"
  1800.       character.move_left()
  1801.     when "RIGHT"
  1802.       character.move_right()
  1803.     when "TURNUP", "TURN_UP", "TURN UP"
  1804.       character.turn_up()
  1805.     when "TURNDOWN", "TURN_DOWN", "TURN DOWN"
  1806.       character.turn_down()
  1807.     when "TURNLEFT", "TURN_LEFT", "TURN LEFT"
  1808.       character.turn_left()
  1809.     when "TURNRIGHT", "TURN_RIGHT", "TURN RIGHT"
  1810.       character.turn_right()
  1811.     when "TURNRIGHT90", "TURN_RIGHT_90", "TURN RIGHT 90"
  1812.       character.turn_right_90()
  1813.     when "TURNLEFT90", "TURN_LEFT_90", "TURN LEFT 90"
  1814.       character.turn_left_90()  
  1815.     when "TURN180", "TURN_180", "TURN 180"
  1816.       character.turn_180()
  1817.     when "TURNTO", "TURN_TO", "TURN TO"
  1818.       target = nil
  1819.       character.turn_to_coord( target.x, target.y ) unless target.nil?()
  1820.     end
  1821.     return 0
  1822.   end
  1823.  
  1824.   #--------------------------------------------------------------------------#
  1825.   # * new-method :pilot_send
  1826.   #--------------------------------------------------------------------------#  
  1827.   def pilot_send( action, parameters )
  1828.     case parameters[0]
  1829.     when "ONLY"
  1830.       self.send( parameters[1] )
  1831.     when "SET"  
  1832.       self.send( parameters[1], *parameters.slice( 2, parameters.size ) )
  1833.     end  
  1834.     return 0
  1835.   end
  1836.  
  1837.   #--------------------------------------------------------------------------#
  1838.   # * new-method :pilot_detonate
  1839.   #--------------------------------------------------------------------------#  
  1840.   def pilot_detonate( action, parameters )
  1841.     process_detonate()
  1842.     return 0
  1843.   end
  1844.  
  1845.   #--------------------------------------------------------------------------#
  1846.   # * new-method :pilot_terminate
  1847.   #--------------------------------------------------------------------------#  
  1848.   def pilot_terminate( action, parameters )
  1849.     process_terminate()
  1850.     return 0
  1851.   end
  1852.  
  1853.   #--------------------------------------------------------------------------#
  1854.   # * new-method :pilot_terminate
  1855.   #--------------------------------------------------------------------------#  
  1856.   def pilot_script( action, parameters )
  1857.     eval( parameters.to_s )
  1858.     return 0
  1859.   end
  1860.  
  1861.   #--------------------------------------------------------------------------#
  1862.   # * new-method :pilot_sleep
  1863.   #--------------------------------------------------------------------------#  
  1864.   def pilot_sleep( action, parameters )
  1865.     @sleep_count = parameters[0].to_i
  1866.     return 1
  1867.   end
  1868.  
  1869.   #--------------------------------------------------------------------------#
  1870.   # * new-method :pilot_wait
  1871.   #--------------------------------------------------------------------------#  
  1872.   def pilot_wait( action, parameters )
  1873.     @wait_count = parameters[0].to_i
  1874.     return 0
  1875.   end
  1876.  
  1877. end  
  1878.  
  1879. #==============================================================================#
  1880. # ** YGG
  1881. #==============================================================================#
  1882. module YGG
  1883.  
  1884.   PROJECTILE_MAP = {
  1885.     "linear"  => YGG::Objects::Projectiles::Linear,
  1886.     "hopping" => YGG::Objects::Projectiles::Hopping,
  1887.     "homing"  => YGG::Objects::Projectiles::Homing,
  1888.     "bomb"    => YGG::Objects::Projectiles::Bomb,
  1889.     "ghost"   => YGG::Objects::Projectiles::GhostBullet,
  1890.     "action"  => YGG::Objects::Projectiles::ActionPilot,
  1891.   }  
  1892.  
  1893.   PROJETILE_SETUP = {}
  1894.  
  1895. end
  1896.  
  1897. #==============================================================================#
  1898. # ** YGG::Handlers::Equip
  1899. #==============================================================================#
  1900. class YGG::Handlers::Equip < YGG::Pos
  1901.  
  1902.   #--------------------------------------------------------------------------#
  1903.   # * Class Method(s)
  1904.   #--------------------------------------------------------------------------#
  1905.  
  1906.   #--------------------------------------------------------------------------#
  1907.   # * new-method :angle_change_list
  1908.   #--------------------------------------------------------------------------#
  1909.   def self.angle_change_list( start, add_target, wait, maxspeed=1, shorten=0 )
  1910.     result = []
  1911.     target = start + add_target
  1912.     rate = add_target.to_f / wait.to_f ; accel = 0
  1913.     ang = start
  1914.     (wait-shorten).times { |i|
  1915.       accel = maxspeed.to_f * i.to_f / wait.to_f
  1916.       if ang < target
  1917.         ang += rate.abs
  1918.         ang += accel ; ang = [ang, target].min
  1919.       elsif ang > target
  1920.         ang -= rate.abs
  1921.         ang -= accel ; ang = [ang, target].max
  1922.       else ; ang = target  
  1923.       end  
  1924.       result += [["CHANGE ANGLE", (ang)%360], ["WAIT", 1]]
  1925.     }  
  1926.     return result
  1927.   end
  1928.  
  1929.   #--------------------------------------------------------------------------#
  1930.   # * new-method :move_to_list
  1931.   #--------------------------------------------------------------------------#
  1932.   def self.move_to_list( start, add_target, wait, axis, maxspeed=1, shorten=0 )
  1933.     result = []
  1934.     target = start + add_target
  1935.     rate = add_target.to_f / wait.to_f ; accel = 0
  1936.     pos = start
  1937.     (wait-shorten).times { |i|
  1938.       accel = maxspeed.to_f * i.to_f / wait.to_f
  1939.       if pos < target
  1940.         pos += rate.abs
  1941.         pos += accel ; pos = [pos, target].min
  1942.       elsif pos > target
  1943.         pos -= rate.abs
  1944.         pos -= accel ; pos = [pos, target].max
  1945.       else ; pos = target  
  1946.       end  
  1947.       result += [["MOVE", axis.upcase, pos], ["WAIT", 1]]
  1948.     }  
  1949.     return result
  1950.   end
  1951.  
  1952.   #--------------------------------------------------------------------------#
  1953.   # * new-method :alternate_mix
  1954.   #--------------------------------------------------------------------------#  
  1955.   def self.alternate_mix( *args )
  1956.     aresult = [] ; sizes = args.inject([]) { |result, array| result << array.size }
  1957.     sizes.max.times { |i| args.each { |array| aresult << array[i] unless array[i].nil?() } }
  1958.     return aresult
  1959.   end
  1960.  
  1961.   #--------------------------------------------------------------------------#
  1962.   # * Constant(s)
  1963.   #--------------------------------------------------------------------------#
  1964.   ACTIONS = {}
  1965.   # // Swing
  1966.   t  = 0
  1967.   at = 78
  1968.   ACTIONS["Swing1"]  = [["RESET"], ["SHOW"]]
  1969.   ACTIONS["Swing1"] += angle_change_list( t, at, 12 )
  1970.   ACTIONS["Swing1"] += [["HIDE"]]
  1971.   # // Swing + Return Swing
  1972.   ACTIONS["Swing2"]  = [["RESET"], ["SHOW"]]
  1973.   ACTIONS["Swing2"] += angle_change_list( t, at, 11, 24, 2 )
  1974.   ACTIONS["Swing2"] += angle_change_list( t+at, t-at, 11, 24, 2 )
  1975.   ACTIONS["Swing2"] += [["HIDE"]]
  1976.   # // Swing + Pull
  1977.   ACTIONS["Swing3"]  = [["RESET"], ["SHOW"]]
  1978.   ACTIONS["Swing3"] += angle_change_list( t, at, 11, 24, 2 )
  1979.   ACTIONS["Swing3"] += move_to_list( 0, -14, 8, "Y" )
  1980.   ACTIONS["Swing3"] += [["HIDE"]]
  1981.  
  1982.   # // Stab
  1983.   ACTIONS["Stab1"]   = [["RESET"], ["SHOW"]]
  1984.   ACTIONS["Stab1"]  += [["CHANGE ANGLE", 40]]
  1985.   ACTIONS["Stab1"]  += [["MOVE", "X", -5]]
  1986.   ACTIONS["Stab1"]  += move_to_list( 0,  -4, 5, "Y" )
  1987.   ACTIONS["Stab1"]  += move_to_list( -4, 8, 8, "Y" )
  1988.   ACTIONS["Stab1"]  += [["HIDE"]]
  1989.  
  1990.   ACTIONS["GRise1"] = [["RESET"], ["SHOW"]]
  1991.   ACTIONS["GRise1"] += move_to_list( 0, -8, 8, "Y" )
  1992.   ACTIONS["GRise1"] += [["WAIT FOR GUARD"]]
  1993.   ACTIONS["GRise1"] += move_to_list( 0, 8, 8, "Y" )
  1994.   ACTIONS["GRise1"] += [["HIDE"]]
  1995.  
  1996. end  
  1997.  
  1998. #==============================================================================#
  1999. ($imported ||= {})["Yggdrasil_1x6_ABS"] = true
  2000. #==============================================================================#
  2001. # ** YGG
  2002. #==============================================================================#
  2003. module YGG    
  2004.  
  2005.   module_function()
  2006.  
  2007.   #--------------------------------------------------------------------------#
  2008.   # * new-method :silent_error?
  2009.   #--------------------------------------------------------------------------#  
  2010.   def silent_error?() ; return false ; end
  2011.   def debug_mode?()   ; return false ; end
  2012.    
  2013.   #--------------------------------------------------------------------------#
  2014.   # * new-method :get_action_list
  2015.   #--------------------------------------------------------------------------#
  2016.   def get_action_list( action_name )
  2017.     unless YGG::ACTION_LIST.has_key?( action_name )  
  2018.       return [] if silent_error?() # // Silent Error
  2019.       raise "Action List #{action_name} does not exist"
  2020.       exit
  2021.     end  
  2022.     return ACTION_LIST[action_name]
  2023.   end
  2024.  
  2025.   # // User Functions  
  2026.  
  2027.   #--------------------------------------------------------------------------#
  2028.   # * new-method :create_range_data
  2029.   #--------------------------------------------------------------------------#
  2030.   # If the range was done before, it is simply reloaded
  2031.   # rng    - Maximum Range
  2032.   # minrng - Minimum Range
  2033.   # type:
  2034.   #   0 - Diamond   < >
  2035.   #   1 - Cross      +
  2036.   #   2 - X          x
  2037.   #   3 - Breath     <
  2038.   #   4 - SnowFlake  *
  2039.   #   5 - Block     [ ]
  2040.   #   6 - Linear    ->
  2041.   # direction:
  2042.   #   2 - Down
  2043.   #   4 - Left
  2044.   #   6 - Right
  2045.   #   8 - Up
  2046.   #--------------------------------------------------------------------------#
  2047.   def create_range_data( rng, minrng=0, type=0, direction=2 )  
  2048.     return Handlers::Range.createRange( rng, minrng, type, direction )
  2049.   end
  2050.  
  2051.   #--------------------------------------------------------------------------#
  2052.   # * new-method :offset_xy_list
  2053.   #--------------------------------------------------------------------------#  
  2054.   def offset_xy_list( ox, oy, xy_list, direction=2 )
  2055.     return xy_list.inject([]) { |result, coords|
  2056.       result.push( offset_xy( ox, oy, coords, direction ) ) }
  2057.   end
  2058.  
  2059.   #--------------------------------------------------------------------------#
  2060.   # * new-method :offset_xy
  2061.   #--------------------------------------------------------------------------#  
  2062.   def offset_xy( ox, oy, coords, direction=2 )
  2063.     result = []
  2064.     case direction
  2065.     when 2
  2066.       result = [ ox + coords[0], oy + coords[1] ]
  2067.     when 4
  2068.       result = [ ox - coords[1], oy - coords[0] ]
  2069.     when 6
  2070.       result = [ ox + coords[1], oy + coords[0] ]
  2071.     when 8
  2072.       result = [ ox - coords[0], oy - coords[1] ]
  2073.     end
  2074.     return result
  2075.   end
  2076.  
  2077.   #--------------------------------------------------------------------------#
  2078.   # * new-method :parse_event_list
  2079.   #--------------------------------------------------------------------------#  
  2080.   def parse_event_list( list )
  2081.     return list
  2082.     # // Skip Parsing
  2083.     final_list = []
  2084.     list.each { |command|
  2085.       new_command = command.clone
  2086.       if [108, 408].include?( command.code )
  2087.         new_command = RPG::EventCommand.new
  2088.         new_command.indent = command.indent
  2089.         case command.parameters.to_s.upcase
  2090.         when "DETONATE"
  2091.           new_command.code = 1000
  2092.         end
  2093.       end  
  2094.       final_list << new_command
  2095.     }  
  2096.     return final_list
  2097.   end
  2098.  
  2099. #==============================================================================#
  2100. # // Main Classes
  2101. #==============================================================================#
  2102. # ** Pos  
  2103. #==============================================================================#
  2104.   class Pos  
  2105.    
  2106.     #--------------------------------------------------------------------------#
  2107.     # * Public Instance Variable(s)
  2108.     #--------------------------------------------------------------------------#  
  2109.     attr_accessor :x, :y, :z # // X, Y, Z
  2110.    
  2111.     #--------------------------------------------------------------------------#
  2112.     # * new-method :initialize
  2113.     #--------------------------------------------------------------------------#
  2114.     def initialize( x, y, z=0 ) ; set( x, y, z ) end
  2115.      
  2116.     #--------------------------------------------------------------------------#
  2117.     # * new-method :set
  2118.     #--------------------------------------------------------------------------#
  2119.     def set( x, y, z=@z ) ; @x = x ; @y = y ; @z = z ; end
  2120.      
  2121.     #--------------------------------------------------------------------------#
  2122.     # * super-method :==
  2123.     #--------------------------------------------------------------------------#  
  2124.     def ==( obj )
  2125.       return ( @x == obj.x &&
  2126.         @y == obj.y &&
  2127.         @z == obj.z ) if obj.kind_of?( self.class )
  2128.       return super( obj )  
  2129.     end
  2130.    
  2131.   end
  2132.  
  2133. #==============================================================================#
  2134. # ** YGG::Handlers::Screen
  2135. #==============================================================================#
  2136.   class Handlers::Screen < Pos
  2137.    
  2138.     #--------------------------------------------------------------------------#
  2139.     # * Public Instance Variable(s)
  2140.     #--------------------------------------------------------------------------#  
  2141.     attr_accessor :real_x, :real_y
  2142.    
  2143.     #--------------------------------------------------------------------------#
  2144.     # * super-method :initialize
  2145.     #--------------------------------------------------------------------------#
  2146.     def initialize( x, y, z=200 ) ; super( x, y, z ) ; moveto( x, y, z ) ; end
  2147.    
  2148.     #--------------------------------------------------------------------------#
  2149.     # * new-method :moveto
  2150.     #--------------------------------------------------------------------------#
  2151.     def moveto( x, y, z=@z )
  2152.       set( x % $game_map.width, y % $game_map.height, z )
  2153.       @real_x = @x * 256 ; @real_y = @y * 256
  2154.     end
  2155.    
  2156.     #--------------------------------------------------------------------------#
  2157.     # * new-method :screen_x
  2158.     #--------------------------------------------------------------------------#  
  2159.     def screen_x()
  2160.       return ($game_map.adjust_x(@real_x) + 8007) / 8 - 1000 + 16
  2161.     end
  2162.    
  2163.     #--------------------------------------------------------------------------#
  2164.     # * new-method :screen_y
  2165.     #--------------------------------------------------------------------------#  
  2166.     def screen_y()
  2167.       return ($game_map.adjust_y(@real_y) + 8007) / 8 - 1000 + 32
  2168.     end
  2169.    
  2170.     #--------------------------------------------------------------------------#
  2171.     # * new-method :screen_z
  2172.     #--------------------------------------------------------------------------#  
  2173.     def screen_z() ; return @z ; end
  2174.    
  2175.   end
  2176.  
  2177. #==============================================================================#
  2178. # ** Handlers::CharPos
  2179. #==============================================================================#
  2180.   class Handlers::CharPos < Handlers::Screen
  2181.    
  2182.     #--------------------------------------------------------------------------#
  2183.     # * Public Instance Variable(s)
  2184.     #--------------------------------------------------------------------------#
  2185.     attr_accessor :fade_amount
  2186.     attr_accessor :fade_max
  2187.    
  2188.     #--------------------------------------------------------------------------#
  2189.     # * super-method :initialize
  2190.     #--------------------------------------------------------------------------#
  2191.     def initialize( x=0, y=0, z=0, fade_out=0, fade_amt=0 )
  2192.       super( x, y, z )
  2193.       @fade_out    = fade_out
  2194.       @fade_amount = @fade_max = fade_amt
  2195.     end
  2196.    
  2197.     #--------------------------------------------------------------------------#
  2198.     # * new-method :fader_type
  2199.     #--------------------------------------------------------------------------#
  2200.     def fader_type() ; return @fade_out ; end
  2201.    
  2202.     #--------------------------------------------------------------------------#
  2203.     # * new-method :setup_pos
  2204.     #--------------------------------------------------------------------------#
  2205.     def setup_pos( x, y ) ; moveto( @x, @y ) ; end
  2206.    
  2207.   end  
  2208.    
  2209. #==============================================================================#
  2210. # ** Handlers::Range
  2211. #==============================================================================#
  2212.   class Handlers::Range  
  2213.    
  2214.     #--------------------------------------------------------------------------#
  2215.     # * Class Variable
  2216.     #--------------------------------------------------------------------------#
  2217.     @@_recorded_ranges = { }
  2218.    
  2219.     #--------------------------------------------------------------------------#
  2220.     # * class-method :createRange
  2221.     #--------------------------------------------------------------------------#
  2222.     def self.createRange( rng, minrng=0, type=0, direction=2 )
  2223.       datarray = [ rng, minrng, type, direction ]
  2224.       unless @@_recorded_ranges.has_key?( datarray )
  2225.         result   = []
  2226.         case type
  2227.         when 0 # // Normal - Diamond <>
  2228.           for x in 0..rng
  2229.             for y in 0..rng
  2230.               next if x+y > rng
  2231.               next if x+y < minrng
  2232.               result << [ x,  y] ; result << [-x,  y]
  2233.               result << [ x, -y] ; result << [-x, -y]
  2234.             end
  2235.           end
  2236.         when 1 # // Cross +
  2237.           for x in 0..rng
  2238.             for y in 0..rng
  2239.               next if x+y > rng
  2240.               next if x+y < minrng
  2241.               result << [ x,  0] ; result << [-x,  0]
  2242.               result << [ 0, -y] ; result << [ 0,  y]
  2243.             end
  2244.           end
  2245.         when 2 # // X - x
  2246.           for x in 0..rng
  2247.             for y in 0..rng
  2248.               next if x+y > rng
  2249.               next if x+y < minrng
  2250.               result << [ x,  x] ; result << [-x, -x]
  2251.               result << [-y,  y] ; result << [ y, -y]
  2252.             end
  2253.           end
  2254.         when 3 # // Breath <
  2255.           for x in 0..rng
  2256.             for y in 0..rng
  2257.               next if x+y > rng
  2258.               next if x+y < minrng
  2259.               case direction
  2260.               when 2 ; result << [ x,  y] ; result << [-x,  y]
  2261.               when 4 ; result << [-x,  y] ; result << [-x, -y]
  2262.               when 6 ; result << [ x,  y] ; result << [ x, -y]
  2263.               when 8 ; result << [ x, -y] ; result << [-x, -y]
  2264.               end  
  2265.             end
  2266.           end
  2267.         when 4 # // Snow Flake *
  2268.           for x in 0..rng
  2269.             next if x < minrng
  2270.             result << [ 0,  x] ; result << [ x,  0]
  2271.             result << [ 0, -x] ; result << [-x,  0]
  2272.             result << [ x,  x] ; result << [-x,  x]
  2273.             result << [ x, -x] ; result << [-x, -x]
  2274.           end  
  2275.         when 5 # // Block []
  2276.           for x in 0..rng
  2277.             for y in 0..rng
  2278.               next if x < minrng && y < minrng
  2279.               result << [ x,  y] ; result << [-x,  y]
  2280.               result << [ x, -y] ; result << [-x, -y]
  2281.             end
  2282.           end  
  2283.         when 6 # // Linear <-
  2284.           for x in 0..rng
  2285.             for y in 0..rng
  2286.               next if x+y > rng
  2287.               next if x+y < minrng
  2288.               case direction
  2289.               when 2 ; result << [ 0,  y]
  2290.               when 4 ; result << [-x,  0]
  2291.               when 6 ; result << [ x,  0]
  2292.               when 8 ; result << [ 0, -y]
  2293.               end  
  2294.             end
  2295.           end
  2296.         end
  2297.         @@_recorded_ranges[datarray] = result.compact.uniq
  2298.       end  
  2299.       return @@_recorded_ranges[datarray]
  2300.     end
  2301.    
  2302.   end
  2303.  
  2304. #==============================================================================#
  2305. # // YGG Construction
  2306. #==============================================================================#
  2307. # ** REGEXP
  2308. #==============================================================================#  
  2309.   module REGEXP
  2310. #==============================================================================#
  2311. # ** EVENT
  2312. #==============================================================================#
  2313.     module EVENT
  2314.       # Event Tags
  2315.       ABS_ALLY         = /<(?:ABS_ALLY|abs ally):[ ]*(\d+)>/i
  2316.       ABS_ENEMY        = /<(?:ABS_ENEMY|abs enemy):[ ]*(\d+)>/i
  2317.       ABS_SET_AS_ALLY  = /<(?:SET_AS_ALLY|SET AS ALLY)>/i
  2318.       ABS_SET_AS_ENEMY = /<(?:SET_AS_ENEMY|SET AS ENEMY)>/i
  2319.       ABS_BOSS         = /<(?:ABS_BOSS|abs boss)>/i
  2320.       SELF_SWITCH      = /<(?:DEAD_SELF_SWITCH|dead self switch):[ ]*(\w+)>/i
  2321.       SWITCH           = /<(?:DEAD_SWITCH|dead switch):[ ]*(\d+)[ ]*,[ ]*(\w+)>/i
  2322.       NO_FADE_DEATH    = /<(?:NO_FADE_DEATH|no fade death)>/i
  2323.       INSTANT_DEATH    = /<(?:INSTANT_DEATH|instant death)>/i
  2324.       DEATH_ANIM       = /<(?:DEATH_ANIMATION_ID|death animation id|death anim|DEATH_ANIM):[ ]*(\d+)>/i
  2325.       INVINCIBLE       = /<(?:INVINCIBLE|IMMORTAL)>/i
  2326.      
  2327.       AI_ENGINE1       = /<(?:AI_ENGINE|AI ENGINE):[ ](.*)>/i
  2328.       AI_ENGINE2       = /<\/(?:AI_ENGINE|AI ENGINE)>/i
  2329.       ENABLE_POP       = /<(?:ENABLE_POP|ENABLE POP|ENABLEPOP)>/i
  2330.       DISABLE_POP      = /<(?:DISABLE_POP|DISABLE POP|DISABLEPOP|NO POP|NO_POP|NOPOP)>/i
  2331.       SHOW_HP_BAR      = /<(?:SHOW_HP_BAR|SHOW HP BAR|SHOWHPBAR)>/i
  2332.       HIDE_HP_BAR      = /<(?:HIDE_HP_BAR|HIDE HP BAR|HIDEHPBAR)>/i
  2333.       SHOW_MP_BAR      = /<(?:SHOW_MP_BAR|SHOW MP BAR|SHOWMPBAR)>/i
  2334.       HIDE_MP_BAR      = /<(?:HIDE_MP_BAR|HIDE MP BAR|HIDEMPBAR)>/i
  2335.      
  2336.       ONDEATH1         = /<(?:ON_DEATH|ON DEATH|ONDEATH):[ ](.*)>/i
  2337.       ONDEATH2         = /<\/(?:ON_DEATH|ON DEATH|ONDEATH)>/i
  2338.     end # // EVENT
  2339. #==============================================================================#
  2340. # ** BASE_ITEM
  2341. #==============================================================================#
  2342.     module BASE_ITEM
  2343.       # Equipment Tags
  2344.       ACTION_OPEN   = /<ACTION[ ]*(\d+)>/i
  2345.       ACTION_CLOSE  = /<\/ACTION>/i
  2346.       ACTION_ASSIGN = /<ACTION[ ]*(\d+)[ ]*\=[ ]*(.*)>/i
  2347.      
  2348.       PREACTION_OPEN   = /<PREACTION[ ]*(\d+)>/i
  2349.       PREACTION_CLOSE  = /<\/PREACTION>/i
  2350.       PREACTION_ASSIGN = /<PREACTION[ ]*(\d+)[ ]*\=[ ]*(.*)>/i
  2351.      
  2352.       ACTION_6      = /(.*):[ ](.*),[ ](.*),[ ](.*),[ ](.*),[ ](.*),[ ](.*)/i
  2353.       ACTION_5      = /(.*):[ ](.*),[ ](.*),[ ](.*),[ ](.*),[ ](.*)/i
  2354.       ACTION_4      = /(.*):[ ](.*),[ ](.*),[ ](.*),[ ](.*)/i
  2355.       ACTION_3      = /(.*):[ ](.*),[ ](.*),[ ](.*)/i
  2356.       ACTION_2      = /(.*):[ ](.*),[ ](.*)/i
  2357.       ACTION_1      = /(.*):[ ](.*)/i
  2358.      
  2359.       DROPS_ATTRACT = /<(?:ATTRACT_DROP|attract drop)s?>/i
  2360.      
  2361.       CHARGE_CAP    = /<(?:CHARGE_CAP|CHARGE CAP|COOLDOWN):[ ]*(\d+)>/i
  2362.     USER_CHARGE_CAP = /<(?:USER_CHARGE_CAP|USER CHARGE CAP|USER_COOLDOWN|USER COOLDOWN):[ ]*(\d+)>/i
  2363.    
  2364.       CANT_EQUIP    = /<(?:CANT_EQUIP_SLOT|CANT EQUIP SLOT)>/i  
  2365.      
  2366.       PICKUP_SFX    = /<(?:PICKUP_SFX|PICKUP SFX|PKSFX):[ ](.*),[ ](\d+),[ ](\d+)>/i
  2367.     end
  2368. #==============================================================================#
  2369. # ** SKILL
  2370. #==============================================================================#      
  2371.     module SKILL
  2372.       UTARGET_SELECT= /<(?:USE_TARGET_SELECT|USE TARGET SELECT)>/i
  2373.       GUARDABLE     = /<(?:GUARDABLE)>/i
  2374.       NOT_GUARDABLE = /<(?:NOT_GUARDABLE|NOT GUARDABLE|NOTGUARDABLE)>/i
  2375.     end # // BASE_ITEM
  2376. #==============================================================================#
  2377. # ** STATE
  2378. #==============================================================================#    
  2379.     module STATE
  2380.       HOLD_TICKS = /<(?:HOLDTICKS|HOLD_TICKS|HOLD TICKS):[ ](\d+)>/i
  2381.       TONE       = /<TONE:[ ]([\+\-]?\d+),[ ]*([\+\-]?\d+),[ ]*([\+\-]?\d+),[ ]*(\d+)>/i
  2382.       MOVE_MOD   = /<(?:MOVEMOD|MOVE_MOD|MOVE MOD):[ ]([\+\-]\d+)>/i
  2383.       SLIP_FREQ  = /<(?:SLIPFREQ|SLIP_FREQ|SLIP FREQ):[ ](\d+)>/i
  2384.     end # // STATE
  2385. #==============================================================================#
  2386. # ** ENEMY
  2387. #==============================================================================#        
  2388.     module ENEMY
  2389.       ATK_ANIMATION_ID = /<(?:ATK_ANIMATION_ID|ATK ANIMATION ID):[ ](\d+)>/i
  2390.       DROP_ITEM1       = /<(?:DROP_ITEM|DROP ITEM|DROPITEM)[ ](\d+)>/i
  2391.       DROP_ITEM2       = /<\/(?:DROP_ITEM|DROP ITEM|DROPITEM)>/i
  2392.       DROP_CLEAR       = /<(?:DROPS_CLEAR|DROPS CLEAR|DROPSCLEAR)>/i
  2393.       GOLD_VARI        = /<(?:GOLD_VARIATION|GOLD VARIATION):[ ](\d+)>/i
  2394.     end  
  2395.   end # // REGEXP
  2396. end # // YGG
  2397.  
  2398. #==============================================================================#
  2399. #
  2400. # OriginalWij and Yanfly Collaboration - Keyboard Input
  2401. # Last Date Updated: 2010.06.12
  2402. #
  2403. #==============================================================================#
  2404. # Updates
  2405. # -----------------------------------------------------------------------------#
  2406. # o 2010.06.12 - Started and Finished Script.
  2407. #==============================================================================#
  2408. unless $imported["KeyboardInput"]
  2409. ($imported ||= {})["KeyboardInput"] = true
  2410. #==============================================================================#
  2411. # ** Input
  2412. #==============================================================================#
  2413. class << Input  
  2414.   #--------------------------------------------------------------------------#
  2415.   # Aliases (Mods - Linked to Module) - Created by OriginalWij
  2416.   #--------------------------------------------------------------------------#
  2417.   alias ow_dt_i_press press? unless $@
  2418.   alias ow_dt_i_trigger trigger? unless $@
  2419.   alias ow_dt_i_repeat repeat? unless $@
  2420.   alias ow_dt_i_update update unless $@
  2421. end
  2422.  
  2423. module Input
  2424.  
  2425.   #--------------------------------------------------------------------------
  2426.   # * initial module settings - Created by OriginalWij and Yanfly
  2427.   #--------------------------------------------------------------------------
  2428.   GetKeyState = Win32API.new( "user32", "GetAsyncKeyState", "i", "i" )
  2429.   GetCapState = Win32API.new( "user32", "GetKeyState", "i", "i" )
  2430.   KeyRepeatCounter = {}
  2431.  
  2432.   module_function()
  2433.   #--------------------------------------------------------------------------
  2434.   # * alias-method :update - Created by OriginalWij
  2435.   #--------------------------------------------------------------------------
  2436.   def update()
  2437.     ow_dt_i_update()
  2438.     for key in KeyRepeatCounter.keys
  2439.       if (GetKeyState.call(key).abs & 0x8000 == 0x8000)
  2440.         KeyRepeatCounter[key] += 1
  2441.       else
  2442.         KeyRepeatCounter.delete(key)
  2443.       end
  2444.     end
  2445.   end
  2446.  
  2447.   #--------------------------------------------------------------------------
  2448.   # * alias-method :press? - Created by OriginalWij
  2449.   #--------------------------------------------------------------------------
  2450.   def press?( key )
  2451.     return ow_dt_i_press(key) if key < 30
  2452.     adjusted_key = adjust_key(key)
  2453.     return true unless KeyRepeatCounter[adjusted_key].nil?
  2454.     return key_pressed?(adjusted_key)
  2455.   end
  2456.  
  2457.   #--------------------------------------------------------------------------
  2458.   # * alias-method :trigger? - Created by OriginalWij
  2459.   #--------------------------------------------------------------------------
  2460.   def trigger?(key)
  2461.     return ow_dt_i_trigger(key) if key < 30
  2462.     adjusted_key = adjust_key(key)
  2463.     count = KeyRepeatCounter[adjusted_key]
  2464.     return ((count == 0) or (count.nil? ? key_pressed?(adjusted_key) : false))
  2465.   end
  2466.  
  2467.   #--------------------------------------------------------------------------
  2468.   # * alias-method :repeat? - Created by OriginalWij
  2469.   #--------------------------------------------------------------------------
  2470.   def repeat?(key)
  2471.     return ow_dt_i_repeat(key) if key < 30
  2472.     adjusted_key = adjust_key(key)
  2473.     count = KeyRepeatCounter[adjusted_key]
  2474.     return true if count == 0
  2475.     if count.nil?
  2476.       return key_pressed?(adjusted_key)
  2477.     else
  2478.       return (count >= 23 and (count - 23) % 6 == 0)
  2479.     end
  2480.   end
  2481.  
  2482.   #--------------------------------------------------------------------------
  2483.   # * new-method :adjust_key - Created by OriginalWij
  2484.   #--------------------------------------------------------------------------
  2485.   def adjust_key(key)
  2486.     key -= 130 if key.between?(130, 158)
  2487.     return key
  2488.   end
  2489.  
  2490.   #--------------------------------------------------------------------------
  2491.   # * new-method :key_pressed? - Created by OriginalWij
  2492.   #--------------------------------------------------------------------------
  2493.   def key_pressed?(key)
  2494.     if (GetKeyState.call(key).abs & 0x8000 == 0x8000)
  2495.       KeyRepeatCounter[key] = 0
  2496.       return true
  2497.     end
  2498.     return false
  2499.   end
  2500.  
  2501.   #--------------------------------------------------------------------------
  2502.   # * new-method :typing? - Created by Yanfly
  2503.   #--------------------------------------------------------------------------
  2504.   def typing?
  2505.     return true if repeat?(SPACE)
  2506.     for i in 'A'..'Z'
  2507.       return true if repeat?(LETTERS[i])
  2508.     end
  2509.     for i in 0...NUMBERS.size
  2510.       return true if repeat?(NUMBERS[i])
  2511.       return true if repeat?(NUMPAD[i])
  2512.     end
  2513.     for key in Extras
  2514.       return true if repeat?(key)
  2515.     end
  2516.     return false
  2517.   end
  2518.  
  2519.   #--------------------------------------------------------------------------
  2520.   # * new-method :key_type - Created by Yanfly
  2521.   #--------------------------------------------------------------------------
  2522.   def key_type()
  2523.     return " " if repeat?(SPACE)
  2524.     for i in 'A'..'Z'
  2525.       next unless repeat?(LETTERS[i])
  2526.       return upcase? ? i.upcase : i.downcase
  2527.     end
  2528.     for i in 0...NUMBERS.size
  2529.       return i.to_s if repeat?(NUMPAD[i])
  2530.       if !press?(SHIFT)
  2531.         return i.to_s if repeat?(NUMBERS[i])
  2532.       elsif repeat?(NUMBERS[i])
  2533.         case i
  2534.         when 1; return "!"
  2535.         when 2; return "@"
  2536.         when 3; return "#"
  2537.         when 4; return "$"
  2538.         when 5; return "%"
  2539.         when 6; return "^"
  2540.         when 7; return "&"
  2541.         when 8; return "*"
  2542.         when 9; return "("
  2543.         when 0; return ")"
  2544.         end
  2545.       end
  2546.     end
  2547.     for key in Extras
  2548.       next unless repeat?(key)
  2549.       case key
  2550.       when USCORE; return press?(SHIFT) ? "_" : "-"
  2551.       when EQUALS; return press?(SHIFT) ? "+" : "="
  2552.       when LBRACE; return press?(SHIFT) ? "{" : "["
  2553.       when RBRACE; return press?(SHIFT) ? "}" : "]"
  2554.       when BSLASH; return press?(SHIFT) ? "|" : "\\"
  2555.       when SCOLON; return press?(SHIFT) ? ":" : ";"
  2556.       when QUOTE;  return press?(SHIFT) ? '"' : "'"
  2557.       when COMMA;  return press?(SHIFT) ? "<" : ","
  2558.       when PERIOD; return press?(SHIFT) ? ">" : "."
  2559.       when SLASH;  return press?(SHIFT) ? "?" : "/"
  2560.       when NMUL;   return "*"
  2561.       when NPLUS;  return "+"
  2562.       when NSEP;   return ","
  2563.       when NMINUS; return "-"
  2564.       when NDECI;  return "."
  2565.       when NDIV;   return "/"
  2566.       end
  2567.     end
  2568.     return ""
  2569.   end
  2570.  
  2571.   #--------------------------------------------------------------------------
  2572.   # * new-method :upcase? - Created by Yanfly
  2573.   #--------------------------------------------------------------------------
  2574.   def upcase?()
  2575.     return !press?(SHIFT) if GetCapState.call(CAPS) == 1
  2576.     return true if press?(SHIFT)
  2577.     return false
  2578.   end
  2579.  
  2580. end # Input
  2581. end
  2582.  
  2583. #==============================================================================#
  2584. # ** Vocab
  2585. #==============================================================================#
  2586. module Vocab
  2587.  
  2588.   #--------------------------------------------------------------------------#
  2589.   # * new-method :maxhp
  2590.   #--------------------------------------------------------------------------#
  2591.   def self.maxhp ; return self.hp ; end
  2592.    
  2593.   #--------------------------------------------------------------------------#
  2594.   # * new-method :maxmp
  2595.   #--------------------------------------------------------------------------#  
  2596.   def self.maxmp ; return self.mp ; end
  2597.    
  2598. end
  2599.  
  2600. #==============================================================================#
  2601. # ** Array
  2602. #==============================================================================#
  2603. class Array
  2604.  
  2605.   #--------------------------------------------------------------------------#
  2606.   # * new-method :rotate
  2607.   #--------------------------------------------------------------------------#  
  2608.   def rotate( n=1 ) ; dup.rotate!( n ) ; end unless method_defined? :rotate
  2609.  
  2610.   #--------------------------------------------------------------------------#
  2611.   # * new-method :rotate!
  2612.   #--------------------------------------------------------------------------#
  2613.   def rotate!( n=1 )
  2614.     return self if empty?
  2615.     n %= size
  2616.     concat( slice!( 0, n ) )
  2617.   end unless method_defined? :rotate!
  2618.  
  2619. end
  2620.  
  2621. #==============================================================================#
  2622. # ** Rect
  2623. #==============================================================================#
  2624. class Rect
  2625.  
  2626.   #--------------------------------------------------------------------------#
  2627.   # * new-method :to_a
  2628.   #--------------------------------------------------------------------------#  
  2629.   def to_a() ; return self.x, self.y, self.width, self.height ; end
  2630.  
  2631.   #--------------------------------------------------------------------------#
  2632.   # * new-method :to_vector4_a
  2633.   #--------------------------------------------------------------------------#  
  2634.   def to_vector4_a()
  2635.     return self.x, self.y, self.x + self.width, self.y + self.height
  2636.   end
  2637.  
  2638. end
  2639.  
  2640. #==============================================================================#
  2641. # ** YGG
  2642. #==============================================================================#
  2643. module YGG
  2644.  
  2645.   #--------------------------------------------------------------------------#
  2646.   # * new-method :get_action_from_line
  2647.   #--------------------------------------------------------------------------#  
  2648.   def self.get_action_from_line( line )
  2649.     case line
  2650.     # // Exception
  2651.     when /SCRIPT:[ ](.*)/i
  2652.       result = [ "SCRIPT", [$1]               ]
  2653.     # // Regular Actions            
  2654.     when ::YGG::REGEXP::BASE_ITEM::ACTION_6
  2655.       result = [ $1, [$2, $3, $4, $5, $6, $7] ]
  2656.     when ::YGG::REGEXP::BASE_ITEM::ACTION_5
  2657.       result = [ $1, [$2, $3, $4, $5, $6]     ]
  2658.     when ::YGG::REGEXP::BASE_ITEM::ACTION_4
  2659.       result = [ $1, [$2, $3, $4, $5]         ]  
  2660.     when ::YGG::REGEXP::BASE_ITEM::ACTION_3
  2661.       result = [ $1, [$2, $3, $4]             ]
  2662.     when ::YGG::REGEXP::BASE_ITEM::ACTION_2
  2663.       result = [ $1, [$2, $3]                 ]  
  2664.     when ::YGG::REGEXP::BASE_ITEM::ACTION_1
  2665.       result = [ $1, [$2]                     ]  
  2666.     else
  2667.       result = [ line, []                     ]
  2668.     end # // case line
  2669.     return result
  2670.   end
  2671.  
  2672. end
  2673.  
  2674. #==============================================================================#
  2675. # ** YGG::Caches1x6
  2676. #==============================================================================#
  2677. module YGG::Caches1x6
  2678.  
  2679.   #--------------------------------------------------------------------------#
  2680.   # * Public Instance Variable(s)
  2681.   #--------------------------------------------------------------------------#  
  2682.   attr_accessor :ygg_actions, :ygg_pre_actions
  2683.   attr_accessor :ygg_target_range
  2684.   attr_accessor :drops_attraction
  2685.   attr_accessor :atk_act_name, :grd_act_name
  2686.   attr_accessor :charge_cap
  2687.   attr_accessor :user_charge_cap
  2688.   attr_accessor :cant_equip_slot
  2689.  
  2690.   #--------------------------------------------------------------------------#
  2691.   # * new-method :ygg_add_to_cache
  2692.   #--------------------------------------------------------------------------#
  2693.   def ygg_add_to_cache( array )
  2694.     unless @__pre_action
  2695.       @ygg_actions[@__current_action].push( array )
  2696.     else  
  2697.       @ygg_pre_actions[@__current_action].push( array )
  2698.     end  
  2699.   end
  2700.  
  2701.   #--------------------------------------------------------------------------#
  2702.   # * new-method :yggdrasil_1x6_cache
  2703.   #--------------------------------------------------------------------------#
  2704.   def yggdrasil_1x6_cache()
  2705.     yggdrasil_1x6_cache_start()
  2706.     self.note.split(/[\r\n]+/).each { |line| yggdrasil_1x6_cache_check( line ) }
  2707.     yggdrasil_1x6_cache_end()
  2708.   end
  2709.  
  2710.   #--------------------------------------------------------------------------#
  2711.   # * new-method :yggdrasil_1x6_cache_start
  2712.   #--------------------------------------------------------------------------#
  2713.   def yggdrasil_1x6_cache_start()
  2714.     @charge_cap      = 0
  2715.     @user_charge_cap = 0
  2716.     @atk_act_name    = ""
  2717.     @grd_act_name    = ""
  2718.     case self
  2719.     when RPG::Item
  2720.       # // Yeah ....
  2721.     when RPG::Weapon
  2722.       @atk_act_name = "Swing1"
  2723.     when RPG::Armor  
  2724.       @grd_act_name = "GRise1"
  2725.     end  
  2726.     @ygg_actions      = {}
  2727.     @ygg_pre_actions  = {}
  2728.     @ygg_target_range = 0
  2729.     @drops_attraction = false
  2730.     @__current_action = -1
  2731.     @__pre_action     = false
  2732.     @cant_equip_slot  = false
  2733.   end
  2734.  
  2735.   #--------------------------------------------------------------------------#
  2736.   # * new-method :yggdrasil_1x6_cache_check
  2737.   #--------------------------------------------------------------------------#
  2738.   def yggdrasil_1x6_cache_check( line )
  2739.     case line
  2740.     # // Action  
  2741.     when ::YGG::REGEXP::BASE_ITEM::ACTION_OPEN
  2742.       @__current_action = $1.to_i
  2743.       @ygg_actions[@__current_action] = []
  2744.       @__pre_action = false
  2745.     when ::YGG::REGEXP::BASE_ITEM::ACTION_CLOSE  
  2746.       @__pre_action = false
  2747.       @__current_action = -1
  2748.     when ::YGG::REGEXP::BASE_ITEM::ACTION_ASSIGN
  2749.       @ygg_actions[$1.to_i] = ::YGG.get_action_list( $2 )
  2750.     # // Pre Action  
  2751.     when ::YGG::REGEXP::BASE_ITEM::PREACTION_OPEN
  2752.       @__current_action = $1.to_i
  2753.       @ygg_pre_actions[@__current_action] = []
  2754.       @__pre_action = true
  2755.     when ::YGG::REGEXP::BASE_ITEM::PREACTION_CLOSE  
  2756.       @__current_action = -1
  2757.       @__pre_action = false
  2758.     when ::YGG::REGEXP::BASE_ITEM::PREACTION_ASSIGN
  2759.       @ygg_pre_actions[$1.to_i] = ::YGG.get_action_list( $2 )  
  2760.      
  2761.     when ::YGG::REGEXP::BASE_ITEM::DROPS_ATTRACT  
  2762.       @drops_attraction = true
  2763.     when ::YGG::REGEXP::BASE_ITEM::CHARGE_CAP  
  2764.       @charge_cap = $1.to_i
  2765.     when ::YGG::REGEXP::BASE_ITEM::USER_CHARGE_CAP  
  2766.       @user_charge_cap = $1.to_i
  2767.      
  2768.     when ::YGG::REGEXP::BASE_ITEM::CANT_EQUIP
  2769.       @cant_equip_slot = true
  2770.     else
  2771.       if @__current_action > -1
  2772.         ygg_add_to_cache( ::YGG.get_action_from_line( line ) )
  2773.       end # // if current_action > -1
  2774.     end # // case line
  2775.   end
  2776.  
  2777.   #--------------------------------------------------------------------------#
  2778.   # * new-method :yggdrasil_1x6_cache_end
  2779.   #--------------------------------------------------------------------------#
  2780.   def yggdrasil_1x6_cache_end()
  2781.     @__current_action = nil ; @__pre_action = nil
  2782.   end
  2783.  
  2784. end  
  2785.  
  2786. #==============================================================================#
  2787. # ** YGG::Containers::GoldItem  
  2788. #==============================================================================#
  2789. class YGG::Containers::GoldItem
  2790.  
  2791.   #--------------------------------------------------------------------------#
  2792.   # * Public Instance Variable(s)
  2793.   #--------------------------------------------------------------------------#  
  2794.   attr_accessor :name
  2795.   attr_accessor :gold_amount
  2796.   attr_accessor :icon_index
  2797.   attr_accessor :pickup_sfx
  2798.  
  2799.   #--------------------------------------------------------------------------#
  2800.   # * new-method :initialize
  2801.   #--------------------------------------------------------------------------#
  2802.   def initialize( amt )
  2803.     @name        = ::Vocab.gold
  2804.     @gold_amount = amt
  2805.     @icon_index  = ::YGG::GOLD_DROP_ICON
  2806.     @pickup_sfx  = ::YGG::SOUND_MONEY
  2807.   end
  2808.  
  2809. end
  2810.  
  2811. #==============================================================================#
  2812. # ** YGG::Handlers::Engage
  2813. #==============================================================================#
  2814. class YGG::Handlers::Engage
  2815.  
  2816.   #--------------------------------------------------------------------------#
  2817.   # * Public Instance Variable(s)
  2818.   #--------------------------------------------------------------------------#
  2819.   attr_accessor :parent
  2820.   attr_accessor :bar_opacity
  2821.  
  2822.   #--------------------------------------------------------------------------#
  2823.   # * new-method :initialize
  2824.   #--------------------------------------------------------------------------#
  2825.   def initialize( parent )
  2826.     @parent      = parent
  2827.     @cool_down   = 0
  2828.     @bar_opacity = 255
  2829.   end
  2830.  
  2831.   #--------------------------------------------------------------------------#
  2832.   # * new-method :engage
  2833.   #--------------------------------------------------------------------------#
  2834.   def engage( cool_down )
  2835.     @cool_down   = cool_down
  2836.     @bar_opacity = 255
  2837.   end
  2838.  
  2839.   #--------------------------------------------------------------------------#
  2840.   # * new-method :engaged?
  2841.   #--------------------------------------------------------------------------#
  2842.   def engaged? ; return @cool_down > 0 ; end
  2843.  
  2844.   #--------------------------------------------------------------------------#
  2845.   # * new-method :update
  2846.   #--------------------------------------------------------------------------#
  2847.   def update()
  2848.     update_cool_down()
  2849.     update_bar_opacity()
  2850.   end
  2851.  
  2852.   #--------------------------------------------------------------------------#
  2853.   # * new-method :update_cool_down
  2854.   #--------------------------------------------------------------------------#
  2855.   def update_cool_down()
  2856.     @cool_down = [@cool_down-1, 0].max
  2857.   end
  2858.  
  2859.   #--------------------------------------------------------------------------#
  2860.   # * new-method :update_bar_opacity
  2861.   #--------------------------------------------------------------------------#
  2862.   def update_bar_opacity()
  2863.     if engaged?()
  2864.       @bar_opacity = [@bar_opacity+(255/60.0), 255].min
  2865.     else
  2866.       @bar_opacity = [@bar_opacity-(255/60.0), 0].max
  2867.     end  
  2868.   end
  2869.  
  2870. end
  2871.  
  2872. #==============================================================================#
  2873. # ** YGG::Handlers::Equip
  2874. #==============================================================================#
  2875. class YGG::Handlers::Equip < YGG::Pos
  2876.  
  2877.   #--------------------------------------------------------------------------#
  2878.   # * Public Instance Variable(s)
  2879.   #--------------------------------------------------------------------------#
  2880.   attr_accessor :parent
  2881.   attr_accessor :icon_index
  2882.   attr_accessor :eq_id
  2883.   attr_accessor :mirror
  2884.   attr_accessor :opacity, :visible
  2885.   attr_accessor :sox, :soy # // Sprite Offset
  2886.   attr_writer   :angle
  2887.  
  2888.   #--------------------------------------------------------------------------#
  2889.   # * new-method :angle_debug # // DEBUG
  2890.   #--------------------------------------------------------------------------#  
  2891.   def angle_debug()
  2892.     #@angle = (@angle + 1) % 360 if @eq_id == 0
  2893.     if Input.trigger?(Input::NUMBERS[1])
  2894.       @sox += 1
  2895.       puts @sox
  2896.     elsif Input.trigger?(Input::NUMBERS[2])
  2897.       @sox -= 1
  2898.       puts @sox
  2899.     elsif Input.trigger?(Input::NUMBERS[3])  
  2900.       @soy += 1
  2901.       puts @soy
  2902.     elsif Input.trigger?(Input::NUMBERS[4])  
  2903.       @soy -= 1
  2904.       puts @soy
  2905.     elsif Input.trigger?(Input::NUMBERS[5])  
  2906.       @sox = 0
  2907.       puts @sox  
  2908.     elsif Input.trigger?(Input::NUMBERS[6])  
  2909.       @soy = 0
  2910.       puts @soy
  2911.     end if @parent.is_a?(Game_Player) if @eq_id == 0
  2912.   end
  2913.  
  2914.   #--------------------------------------------------------------------------#
  2915.   # * new-method :initialize
  2916.   #--------------------------------------------------------------------------#
  2917.   def initialize( parent, eq_id )
  2918.     super( 0, 0, 0 )
  2919.     @parent       = parent
  2920.     @eq_id        = eq_id
  2921.     @icon_index   = @parent.equip_icon( @eq_id )
  2922.     @list         = []
  2923.     @list_index   = 0
  2924.     @sox, @soy    = 20, 20
  2925.     @visible      = false
  2926.     @mirror       = false
  2927.     @angle_offset = 0
  2928.     @angle_mult   = 1
  2929.     @attack_action= ""
  2930.     @guard_action = ""
  2931.     reset()
  2932.   end
  2933.  
  2934.   #--------------------------------------------------------------------------#
  2935.   # * new-method :angle
  2936.   #--------------------------------------------------------------------------#
  2937.   def angle ; return (@angle*@angle_mult)+@angle_offset ; end
  2938.    
  2939.   #--------------------------------------------------------------------------#
  2940.   # * new-method :reset
  2941.   #--------------------------------------------------------------------------#
  2942.   def reset()
  2943.     @wait_count   = 0
  2944.     @opacity      = 255
  2945.     @ox, @oy, @oz = 0, 0, 0
  2946.     @angle        = 0
  2947.   end
  2948.  
  2949.   #--------------------------------------------------------------------------#
  2950.   # * new-method :ox
  2951.   #--------------------------------------------------------------------------#
  2952.   def ox ; return @x + @ox + @sox ; end
  2953.   #--------------------------------------------------------------------------#
  2954.   # * new-method :oy
  2955.   #--------------------------------------------------------------------------#
  2956.   def oy ; return @y + @oy + @soy ; end
  2957.   #--------------------------------------------------------------------------#
  2958.   # * new-method :oz
  2959.   #--------------------------------------------------------------------------#  
  2960.   def oz ; return @z + @oz ; end
  2961.  
  2962.   #--------------------------------------------------------------------------#
  2963.   # * new-method :update
  2964.   #--------------------------------------------------------------------------#  
  2965.   def update()
  2966.     update_list()
  2967.     update_position()
  2968.   end
  2969.  
  2970.   #--------------------------------------------------------------------------#
  2971.   # * new-method :do_action
  2972.   #--------------------------------------------------------------------------#  
  2973.   def do_action( name )
  2974.     @icon_index    = @parent.equip_icon( @eq_id )    
  2975.     @list = ACTIONS[name].clone ; @list_index = 0
  2976.   end
  2977.  
  2978.   #--------------------------------------------------------------------------#
  2979.   # * new-method :do_attack
  2980.   #--------------------------------------------------------------------------#  
  2981.   def do_attack()
  2982.     @attack_action = @parent.equip_atk_act_name( @eq_id )
  2983.     do_action( @attack_action ) unless @attack_action == ""
  2984.   end
  2985.  
  2986.   #--------------------------------------------------------------------------#
  2987.   # * new-method :do_guard
  2988.   #--------------------------------------------------------------------------#  
  2989.   def do_guard()
  2990.     @guard_action  = @parent.equip_grd_act_name( @eq_id )
  2991.     do_action( @guard_action ) unless @guard_action == ""
  2992.   end
  2993.  
  2994.   #--------------------------------------------------------------------------#
  2995.   # * new-method :update_position
  2996.   #--------------------------------------------------------------------------#  
  2997.   def update_position()
  2998.     #self.angle_debug()
  2999.     case @eq_id
  3000.     when 0 # // Weapon
  3001.       oox, ooy = @ox, @oy
  3002.       case @parent.direction
  3003.       when 1 # // Down-Left
  3004.       when 2 # // Down
  3005.         @x, @y, @z = -28, -28, 20
  3006.         @sox, @soy    = 20, 20
  3007.         @ox, @oy = oox, ooy
  3008.         #@angle_offset = 0
  3009.         @angle_mult   = 1
  3010.         @mirror = false
  3011.       when 3 # // Down-Right  
  3012.       when 4 # // Left
  3013.         @x, @y, @z = -24, -28, -20
  3014.         @sox, @soy    = 20, 20
  3015.         @ox, @oy = -ooy, -oox
  3016.         #@angle_offset = 0
  3017.         @angle_mult   = 1
  3018.         @mirror = false
  3019.       when 6 # // Right
  3020.         @x, @y, @z = -4, -28, 20
  3021.         @sox, @soy    = 5, 20
  3022.         @ox, @oy = ooy, oox
  3023.         #@angle_offset = 0
  3024.         @angle_mult   = -1
  3025.         @mirror = true
  3026.       when 7 # // Up-Left  
  3027.       when 8 # // Up
  3028.         @x, @y, @z = 4, -28, -20
  3029.         @sox, @soy    = 5, 20
  3030.         @ox, @oy = -oox, ooy
  3031.         #@angle_offset = 0
  3032.         @angle_mult   = -1
  3033.         @mirror = true
  3034.       when 9 # // Up-Right
  3035.       end  
  3036.     when 1 # // Shield
  3037.       case @parent.direction
  3038.       when 1 # // Down-Left
  3039.       when 2 # // Down
  3040.         @x, @y, @z = 0, -24, 20
  3041.         @mirror = true
  3042.       when 3 # // Down-Right  
  3043.       when 4 # // Left
  3044.         @x, @y, @z = -16, -24, 20
  3045.         @mirror = false
  3046.       when 6 # // Right
  3047.         @x, @y, @z = -4, -28, -20
  3048.         @mirror = true
  3049.       when 7 # // Up-Left  
  3050.       when 8 # // Up
  3051.         @x, @y, @z = -24, -24, -20
  3052.         @mirror = false
  3053.       when 9 # // Up-Right
  3054.       end  
  3055.     end  
  3056.   end
  3057.  
  3058.   #--------------------------------------------------------------------------#
  3059.   # * new-method :update_list
  3060.   #--------------------------------------------------------------------------#  
  3061.   def update_list()
  3062.     @wait_count = [@wait_count - 1, 0].max
  3063.     return unless @wait_count == 0
  3064.     while @list_index < @list.size
  3065.       ret_value = -1
  3066.       act = @list[@list_index]
  3067.       case act[0].upcase
  3068.       when "MOVE"
  3069.         case act[1].upcase
  3070.         when "X" ; @ox = act[2]
  3071.         when "Y" ; @oy = act[2]
  3072.         when "Z" ; @oz = act[2] # // For whatever reason
  3073.         end  
  3074.         ret_value = 0
  3075.       when "CHANGEANGLE", "CHANGE_ANGLE", "CHANGE ANGLE"
  3076.         @angle = act[1]
  3077.         ret_value = 0
  3078.       when "RESET"
  3079.         reset()
  3080.         ret_value = 0
  3081.       when "CHANGEOPACITY", "CHANGE_OPACITY", "CHANGE OPACITY"  
  3082.         @opacity = act[1]
  3083.         ret_value = 0
  3084.       when "SHOW"  
  3085.         @visible = true
  3086.         ret_value = 0
  3087.       when "HIDE"  
  3088.         @visible = false
  3089.         ret_value = 0
  3090.       when "WAIT FOR GUARD"  
  3091.         return if @parent.guard_time > 0
  3092.         ret_value = 0
  3093.       when "WAIT"  
  3094.         @wait_count = act[1]
  3095.         ret_value = 1
  3096.       end  
  3097.       @list_index += 1
  3098.       return if ret_value == 1
  3099.     end  
  3100.   end
  3101.  
  3102. end
  3103.  
  3104. #==============================================================================#
  3105. # ** YGG::Handlers::BattleObj
  3106. #==============================================================================#
  3107. class YGG::Handlers::BattleObj
  3108.  
  3109.   #--------------------------------------------------------------------------#
  3110.   # * Public Instance Variable(s)
  3111.   #--------------------------------------------------------------------------#  
  3112.   attr_accessor :obj_id
  3113.   attr_accessor :type
  3114.  
  3115.   #--------------------------------------------------------------------------#
  3116.   # * new-method :initialize
  3117.   #--------------------------------------------------------------------------#  
  3118.   def initialize( id, type )
  3119.     @obj_id, @type = id, type ; @charge_time = 0 ;
  3120.     @dummy_obj = RPG::BaseItem.new() ; @dummy_obj.yggdrasil_1x6_cache()
  3121.   end
  3122.  
  3123.   #--------------------------------------------------------------------------#
  3124.   # * new-method :skill
  3125.   #--------------------------------------------------------------------------#  
  3126.   def skill()
  3127.     return @type == :skill ? $data_skills[@obj_id] : nil
  3128.   end
  3129.  
  3130.   #--------------------------------------------------------------------------#
  3131.   # * new-method :item
  3132.   #--------------------------------------------------------------------------#
  3133.   def item()
  3134.     return @type == :item ? $data_items[@obj_id] : nil
  3135.   end
  3136.  
  3137.   #--------------------------------------------------------------------------#
  3138.   # * new-method :obj
  3139.   #--------------------------------------------------------------------------#  
  3140.   def obj()
  3141.     return item() || skill() || @dummy_obj
  3142.   end
  3143.  
  3144.   #--------------------------------------------------------------------------#
  3145.   # * new-method :reset_time
  3146.   #--------------------------------------------------------------------------#  
  3147.   def reset_time()
  3148.     @charge_time = cap
  3149.   end
  3150.  
  3151.   #--------------------------------------------------------------------------#
  3152.   # * new-method :time
  3153.   #--------------------------------------------------------------------------#  
  3154.   def time()
  3155.     return @charge_time
  3156.   end
  3157.  
  3158.   #--------------------------------------------------------------------------#
  3159.   # * new-method :cap
  3160.   #--------------------------------------------------------------------------#  
  3161.   def cap()
  3162.     return obj.charge_cap
  3163.   end
  3164.  
  3165.   #--------------------------------------------------------------------------#
  3166.   # * new-method :can_use?
  3167.   #--------------------------------------------------------------------------#  
  3168.   def can_use?() ; return @charge_time == 0 ; end
  3169.  
  3170.   #--------------------------------------------------------------------------#
  3171.   # * new-method :update
  3172.   #--------------------------------------------------------------------------#  
  3173.   def update()
  3174.     @charge_time = [@charge_time - 1, 0].max
  3175.   end
  3176.  
  3177. end
  3178.  
  3179. #==============================================================================#
  3180. # ** YGG::System (Battle Edits)
  3181. #==============================================================================#
  3182. class YGG::System
  3183.  
  3184.   #--------------------------------------------------------------------------#
  3185.   # * new-method :action_attack
  3186.   #--------------------------------------------------------------------------#  
  3187.   def action_attack( user_ev, targets_ev )
  3188.     user = user_ev.ygg_battler
  3189.     targets_ev.each { |target|
  3190.       next if target.ygg_invincible
  3191.       bat = target.ygg_battler
  3192.       next if bat.nil?()
  3193.       bat.ygg_guard = target.guard_time > 0
  3194.       bat.attack_effect( user )
  3195.       target.ygg_engage.engage( 180 )
  3196.       YGG::PopText.create_pop( { :character => target, :type => :attack_damage } ) if target.pop_enabled?() if YGG::USE_TEXT_POP        
  3197.       action_gain_exp( user, bat, user_ev, YGG::POP_EXP ) unless bat.actor?() if user.actor?()
  3198.       bat.ygg_guard = false
  3199.     }
  3200.   end
  3201.  
  3202.   #--------------------------------------------------------------------------#
  3203.   # * new-method :action_skill
  3204.   #--------------------------------------------------------------------------#  
  3205.   def action_skill( user_ev, targets_ev, obj )
  3206.     targets = targets_ev.inject([]) { |r, e| r << e.ygg_battler }
  3207.     targets.compact!() ; user = user_ev.ygg_battler
  3208.     targets_ev.each { |target|
  3209.       next if target.ygg_invincible
  3210.       bat = target.ygg_battler
  3211.       next if bat.nil?()
  3212.       bat.ygg_guard = target.guard_time > 0 && obj.guardable
  3213.       bat.skill_effect( user, obj )
  3214.       target.ygg_engage.engage( 180 )
  3215.       YGG::PopText.create_pop( { :character => target, :type => :skill_damage } ) if target.pop_enabled?() if YGG::USE_TEXT_POP              
  3216.       action_gain_exp( user, bat, user_ev, YGG::POP_EXP ) unless bat.actor?() if user.actor?()
  3217.       bat.ygg_guard = false
  3218.     }
  3219.   end
  3220.  
  3221.   #--------------------------------------------------------------------------#
  3222.   # * new-method :action_item
  3223.   #--------------------------------------------------------------------------#  
  3224.   def action_item( user_ev, targets_ev, obj )
  3225.     targets = targets_ev.inject([]) { |r, e| r << e.ygg_battler }
  3226.     targets.compact!() ; user = user_ev.ygg_battler
  3227.     targets_ev.each { |target|
  3228.       next if target.ygg_invincible
  3229.       bat = target.ygg_battler
  3230.       next if bat.nil?()
  3231.       bat.ygg_guard = target.guard_time > 0 && obj.guardable
  3232.       bat.item_effect( user, obj )
  3233.       target.ygg_engage.engage( 180 )
  3234.       YGG::PopText.create_pop( { :character => target, :type => :item_damage } ) if target.pop_enabled?() if YGG::USE_TEXT_POP              
  3235.       action_gain_exp( user, bat, user_ev, YGG::POP_EXP ) unless bat.actor?() if user.actor?()
  3236.       bat.ygg_guard = false
  3237.     }
  3238.   end
  3239.  
  3240.   #--------------------------------------------------------------------------#
  3241.   # * new-method :action_gain_exp
  3242.   #--------------------------------------------------------------------------#  
  3243.   def action_gain_exp( receivee, bat, event=nil, show=true )
  3244.     case YGG::EXP_GAINING_METHOD
  3245.     when 0 # // Dead
  3246.       return unless bat.dead?()
  3247.       exp = bat.exp
  3248.     when 1 # // Per Hit
  3249.       exp = YGG::EXP_PER_HIT_FORMULA.call(
  3250.         bat.hp_damage+receivee.mp_damage, receivee, bat )
  3251.     end  
  3252.     old_level = receivee.level
  3253.     case YGG::EXP_SAHRE_METHOD
  3254.     when 0 # Active Member Only
  3255.       receivee.gain_exp( exp, false )
  3256.     when 1 # All Members Equal
  3257.       ($game_party.members-[receivee]).each { |mem| mem.gain_exp( exp, false ) }
  3258.       receivee.gain_exp( exp, false )
  3259.     when 2 # All Members Split
  3260.       mems = ($game_party.members-[receivee])
  3261.       exp /= mems.size+1
  3262.       mems.each { |mem| mem.gain_exp( exp, false ) }
  3263.       receivee.gain_exp( exp, false )
  3264.     end          
  3265.     action_level_up( receivee, old_level, event, YGG::POP_LEVEL_UP ) if old_level != receivee.level
  3266.     unless event.nil?()
  3267.       ::YGG::PopText.create_pop(
  3268.         { :character => event, :type => :gain_exp, :parameters => [exp] }
  3269.       ) if YGG::USE_TEXT_POP                
  3270.     end if show
  3271.   end
  3272.  
  3273.   #--------------------------------------------------------------------------#
  3274.   # * new-method :action_level_up
  3275.   #--------------------------------------------------------------------------#
  3276.   def action_level_up( receivee, old_level, event=nil, show=true )
  3277.     $scene.level_up_window.show_level_up( receivee, old_level ) if YGG::USE_LEVEL_UP_WINDOW > 0
  3278.     unless event.nil?()
  3279.       if ::YGG::LEVEL_UP_ALERT
  3280.         event.ygg_anims << ::YGG::ANIM_ON_LEVEL unless ::YGG::ANIM_ON_LEVEL == 0
  3281.       end  
  3282.       ::YGG::PopText.create_pop(
  3283.         { :character => event, :type => :level_up, :parameters => [old_level] }
  3284.       ) if show if YGG::USE_TEXT_POP              
  3285.     end
  3286.   end
  3287.  
  3288. end
  3289.  
  3290. #==============================================================================#
  3291. # ** YGG::Handlers::Action
  3292. #==============================================================================#
  3293. class YGG::Handlers::Action
  3294.  
  3295.   #--------------------------------------------------------------------------#
  3296.   # * Public Instance Variable(s)
  3297.   #--------------------------------------------------------------------------#  
  3298.   attr_accessor :list
  3299.   attr_accessor :list_stack
  3300.   attr_accessor :skill_id, :item_id
  3301.   attr_accessor :user_event
  3302.   attr_accessor :target_events
  3303.   attr_accessor :parent_event
  3304.  
  3305.   #--------------------------------------------------------------------------#
  3306.   # * new-method :initialize
  3307.   #--------------------------------------------------------------------------#  
  3308.   def initialize( parent, list=[] )
  3309.     @parent_event = parent
  3310.     @interpreter  = ::Game_Interpreter.new()
  3311.     @list_stack   = [] ; setup( list ) ; execute( nil, [], { :skip_first_update=>true } )
  3312.   end
  3313.  
  3314.   #--------------------------------------------------------------------------#
  3315.   # * new-method :setup
  3316.   #--------------------------------------------------------------------------#  
  3317.   def setup( list=[] )
  3318.     @list        = list.clone
  3319.     @active_list = @list.clone
  3320.   end
  3321.  
  3322.   #--------------------------------------------------------------------------#
  3323.   # * new-method :busy?
  3324.   #--------------------------------------------------------------------------#  
  3325.   def busy?()
  3326.     return @list_index < @active_list.size || @interpreter.running?()
  3327.   end
  3328.  
  3329.   #--------------------------------------------------------------------------#
  3330.   # * new-method :execute
  3331.   #--------------------------------------------------------------------------#  
  3332.   def execute( user_event, starting_targets=[], start_values={} )
  3333.     @active_list    = @list.clone
  3334.     @wait_count     = start_values[:wait_count] || 0
  3335.     @skill_id       = start_values[:skill_id] || 0
  3336.     @item_id        = start_values[:item_id] || 0
  3337.     @range          = start_values[:range] || []
  3338.     @target_events  = starting_targets
  3339.     @user_event     = user_event
  3340.     @wait_for_comev = false
  3341.     @list_index     = 0
  3342.     update() unless start_values[:skip_first_update]
  3343.   end
  3344.  
  3345.   #--------------------------------------------------------------------------#
  3346.   # * new-method :update
  3347.   #--------------------------------------------------------------------------#  
  3348.   def update()
  3349.     @interpreter.update()
  3350.     return if @interpreter.running?() && @wait_for_comev
  3351.     @wait_count = [@wait_count-1, 0].max
  3352.     update_action() if @wait_count == 0
  3353.   end
  3354.  
  3355.   #--------------------------------------------------------------------------#
  3356.   # * new-method :update_action
  3357.   #--------------------------------------------------------------------------#  
  3358.   def update_action()
  3359.     unless @list_stack.empty?()
  3360.       setup( @list_stack.shift() )
  3361.       execute( @user_event, @target_events,
  3362.        {
  3363.         :skill_id => @skill_id,
  3364.         :item_id  => @item_id,
  3365.         :range    => @range
  3366.        }
  3367.       )
  3368.     end if @list_index >= @active_list.size
  3369.     while @list_index < @active_list.size
  3370.       #break if act_set.nil?()
  3371.       @action, @parameters = *@active_list[@list_index]
  3372.       #for i in 0...@parameters.size() ; @parameters[i] = @parameters[i].to_s() ; end
  3373.       act_result = -1
  3374.       #puts sprintf("ACTION: %s", @action)
  3375.       #puts sprintf("PARAMETERS: %s", @parameters)
  3376.       case @action.upcase()
  3377.       # // action: action_name
  3378.       when "ACTION", "ACTIONLIST", "ACTION LIST", "ACTION_LIST"
  3379.         act_result = action_actionlist( @action, @parameters )
  3380.       when "ANIMATION"
  3381.         act_result = action_animation( @action, @parameters )
  3382.       when "COMMONEVENT", "COMMON_EVENT", "COMMON EVENT"  
  3383.         act_result = action_common_event( @action, @parameters )
  3384.       when "ATTACKEFFECT", "ATTACK_EFFECT", "ATTACK EFFECT"
  3385.         act_result = action_effect( @action, @parameters )
  3386.       when "SKILLEFFECT", "SKILL_EFFECT", "SKILL EFFECT"
  3387.         act_result = action_effect( @action, @parameters )
  3388.       when "ITEMEFFECT", "ITEM_EFFECT", "ITEM EFFECT"  
  3389.         act_result = action_effect( @action, @parameters )
  3390.       when "OBJEFFECT", "OBJ_EFFECT", "OBJ EFFECT"    
  3391.         eff = @skill_id > 0 ? "SKILL_EFFECT" : nil
  3392.         eff = @item_id > 0 ? "ITEM_EFFECT" : "" if eff.nil?()
  3393.         act_result = action_effect( eff, @parameters+["PRESET"] )
  3394.       when "GUARD"  
  3395.         act_result = action_guard( @action, @parameters )
  3396.       when "CHARGE", "COOLDOWN"  
  3397.         act_result = action_charge( @action, @parameters )
  3398.       when "RANGE"  
  3399.         act_result = action_range( @action, @parameters )
  3400.       when "TARGET"  
  3401.         action_target( @action, @parameters )
  3402.         act_result = 0
  3403.       when "SUBTARGET"
  3404.         act_result = action_subtargets( @action, @parameters )  
  3405.       when "TARGET_SELECT", "TARGET SELECT", "TARGETSELECT"
  3406.         act_result = action_target_select( @action, @parameters )
  3407.       when "SET_ORIGIN", "SET ORIGIN", "SETORIGIN"
  3408.         act_result = action_origin( @action, @parameters )
  3409.       when "MOVE"  
  3410.         act_result = action_move( @action, @parameters )
  3411.       when "JUMP"  
  3412.         act_result = action_jump( @action, @parameters )  
  3413.       when "SETITEM", "SET_ITEM", "SET ITEM"  
  3414.         act_result = action_set_item( @action, @parameters )
  3415.       when "SETSKILL", "SET_SKILL", "SET SKILL"  
  3416.         act_result = action_set_skill( @action, @parameters )
  3417.       when "PROJECTILE"  
  3418.         act_result = action_projectile( @action, @parameters )
  3419.       when "SCRIPT"  
  3420.         act_result = action_script( @action, @parameters )
  3421.       when "THROUGH"  
  3422.         act_result = action_through( @action, @parameters )
  3423.       when "PARENTWAIT", "PARENT_WAIT", "PARENT WAIT"  
  3424.         act_result = action_parent_wait( @action, @parameters )
  3425.       when "WAIT", "WAIT_FOR_EVENT", "WAIT FOR ANIMATION"
  3426.         act_result = action_wait( @action, @parameters )
  3427.       else
  3428.         act_result = extended_actions( @action, @parameters )
  3429.       end
  3430.       if act_result == -1
  3431.         puts "ERROR: -1 returned for action #{self}"
  3432.       else
  3433.         puts "BING: #{act_result} returned for action #{self}"
  3434.       end if YGG.debug_mode?
  3435.       @list_index += 1
  3436.       break if act_result == 1
  3437.     end
  3438.   end
  3439.  
  3440.   #--------------------------------------------------------------------------#
  3441.   # * new-method :extended_actions
  3442.   #--------------------------------------------------------------------------#  
  3443.   def extended_actions( action, parameters )
  3444.   end
  3445.  
  3446.   #--------------------------------------------------------------------------#
  3447.   # * new-method :action_set_skill
  3448.   #--------------------------------------------------------------------------#  
  3449.   def action_set_skill( action, parameters )
  3450.     @skill_id = parameters[0].to_i
  3451.     return 0
  3452.   end  
  3453.  
  3454.   #--------------------------------------------------------------------------#
  3455.   # * new-method :action_set_item
  3456.   #--------------------------------------------------------------------------#  
  3457.   def action_set_item( action, parameters )
  3458.     @item_id = parameters[0].to_i
  3459.     return 0
  3460.   end  
  3461.  
  3462.   #--------------------------------------------------------------------------#
  3463.   # * new-method :action_actionlist
  3464.   #--------------------------------------------------------------------------#  
  3465.   def action_actionlist( action, parameters )
  3466.     @active_list = @active_list.slice(0, @list_index) +
  3467.       ::YGG.get_action_list( parameters[0] ) +
  3468.       @active_list.slice( @list_index, @active_list.size )
  3469.     return 0
  3470.   end  
  3471.  
  3472.   #--------------------------------------------------------------------------#
  3473.   # * new-method :action_animation
  3474.   #--------------------------------------------------------------------------#              
  3475.   def action_animation( action, parameters )
  3476.     p0 = parameters[0].to_s.upcase()
  3477.     p1 = parameters[1].upcase()
  3478.     p2 = parameters[2].upcase()
  3479.    
  3480.     id = 0
  3481.     case p0
  3482.     when "OBJ"
  3483.       id = $data_skills[@skill_id].animation_id if @skill_id > 0
  3484.       id = $data_items[@item_id].animation_id    if @item_id > 0
  3485.       id = @user_event.ygg_battler.atk_animation_id() if id == -1
  3486.     when "ATK", "ATTACK"  
  3487.       id = @user_event.ygg_battler.atk_animation_id()
  3488.     else
  3489.       id = p0.to_i
  3490.     end  
  3491.    
  3492.     case p1  
  3493.     when "POS"  
  3494.       event = @user_event
  3495.       x, y = *YGG.offset_xy(
  3496.        event.x, event.y,
  3497.        [parameters[3].to_i(), parameters[4].to_i()],
  3498.        event.direction )
  3499.       targets = action_target( "TARGET", ["MAP_XY", x, y], true )
  3500.       case p2
  3501.       when "NORMAL"
  3502.         targets.each { |t| t.animation_id = id }
  3503.       when "WILD"    
  3504.         $scene.push_ygg_anim( id, x, y, targets, false ) if $scene.is_a?( Scene_Map )
  3505.       end
  3506.     else
  3507.       action_target( "TARGET", [p1] ).each { |t|
  3508.         case p2
  3509.         when "NORMAL" ; t.animation_id = id
  3510.         when "WILD"   ; t.ygg_anims.push( id )
  3511.         end
  3512.       }  
  3513.     end
  3514.     return 0
  3515.   end
  3516.  
  3517.   #--------------------------------------------------------------------------#
  3518.   # * new-method :action_origin
  3519.   #--------------------------------------------------------------------------#  
  3520.   def action_origin( action, parameters )
  3521.     action_target( "TARGET", parameters, true ).each { |character|
  3522.       character.set_orgin() }
  3523.   end  
  3524.    
  3525.   #--------------------------------------------------------------------------#
  3526.   # * new-method :action_move
  3527.   #--------------------------------------------------------------------------#    
  3528.   def action_move( action, parameters )
  3529.     targets = action_target( "TARGET", [parameters[0]], true )
  3530.     targets.each { |character|
  3531.       case parameters[1].upcase
  3532.       when "FORWARD"
  3533.         character.move_forward()
  3534.       when "BACKWARD"
  3535.         character.move_backward()  
  3536.       when "UP"
  3537.         character.move_up()
  3538.       when "DOWN"
  3539.         character.move_down()
  3540.       when "LEFT"
  3541.         character.move_left()
  3542.       when "RIGHT"
  3543.         character.move_right()
  3544.       when "TO"  
  3545.         case parameters[2]
  3546.         when "ORIGIN"
  3547.           character.moveto( character.origin.x, character.origin.y )
  3548.         else
  3549.           prms = parameters.slice( 2, parameters.size )
  3550.           action_targets( "TARGET", prms, true ).each { |target|
  3551.             character.moveto( target.x, target.y )
  3552.           }
  3553.         end  
  3554.       when "TOXY", "TO_XY", "TO XY"  
  3555.         dist, sway = parameters[2], parameters[3]
  3556.         case character.direction
  3557.         when 2 # // Down
  3558.           x, y = character.x+sway, character.y+dist
  3559.         when 4 # // Left
  3560.           x, y = character.x-dist, character.y+sway
  3561.         when 6 # // Right
  3562.           x, y = character.x+dist, character.y-sway
  3563.         when 8 # // Up
  3564.           x, y = character.x-sway, character.y-dist
  3565.         end
  3566.         character.moveto( x, y )
  3567.       when "TOMAPXY", "TO_MAP_XY", "TO MAP XY"  
  3568.         character.moveto( parameters[2].to_i, parameters[3].to_i )
  3569.       when "TURNUP", "TURN_UP", "TURN UP"
  3570.         character.turn_up()
  3571.       when "TURNDOWN", "TURN_DOWN", "TURN DOWN"
  3572.         character.turn_down()
  3573.       when "TURNLEFT", "TURN_LEFT", "TURN LEFT"
  3574.         character.turn_left()
  3575.       when "TURNRIGHT", "TURN_RIGHT", "TURN RIGHT"
  3576.         character.turn_right()
  3577.       when "TURNRIGHT90", "TURN_RIGHT_90", "TURN RIGHT 90"
  3578.         character.turn_right_90()
  3579.       when "TURNLEFT90", "TURN_LEFT_90", "TURN LEFT 90"
  3580.         character.turn_left_90()  
  3581.       when "TURN180", "TURN_180", "TURN 180"
  3582.         character.turn_180()
  3583.       when "TURNTO", "TURN_TO", "TURN TO"
  3584.         prms = parameters.slice( 2, parameters.size )
  3585.         action_targets( "TARGET", prms, true ).each { |target|
  3586.           character.turn_to_coord( target.x, target.y ) }
  3587.       end
  3588.     }  
  3589.     return 0
  3590.   end
  3591.  
  3592.   #--------------------------------------------------------------------------#
  3593.   # * new-method :action_jump
  3594.   #--------------------------------------------------------------------------#    
  3595.   def action_jump( action, parameters )  
  3596.     users = action_target( "TARGET", parameters[0], true )
  3597.     users.each { |character|
  3598.       case parameters[1].upcase
  3599.       when "XY"
  3600.         character.jump( parameters[2].to_i, parameters[3].to_i )
  3601.       else
  3602.         action_target( "TARGET", parameters[1], true ).each { |t|
  3603.           character.jump_to_char( t )
  3604.         }
  3605.       end  
  3606.     }
  3607.     return 0
  3608.   end
  3609.  
  3610.   #--------------------------------------------------------------------------#
  3611.   # * new-method :action_charge
  3612.   #--------------------------------------------------------------------------#    
  3613.   def action_charge( action, parameters )
  3614.     targets = action_target( "TARGET", parameters[0], true )
  3615.     value = parameters[2].upcase == "MAX" ? t.ygg_battler.cooldown_max : parameters[2].to_i
  3616.     case parameters[1].upcase
  3617.     when "ADD"
  3618.       targets.each { |t| t.ygg_battler.cooldown += value }
  3619.     when "SUB"  
  3620.       targets.each { |t| t.ygg_battler.cooldown -= value }
  3621.     when "SET"  
  3622.       targets.each { |t| t.ygg_battler.cooldown  = value }
  3623.     end  
  3624.     return 0
  3625.   end
  3626.  
  3627.   #--------------------------------------------------------------------------#
  3628.   # * new-method :action_common_event
  3629.   #--------------------------------------------------------------------------#  
  3630.   def action_common_event( action, parameters )
  3631.     case parameters[0].upcase
  3632.     when "SKILL"
  3633.       common_event_id = $data_skills[parameters[1].to_i].common_event_id
  3634.     when "ITEM"  
  3635.       common_event_id = $data_items[parameters[1].to_i].common_event_id
  3636.     when "OBJ"  
  3637.       if @skill_id > 0
  3638.         action_common_event( "COMMON_EVENT", ["SKILL", @skill_id, parameters[2]] )
  3639.       elsif @item_id > 0
  3640.         action_common_event( "COMMON_EVENT", ["ITEM", @item_id, parameters[2]] )
  3641.       end  
  3642.       return
  3643.     when "ID"  
  3644.       common_event_id = parameters[1].to_i
  3645.     end  
  3646.     @interpreter.setup( $data_common_events[common_event_id].list )
  3647.     @wait_for_comev = parameters[2].to_s.upcase == "WAIT"
  3648.     return @wait_for_comev ? 1 : 0
  3649.   end
  3650.  
  3651.   #--------------------------------------------------------------------------#
  3652.   # * new-method :action_range
  3653.   #--------------------------------------------------------------------------#      
  3654.   def action_range( action, parameters )
  3655.     case parameters[0].upcase
  3656.     when "ADD"
  3657.       @range.push( [ parameters[1].to_i, parameters[2].to_i ] )
  3658.     when "SUB"  
  3659.       @range -= [[ parameters[1].to_i, parameters[2].to_i ]]
  3660.     when "CLEAR"  
  3661.       @range.clear()
  3662.     when "CREATE"  
  3663.       rng, minrng, type = parameters[1].to_i, parameters[2].to_i, parameters[3].to_i
  3664.       target = action_target( "TARGET", [parameters[4].to_s], true )[0]
  3665.       direction = target.nil?() ? parameters[4].to_i : target.direction
  3666.       @range = YGG.create_range_data( rng, minrng, type, direction )
  3667.     end  
  3668.     return 0
  3669.   end  
  3670.  
  3671.   #--------------------------------------------------------------------------#
  3672.   # * new-method :action_target
  3673.   #--------------------------------------------------------------------------#          
  3674.   def action_target( action, parameters, return_only=false )
  3675.     raise "Parameter is not an array" unless parameters.is_a?( Array )
  3676.     targets = []
  3677.     case parameters[0].upcase()
  3678.     when "PARENT"
  3679.       targets = [ @parent_event ]
  3680.     when "USER"
  3681.       targets = [ @user_event ]
  3682.     when "TARGET"  
  3683.       targets = [ @target_events[0] ]
  3684.     when "TARGETS"  
  3685.       targets = @target_events
  3686.     when "ALLIES"  
  3687.       targets = @target_events.inject([]) { |r, e| r.push( e ) if @user_event.ally_character?( e ) ; r }
  3688.     when "ENEMIES"  
  3689.       targets = @target_events.inject([]) { |r, e| r.push( e ) if @user_event.enemy_character?( e ) ; r }
  3690.     when "RANDTARGET"  
  3691.       targets = action_target( "TARGET", ["TARGETS"], true )
  3692.       targets = [targets[rand(targets.size)]]
  3693.     when "RANDALLY"  
  3694.       targets = action_target( "TARGET", ["ALLIES"], true )
  3695.       targets = [targets[rand(targets.size)]]  
  3696.     when "RANDENEMY"  
  3697.       targets = action_target( "TARGET", ["ENEMIES"], true )
  3698.       targets = [targets[rand(targets.size)]]    
  3699.     when "SCREEN", "ONSCREEN", "ON_SCREEN"  
  3700.       $game_yggdrasil.battlers.each { |ev|
  3701.         targets.push( ev ) if ev.limitedOnScreen?()
  3702.       }
  3703.     when "OFFSCREEN", "OFF_SCREEN"  
  3704.       $game_yggdrasil.battlers.each { |ev|
  3705.         targets.push( ev ) if !ev.limitedOnScreen?()
  3706.       }
  3707.     when "MAP_XY"
  3708.       xy_list = [ [parameters[1].to_i, parameters[2].to_i] ]
  3709.       targets = @user_event.get_target_events( xy_list )
  3710.     when "XY"  
  3711.       xy_list = [ [parameters[1].to_i, parameters[2].to_i] ]
  3712.       xy_list = YGG::offset_xy_list( @user_event.x, @user_event.y, xy_list, @user_event.direction )
  3713.       targets = @user_event.get_target_events( xy_list )
  3714.     when "RANGE"  
  3715.       xy_list = @range
  3716.       xy_list = YGG::offset_xy_list( @user_event.x, @user_event.y, xy_list, @user_event.direction )
  3717.       targets = @user_event.get_target_events( xy_list )
  3718.     end
  3719.     targets = targets.compact.uniq
  3720.     @target_events = targets unless return_only
  3721.     return targets
  3722.   end
  3723.  
  3724.   #--------------------------------------------------------------------------#
  3725.   # * new-method :action_subtargets
  3726.   #--------------------------------------------------------------------------#  
  3727.   def action_subtargets( action, parameters )
  3728.     @target_events -= action_target( "TARGET", parameters, true )
  3729.     return 0
  3730.   end
  3731.  
  3732.   #--------------------------------------------------------------------------#
  3733.   # * new-method :action_target_select
  3734.   #--------------------------------------------------------------------------#  
  3735.   def action_target_select( action, parameters )
  3736.     if @parent_event.ai_operated?()
  3737.       targs = action_target( "TARGET", parameters.slice( 1, parameters.size ) ).sort_by { rand }
  3738.       result = [] ; for i in 0...parameters[0].to_i ; result.push( targs[i] ) ; end
  3739.       @target_events = result.compact.uniq
  3740.     else  
  3741.       @target_events = $game_yggdrasil.start_target_selection( parameters[0].to_i,
  3742.         action_target( "TARGET", parameters.slice( 1, parameters.size ), true ) )
  3743.     end    
  3744.     return 0
  3745.   end
  3746.  
  3747.   #--------------------------------------------------------------------------#
  3748.   # * new-method :action_effect
  3749.   #--------------------------------------------------------------------------#            
  3750.   def action_effect( action, parameters )
  3751.     users   = action_target( "TARGET", [parameters[0]], true )
  3752.     targets = action_target( "TARGET", [parameters[1]], true )
  3753.     case action.upcase()
  3754.     when "ATTACKEFFECT", "ATTACK_EFFECT", "ATTACK EFFECT"
  3755.       users.each { |user|
  3756.         user.equip_handle( 0 ).do_attack()
  3757.         $game_yggdrasil.action_attack( user, targets )
  3758.       }  
  3759.     when "SKILLEFFECT", "SKILL_EFFECT", "SKILL EFFECT"  
  3760.       users.each { |user|
  3761.         case parameters[2].upcase()
  3762.         when "PRESET", "OBJ"
  3763.           sid = @skill_id
  3764.         else ; sid = parameters[2].to_i
  3765.         end  
  3766.         $game_yggdrasil.action_skill( user, targets, $data_skills[sid] )
  3767.       }  
  3768.     when "ITEMEFFECT", "ITEM_EFFECT", "ITEM EFFECT"  
  3769.       users.each { |user|
  3770.         case parameters[2].upcase()
  3771.         when "PRESET", "OBJ"
  3772.           iid = @item_id
  3773.         else ; iid = parameters[2].to_i
  3774.         end  
  3775.         $game_yggdrasil.action_item( user, targets, $data_items[iid] )
  3776.       }  
  3777.     end  
  3778.     return 0
  3779.   end
  3780.  
  3781.   #--------------------------------------------------------------------------#
  3782.   # * new-method :action_guard
  3783.   #--------------------------------------------------------------------------#                  
  3784.   def action_guard( action, parameters )
  3785.     @user_event.guard_time = parameters[0].to_i
  3786.     @user_event.equip_handle( 1 ).do_guard()
  3787.   end
  3788.  
  3789.   #--------------------------------------------------------------------------#
  3790.   # * new-method :action_projectile
  3791.   #--------------------------------------------------------------------------#                  
  3792.   def action_projectile( action, parameters )
  3793.     users = action_target( "TARGET", [parameters[0]], true )
  3794.     case parameters[1].upcase
  3795.     when "PARENT"
  3796.       direction = action_target( "TARGET", ["PARENT"], true )[0].direction
  3797.     when "USER"
  3798.       direction = action_target( "TARGET", ["USER"], true )[0].direction
  3799.     when "TARGET"  
  3800.       direction = action_target( "TARGET", ["TARGET"], true )[0].direction
  3801.     else  
  3802.       direction = parameters[1].to_i
  3803.     end  
  3804.     projectile = ::YGG::PROJECTILE_MAP[parameters[2].to_s]
  3805.     setup_code = ::YGG::PROJETILE_SETUP[parameters[3].to_s]
  3806.     users.each { |user|
  3807.       pro = projectile.new( user, setup_code )
  3808.       pro.moveto( user.x, user.y ) ; pro.set_direction( direction )
  3809.       $game_yggdrasil.add_projectile( pro )
  3810.     }  
  3811.     return 0
  3812.   end
  3813.  
  3814.   #--------------------------------------------------------------------------#
  3815.   # * new-method :action_script
  3816.   #--------------------------------------------------------------------------#                  
  3817.   def action_script( action, parameters )
  3818.     user    = action_target( "TARGET", ["USER"] )
  3819.     target  = action_target( "TARGET", ["TARGET"] )
  3820.     targets = action_target( "TARGET", ["TARGETS"] )
  3821.     eval( parameters.to_s )
  3822.     return 0
  3823.   end
  3824.  
  3825.   #--------------------------------------------------------------------------#
  3826.   # * new-method :action_through
  3827.   #--------------------------------------------------------------------------#                  
  3828.   def action_through( action, parameters )
  3829.     targets = action_target( "TARGET", [parameters[0]] )
  3830.     case parameters[1].upcase
  3831.     when "TRUE", "ON", "YES"
  3832.       targets.each { |t| t.set_through( true ) }
  3833.     when "FALSE", "OFF", "NO"
  3834.       targets.each { |t| t.set_through( false ) }
  3835.     end
  3836.     return 0
  3837.   end
  3838.  
  3839.   #--------------------------------------------------------------------------#
  3840.   # * new-method :action_parent_wait
  3841.   #--------------------------------------------------------------------------#                  
  3842.   def action_parent_wait( action, parameters )
  3843.     @user_event.wait_count = parameters[0].to_i
  3844.   end
  3845.  
  3846.   #--------------------------------------------------------------------------#
  3847.   # * new-method :action_wait
  3848.   #--------------------------------------------------------------------------#                  
  3849.   def action_wait( action, parameters )
  3850.     case action.upcase
  3851.     when "WAIT FOR ANIMATION"
  3852.       @wait_count = $data_animations[parameters[0].to_i].frame_max * ::Sprite_Base::RATE
  3853.     when "WAIT"
  3854.       @wait_count = parameters[0].to_i
  3855.     end  
  3856.     return 1
  3857.   end
  3858.  
  3859. end  
  3860.  
  3861. # // (YGG_MC) - Mix Code
  3862. #==============================================================================#
  3863. # // RMVX Mixins
  3864. #==============================================================================#
  3865. # ** RPG::Animation
  3866. #==============================================================================#
  3867. class RPG::Animation
  3868.  
  3869.   #----------------------------------------------------------------------------#
  3870.   # * new-method :cell_count
  3871.   #----------------------------------------------------------------------------#
  3872.   def cell_count() ; end unless method_defined? :cell_count
  3873.    
  3874. end  
  3875.  
  3876. #==============================================================================#
  3877. # ** RPG::BaseItem
  3878. #==============================================================================#
  3879. class RPG::BaseItem
  3880.  
  3881.   include YGG::Caches1x6
  3882.  
  3883.   #----------------------------------------------------------------------------#
  3884.   # * Public Instance Variable(s)
  3885.   #----------------------------------------------------------------------------#
  3886.   attr_accessor :pickup_sfx
  3887.  
  3888.   #----------------------------------------------------------------------------#
  3889.   # * new-method :pickup_sfx
  3890.   #----------------------------------------------------------------------------#
  3891.   def pickup_sfx()
  3892.     @pickup_sfx ||= self.note =~ YGG::REGEXP::BASE_ITEM::PICKUP_SFX ?
  3893.       RPG::SE.new( $1, $2.to_i, $3.to_i ) : ::YGG::SOUND_ITEM
  3894.     return @pickup_sfx
  3895.   end
  3896.  
  3897.   #----------------------------------------------------------------------------#
  3898.   # * new-method :drops_attraction?
  3899.   #----------------------------------------------------------------------------#
  3900.   def drops_attraction?() ; return @drops_attraction ; end
  3901.  
  3902. end
  3903.  
  3904. #==============================================================================#
  3905. # ** RPG::Armor
  3906. #==============================================================================#
  3907. class RPG::Armor
  3908.  
  3909.   #----------------------------------------------------------------------------#
  3910.   # * super-method :drops_attraction?
  3911.   #----------------------------------------------------------------------------#  
  3912.   def yggdrasil_1x6_cache_end()
  3913.     super()
  3914.     @ygg_actions[0] ||= ::YGG.get_action_list( "GUARD_ACTION" )
  3915.   end
  3916.  
  3917. end
  3918.  
  3919. #==============================================================================#
  3920. # ** RPG::UsableItem
  3921. #==============================================================================#
  3922. class RPG::UsableItem
  3923.  
  3924.   #----------------------------------------------------------------------------#
  3925.   # * Public Instance Variable(s)
  3926.   #----------------------------------------------------------------------------#  
  3927.   attr_accessor :guardable
  3928.  
  3929.   #----------------------------------------------------------------------------#
  3930.   # * super-method :yggdrasil_1x6_cache_start
  3931.   #----------------------------------------------------------------------------#
  3932.   def yggdrasil_1x6_cache_start()
  3933.     super()
  3934.     @__use_target_select = false
  3935.     @guardable = false
  3936.   end
  3937.  
  3938.   #----------------------------------------------------------------------------#
  3939.   # * super-method :yggdrasil_1x6_cache_check
  3940.   #----------------------------------------------------------------------------#  
  3941.   def yggdrasil_1x6_cache_check( line )
  3942.     super( line )
  3943.     case line
  3944.     when ::YGG::REGEXP::SKILL::UTARGET_SELECT
  3945.       @__use_target_select = true
  3946.     when ::YGG::REGEXP::SKILL::GUARDABLE
  3947.       @guardable = true
  3948.     when ::YGG::REGEXP::SKILL::NOT_GUARDABLE  
  3949.       @guardable = false
  3950.     end  
  3951.   end
  3952.  
  3953.   #----------------------------------------------------------------------------#
  3954.   # * super-method :yggdrasil_1x6_cache_end
  3955.   #----------------------------------------------------------------------------#  
  3956.   def yggdrasil_1x6_cache_end()
  3957.     super()
  3958.     case @scope
  3959.     when 0     # // None
  3960.       @ygg_actions[0] ||= ::YGG.get_action_list( "NORMAL_OBJ0" ).clone
  3961.     when 11    # // User
  3962.       @ygg_actions[0] ||= ::YGG.get_action_list( "NORMAL_OBJ1" ).clone
  3963.     when 1     # // 1 Enemy
  3964.       @ygg_actions[0] ||= @__use_target_select ?
  3965.         ::YGG.get_action_list( "NORMAL_OBJ2_T1" ).clone :
  3966.         ::YGG.get_action_list( "NORMAL_OBJ2_1" ).clone
  3967.     when 3     # // 1 Enemy Dual
  3968.       @ygg_actions[0] ||= @__use_target_select ?
  3969.         ::YGG.get_action_list( "NORMAL_OBJ2_T2" ).clone :
  3970.         ::YGG.get_action_list( "NORMAL_OBJ2_2" ).clone
  3971.     when 4     # // 1 Random Enemy
  3972.       @ygg_actions[0] ||= ::YGG.get_action_list( "NORMAL_OBJ2_R1" ).clone
  3973.     when 5     # // 2 Random Enemies
  3974.       @ygg_actions[0] ||= ::YGG.get_action_list( "NORMAL_OBJ2_R2" ).clone
  3975.     when 6     # // 3 Random Enemies
  3976.       @ygg_actions[0] ||= ::YGG.get_action_list( "NORMAL_OBJ2_R3" ).clone  
  3977.     when 7, 9  # // 1 Ally
  3978.       @ygg_actions[0] ||= @__use_target_select ?
  3979.         ::YGG.get_action_list( "NORMAL_OBJ3_T1" ).clone :
  3980.         ::YGG.get_action_list( "NORMAL_OBJ3_1" ).clone
  3981.     when 2     # // All Enemies
  3982.       @ygg_actions[0] ||= ::YGG.get_action_list( "NORMAL_OBJ4" ).clone  
  3983.     when 8, 10 # // All Allies
  3984.       @ygg_actions[0] ||= ::YGG.get_action_list( "NORMAL_OBJ5" ).clone  
  3985.     end  
  3986.   end
  3987.  
  3988. end
  3989.  
  3990. #==============================================================================#
  3991. # ** RPG::Enemy
  3992. #==============================================================================#
  3993. class RPG::Enemy
  3994.  
  3995.   include YGG::Caches1x6
  3996.  
  3997.   #----------------------------------------------------------------------------#
  3998.   # * Public Instance Variable(s)
  3999.   #----------------------------------------------------------------------------#  
  4000.   attr_accessor :atk_animation_id
  4001.   attr_accessor :atk_animation_id2
  4002.   attr_accessor :drop_items
  4003.   attr_accessor :gold_variation
  4004.  
  4005.   #----------------------------------------------------------------------------#
  4006.   # * super-method :yggdrasil_1x6_cache_check
  4007.   #----------------------------------------------------------------------------#  
  4008.   def yggdrasil_1x6_cache_start()
  4009.     super()
  4010.     @drop_items ||= [] ; @__drop_id = -1
  4011.     @__drop = nil ; @__drop_reading = false
  4012.     @gold_variation = 0
  4013.   end
  4014.  
  4015.   #----------------------------------------------------------------------------#
  4016.   # * super-method :yggdrasil_1x6_cache_check
  4017.   #----------------------------------------------------------------------------#  
  4018.   def yggdrasil_1x6_cache_check( line )
  4019.     super( line )
  4020.     case line
  4021.     when YGG::REGEXP::ENEMY::ATK_ANIMATION_ID
  4022.       @atk_animation_id = $1.to_i
  4023.     when YGG::REGEXP::ENEMY::DROP_ITEM2
  4024.       @drop_items[@__drop_id] = @__drop if @__drop_id > -1
  4025.       @__drop_id = -1 ; @__drop = nil ; @__drop_reading = false  
  4026.     when YGG::REGEXP::ENEMY::DROP_ITEM1
  4027.       @__drop_id = $1.to_i ; @__drop = DropItem.new() ; @__drop_reading = true    
  4028.     when YGG::REGEXP::ENEMY::DROP_CLEAR  
  4029.       @drop_items.clear()
  4030.     when YGG::REGEXP::ENEMY::GOLD_VARI
  4031.       @gold_variation = $1.to_i
  4032.     else
  4033.       if @__drop_reading
  4034.         case line
  4035.         # // Type of the drop item (0: none, 1: item, 2: weapon, 3: armor)
  4036.         when /kind:[ ](\d+)/i
  4037.           @__drop.kind = $1.to_i
  4038.         when /(?:item_id|item id|itemid):[ ](\d+)/i  
  4039.           @__drop.kind = 1 ; @__drop.item_id = $1.to_i
  4040.         when /(?:weapon_id|weapon id|weaponid):[ ](\d+)/i  
  4041.           @__drop.kind = 2 ; @__drop.weapon_id = $1.to_i
  4042.         when /(?:armor_id|armor id|armorid):[ ](\d+)/i    
  4043.           @__drop.kind = 3 ; @__drop.armor_id = $1.to_i
  4044.         when /(?:denom|denominator|prob|probability):[ ](\d+)/i  
  4045.           @__drop.denominator = $1.to_i
  4046.         end
  4047.       end  
  4048.     end  
  4049.   end
  4050.  
  4051.   #----------------------------------------------------------------------------#
  4052.   # * super-method :yggdrasil_1x6_cache_end
  4053.   #----------------------------------------------------------------------------#  
  4054.   def yggdrasil_1x6_cache_end()
  4055.     super()
  4056.     @atk_animation_id  ||= 1
  4057.     @atk_animation_id2 ||= 0
  4058.     @ygg_actions[0]    ||= ::YGG.get_action_list( "NORMAL_ATTACK_EN" ) # // Attack Action
  4059.     @ygg_actions[1]    ||= ::YGG.get_action_list( "GUARD_ACTION_EN" )  # // Guard Action
  4060.     @ygg_actions[2]    ||= ::YGG.get_action_list( "ESCAPE_ACTION_EN" ) # // Escape Action
  4061.     @ygg_actions[3]    ||= ::YGG.get_action_list( "WAIT_ACTION_EN" )   # // Wait Action
  4062.     @drop_items[1]     ||= @drop_item1
  4063.     @drop_items[2]     ||= @drop_item2
  4064.     # // Match Drop Items D: We dont want mismatch and chaos >:
  4065.     @drop_item1 = @drop_items[1]
  4066.     @drop_item2 = @drop_items[2]
  4067.   end
  4068.  
  4069. end  
  4070.  
  4071. #==============================================================================#
  4072. # ** RPG::State
  4073. #==============================================================================#
  4074. class RPG::State
  4075.  
  4076.   #--------------------------------------------------------------------------#
  4077.   # * Public Instance Variable(s)
  4078.   #--------------------------------------------------------------------------#  
  4079.   attr_accessor :hold_ticks
  4080.   attr_accessor :effect_tone
  4081.   attr_accessor :tone_effect
  4082.   attr_accessor :move_mod
  4083.  
  4084.   #----------------------------------------------------------------------------#
  4085.   # * new-method :yggdrasil_1x6_cache
  4086.   #----------------------------------------------------------------------------#  
  4087.   def yggdrasil_1x6_cache()
  4088.     yggdrasil_1x6_cache_start()
  4089.     self.note.split(/[\r\n]+/).each { |line| yggdrasil_1x6_cache_check( line ) }
  4090.     yggdrasil_1x6_cache_end()
  4091.   end
  4092.  
  4093.   #----------------------------------------------------------------------------#
  4094.   # * new-method :yggdrasil_1x6_cache_start
  4095.   #----------------------------------------------------------------------------#  
  4096.   def yggdrasil_1x6_cache_start()
  4097.     @hold_ticks  = self.hold_turn * ::YGG::STATE_TURN_COUNTER
  4098.     @move_mod    = 0
  4099.     @effect_tone = Tone.new( 0, 0, 0, 0 )
  4100.     @tone_effect = false
  4101.     @slip_freq   = ::YGG::SLIP_DAMAGE_FREQUENCY
  4102.   end
  4103.  
  4104.   #----------------------------------------------------------------------------#
  4105.   # * new-method :yggdrasil_1x6_cache_check
  4106.   #----------------------------------------------------------------------------#  
  4107.   def yggdrasil_1x6_cache_check( line )
  4108.     case line
  4109.     when ::YGG::REGEXP::STATE::HOLD_TICKS
  4110.       @hold_ticks = $1.to_i
  4111.     when ::YGG::REGEXP::STATE::TONE  
  4112.       @effect_tone = ::Tone.new( $1.to_i, $2.to_i, $3.to_i, $4.to_i )
  4113.       @tone_effect = true
  4114.     when ::YGG::REGEXP::STATE::MOVE_MOD  
  4115.       @move_mod = $1.to_i
  4116.     when ::YGG::REGEXP::STATE::SLIP_FREQ  
  4117.       @slip_freq = $1.to_i
  4118.     end  
  4119.   end
  4120.  
  4121.   #----------------------------------------------------------------------------#
  4122.   # * new-method :yggdrasil_1x6_cache_end
  4123.   #----------------------------------------------------------------------------#  
  4124.   def yggdrasil_1x6_cache_end()
  4125.   end
  4126.  
  4127.   #----------------------------------------------------------------------------#
  4128.   # * new-method :slip_freq
  4129.   #----------------------------------------------------------------------------#
  4130.   def slip_freq()
  4131.     return self.slip_damage ? @slip_freq : 0
  4132.   end
  4133.  
  4134. end
  4135.  
  4136. #==============================================================================#
  4137. # ** YGG::System ($game_yggdrasil)
  4138. #==============================================================================#
  4139. class YGG::System
  4140.  
  4141.   #--------------------------------------------------------------------------#
  4142.   # * Constants
  4143.   #--------------------------------------------------------------------------#
  4144.   ITEMS_MAPID = ::YGG::ITEM_MAP
  4145.  
  4146.   #--------------------------------------------------------------------------#
  4147.   # * Public Instance Variable(s)
  4148.   #--------------------------------------------------------------------------#
  4149.   attr_accessor :passage_objs
  4150.  
  4151.   attr_reader :projectiles
  4152.   attr_reader :new_projectiles
  4153.  
  4154.   attr_reader :new_poptexts
  4155.  
  4156.   attr_reader :active_ranges
  4157.   attr_reader :battlers
  4158.  
  4159.   #--------------------------------------------------------------------------#
  4160.   # * new-method :initialize
  4161.   #--------------------------------------------------------------------------#
  4162.   def initialize()
  4163.     setup_map( -1 )
  4164.   end
  4165.  
  4166.   #--------------------------------------------------------------------------#
  4167.   # * new-method :hud
  4168.   #--------------------------------------------------------------------------#
  4169.   def hud()
  4170.     @hud ||= YGG::Handlers::HudWrapper.new()
  4171.     return @hud
  4172.   end
  4173.  
  4174.   #--------------------------------------------------------------------------#
  4175.   # * new-method :add_pop
  4176.   #--------------------------------------------------------------------------#
  4177.   def add_pop( poptext, x, y, z=1 )
  4178.     return unless ::YGG::USE_TEXT_POP
  4179.     pop = ::YGG::PopHandler.new( poptext, x, y, z )
  4180.     @pop_texts.push( pop )
  4181.     @new_poptexts  << pop
  4182.     return pop
  4183.   end
  4184.  
  4185.   #--------------------------------------------------------------------------#
  4186.   # * new-method :remove_pop
  4187.   #--------------------------------------------------------------------------#  
  4188.   def remove_pop( pop_handler )
  4189.     pop_handler.force_complete!()
  4190.     @pop_texts.delete( pop_handler )
  4191.     @new_poptexts.delete( pop_handler )
  4192.     return pophandler
  4193.   end
  4194.  
  4195.   #--------------------------------------------------------------------------#
  4196.   # * new-method :add_projectile
  4197.   #--------------------------------------------------------------------------#  
  4198.   def add_projectile( projectile )
  4199.     @projectiles << projectile
  4200.     @new_projectiles << projectile
  4201.     projectile.pro_register()
  4202.     return projectile
  4203.   end
  4204.  
  4205.   #--------------------------------------------------------------------------#
  4206.   # * new-method :remove_projectile
  4207.   #--------------------------------------------------------------------------#  
  4208.   def remove_projectile( projectile )
  4209.     @projectiles.delete( projectile )
  4210.     @new_projectiles.delete( projectile )
  4211.     projectile.pro_unregister()
  4212.     projectile.force_terminate()
  4213.     return projectile
  4214.   end
  4215.  
  4216.   #--------------------------------------------------------------------------#
  4217.   # * new-method :add_battler
  4218.   #--------------------------------------------------------------------------#
  4219.   def add_battler( b ) ; @battlers |= [b] ; end
  4220.  
  4221.   #--------------------------------------------------------------------------#
  4222.   # * new-method :remove_battler
  4223.   #--------------------------------------------------------------------------#
  4224.   def remove_battler( b ) ; @battlers -= [b] ; end
  4225.  
  4226.   #--------------------------------------------------------------------------#
  4227.   # * new-method :add_passage_obj
  4228.   #--------------------------------------------------------------------------#
  4229.   def add_passage_obj( obj )
  4230.     @passage_objs |= [obj]
  4231.   end
  4232.  
  4233.   #--------------------------------------------------------------------------#
  4234.   # * new-method :remove_passage_obj
  4235.   #--------------------------------------------------------------------------#
  4236.   def remove_passage_obj( obj )
  4237.     @passage_objs -= [obj]
  4238.   end
  4239.  
  4240.   #--------------------------------------------------------------------------#
  4241.   # * new-method :update
  4242.   #--------------------------------------------------------------------------#
  4243.   def update()
  4244.     update_poptexts()
  4245.     update_drops()
  4246.     update_roam_events()
  4247.     update_projectiles()
  4248.     update_hud()
  4249.   end
  4250.  
  4251.   #--------------------------------------------------------------------------#
  4252.   # * new-method :update_hud
  4253.   #--------------------------------------------------------------------------#
  4254.   def update_hud()
  4255.     self.hud.update()
  4256.   end
  4257.  
  4258.   #--------------------------------------------------------------------------#
  4259.   # * new-method :update_roam_events
  4260.   #--------------------------------------------------------------------------#
  4261.   def update_roam_events()
  4262.     @roam_events.each { |ev| ev.update() }
  4263.   end
  4264.  
  4265.   #--------------------------------------------------------------------------#
  4266.   # * new-method :update_projectiles
  4267.   #--------------------------------------------------------------------------#
  4268.   def update_projectiles()
  4269.     @projectiles = @projectiles.inject([]) { |result, pro|
  4270.       unless pro.terminated?() ; pro.update() ; result << pro  
  4271.       else ; @new_projectiles.delete( pro ) ; pro.registered = false ; end
  4272.       result
  4273.     } unless @projectiles.empty?()
  4274.   end
  4275.  
  4276.   #--------------------------------------------------------------------------#
  4277.   # * new-method :pop_texts
  4278.   #--------------------------------------------------------------------------#
  4279.   def update_poptexts()
  4280.     @pop_texts = @pop_texts.inject([]) { |result, pop|
  4281.       pop.update() ; result << pop unless pop.complete?() ; result
  4282.     } unless @pop_texts.empty?()
  4283.   end
  4284.  
  4285.   #--------------------------------------------------------------------------#
  4286.   # * new-method :pop_texts
  4287.   #--------------------------------------------------------------------------#
  4288.   def pop_texts() ; return @pop_texts ; end
  4289.  
  4290.   #--------------------------------------------------------------------------#
  4291.   # * new-method :roam_xy
  4292.   #--------------------------------------------------------------------------#
  4293.   def roam_xy( x, y )
  4294.     return (
  4295.       @roam_events +
  4296.       @passage_objs).inject([]) { |r, ev| r << ev if ev.pos?( x, y ) ; ev }
  4297.   end
  4298.            
  4299.   #--------------------------------------------------------------------------#
  4300.   # * new-method :battlers_xy
  4301.   #--------------------------------------------------------------------------#
  4302.   def battlers_xy( x, y )
  4303.     return @battlers.inject([]) { |result, b| result << b if b.pos?( x, y ) ; result }
  4304.   end
  4305.  
  4306.   #--------------------------------------------------------------------------#
  4307.   # * new-method :battlers_range
  4308.   #--------------------------------------------------------------------------#  
  4309.   def battlers_range( x1, y1, x2, y2 )
  4310.     return @battlers.inject([]) { |result, b|
  4311.       result << b if b.x.between?( x1, x2 ) && b.y.between?( y1, y2 ) ; result }
  4312.   end
  4313.  
  4314.   #--------------------------------------------------------------------------#
  4315.   # * new-method :on?
  4316.   #--------------------------------------------------------------------------#  
  4317.   if ::YGG::ABS_SYSTEM_SWITCH.nil?()
  4318.     def on?() ; return true ; end
  4319.   else
  4320.     def on?() ; return $game_switches[::YGG::ABS_SYSTEM_SWITCH] ; end  
  4321.   end  
  4322.  
  4323.   #--------------------------------------------------------------------------#
  4324.   # * new-method :setup_map
  4325.   #--------------------------------------------------------------------------#
  4326.   def setup_map( map_id )
  4327.     @map_id          = map_id
  4328.     @pop_texts     ||= [] ; @pop_texts.clear()
  4329.     @new_poptexts  ||= [] ; @new_poptexts.clear()
  4330.     @battlers      ||= [] ; @battlers.each { |b| b.ygg_unregister() } ; @battlers.clear()  
  4331.     @active_drops  ||= [] ; @active_drops.clear()
  4332.     @active_ranges ||= [] ; @active_ranges.clear()
  4333.     @projectiles   ||= [] ; @projectiles.clear()  
  4334.     @new_projectiles||=[] ; @new_projectiles.clear()
  4335.     @roam_events   ||= [] ; @roam_events.clear()
  4336.     @passage_objs  ||= [] ; @passage_objs.clear()
  4337.   end  
  4338.  
  4339.   #--------------------------------------------------------------------------#
  4340.   # * new-method :get_map
  4341.   #--------------------------------------------------------------------------#  
  4342.   def get_map( map_id )
  4343.     $game_map.get_map( map_id )
  4344.   end
  4345.  
  4346.   #--------------------------------------------------------------------------#
  4347.   # * new-method :setup_itemmap
  4348.   #--------------------------------------------------------------------------#
  4349.   def setup_itemmap()
  4350.     if $items_map.nil?()
  4351.       $items_map = get_map( ITEMS_MAPID )
  4352.       $items_map.events.values.each { |ev| ev.pages.each { |pg|
  4353.         pg.list = YGG.parse_event_list( pg.list ) } }
  4354.     end  
  4355.   end
  4356.  
  4357.   #--------------------------------------------------------------------------#
  4358.   # * new-method :create_drops
  4359.   #--------------------------------------------------------------------------#
  4360.   def create_drops( x, y, dropee )
  4361.     place_drops( x, y, dropee.items, dropee.gold )
  4362.   end  
  4363.  
  4364.   #--------------------------------------------------------------------------#
  4365.   # * new-method :place_drops
  4366.   #--------------------------------------------------------------------------#
  4367.   def place_drops( x, y, item_set, gold = nil )
  4368.     drops = []  
  4369.     for dr in item_set.compact
  4370.       cc = YGG::Drop_Character.new( dr, YGG::ITEM_FADE_TIME )
  4371.       fail_count = 0
  4372.       dx, dy = x, y
  4373.       loop do
  4374.         x_r = rand(YGG::DROP_SCATTER_DISTANCE)
  4375.         y_r = rand(YGG::DROP_SCATTER_DISTANCE)
  4376.         x_r = -x_r if rand(2) == 0
  4377.         y_r = -y_r if rand(2) == 0
  4378.         dx = x + x_r
  4379.         dy = y + y_r
  4380.         if fail_count > 20 ; break dx, dy = x, y ; end
  4381.         break if $game_map.passable?( dx, dy )
  4382.         fail_count += 1
  4383.       end  
  4384.       cc.moveto( dx, dy )
  4385.       drops.push( cc )
  4386.     end
  4387.     unless gold.nil?() || gold.eql?( 0 )
  4388.       cc = YGG::Drop_Character.new( YGG::Containers::GoldItem.new( gold ), YGG::GOLD_FADE_TIME )
  4389.       cc.moveto( x, y )
  4390.       drops.push( cc )
  4391.     end
  4392.     drops.each { |char|
  4393.       @active_drops.push( char ) ;
  4394.       $scene.spriteset.add_drop_sprite( char ) if $scene.is_a?( Scene_Map )
  4395.     }
  4396.     return drops
  4397.   end
  4398.  
  4399.   #--------------------------------------------------------------------------#
  4400.   # * new-method :items_map
  4401.   #--------------------------------------------------------------------------#
  4402.   def items_map() ; return $items_map ; end
  4403.  
  4404.   #--------------------------------------------------------------------------#
  4405.   # * alias-method :update_drops
  4406.   #--------------------------------------------------------------------------#
  4407.   def update_drops()
  4408.     @active_drops = @active_drops.inject([]) { |result, dr| dr.update()
  4409.       result.push( dr ) unless dr.timeout?() ; result } unless @active_drops.empty?()
  4410.   end
  4411.  
  4412.   #--------------------------------------------------------------------------#
  4413.   # * new-method :active_drops
  4414.   #--------------------------------------------------------------------------#
  4415.   def active_drops() ; return @active_drops ; end
  4416.  
  4417.   #--------------------------------------------------------------------------#
  4418.   # * new-method :drops_xy
  4419.   #--------------------------------------------------------------------------#  
  4420.   def drops_xy( x, y )
  4421.     return self.active_drops.inject([]) { |result, dr|
  4422.       result.push(dr) if dr.pos?(x, y) ; result }
  4423.   end
  4424.  
  4425. end
  4426.  
  4427. #==============================================================================#
  4428. # // Start Yggdrasil MixIn Code  
  4429. #==============================================================================#
  4430. YGG::Containers::Drops = Struct.new( :items, :gold )
  4431. #==============================================================================#
  4432. # ** YGG::MixIns::Actor
  4433. #==============================================================================#
  4434. module YGG::MixIns::Actor
  4435.  
  4436.   #--------------------------------------------------------------------------#
  4437.   # * new-method :create_drops_object
  4438.   #--------------------------------------------------------------------------#  
  4439.   def create_drops_object()
  4440.     return ::YGG::Containers::Drops.new( [], 0 )
  4441.   end
  4442.  
  4443. end
  4444.  
  4445. #==============================================================================#
  4446. # ** YGG::MixIns::Enemy
  4447. #==============================================================================#
  4448. module YGG::MixIns::Enemy
  4449.  
  4450.   #--------------------------------------------------------------------------#
  4451.   # * new-method :create_drops_object
  4452.   #--------------------------------------------------------------------------#  
  4453.   def create_drops_object()
  4454.     return ::YGG::Containers::Drops.new( self.all_drops, self.calc_gold )
  4455.   end
  4456.  
  4457. end
  4458.  
  4459. #==============================================================================#
  4460. # ** YGG::MixIns::Movement
  4461. #==============================================================================#
  4462. module YGG::MixIns::Movement
  4463.  
  4464.   #--------------------------------------------------------------------------#
  4465.   # * new-method :distance_from
  4466.   #--------------------------------------------------------------------------#
  4467.   def distance_from( obj )
  4468.     return (obj.x - self.x).abs + (obj.y - self.y).abs
  4469.   end
  4470.  
  4471.   #--------------------------------------------------------------------------#
  4472.   # * Jump to XY
  4473.   #--------------------------------------------------------------------------#  
  4474.   def jump_to_xy( tx, ty )
  4475.     jump( tx-self.x, ty-self.y )
  4476.   end
  4477.  
  4478.   #--------------------------------------------------------------------------#
  4479.   # * Jump to Character
  4480.   #--------------------------------------------------------------------------#  
  4481.   def jump_to_char( char )
  4482.     jump_to_xy( char.x, char.y )
  4483.   end
  4484.  
  4485.   #--------------------------------------------------------------------------#
  4486.   # * Jump to Event
  4487.   #--------------------------------------------------------------------------#  
  4488.   def jump_to_event( event_id )
  4489.     jump_to_char( $game_map.events[event_id] )
  4490.   end
  4491.  
  4492.   #--------------------------------------------------------------------------#
  4493.   # * new-method :jump_forward
  4494.   #--------------------------------------------------------------------------#
  4495.   def jump_forward( amount, offset )
  4496.     case direction
  4497.     when 2
  4498.       jump( offset, amount )
  4499.     when 4
  4500.       jump( -amount, offset )
  4501.     when 6
  4502.       jump( amount, -offset )
  4503.     when 8
  4504.       jump( -offset, -amount )
  4505.     end  
  4506.   end
  4507.  
  4508.   #--------------------------------------------------------------------------#
  4509.   # * new-method :jump_backward
  4510.   #--------------------------------------------------------------------------#
  4511.   def jump_backward( amount, offset )
  4512.     jump_forward( -amount, -offset )
  4513.   end
  4514.  
  4515.   #--------------------------------------------------------------------------#
  4516.   # * new-method :distance_x_from_tx
  4517.   #--------------------------------------------------------------------------#
  4518.   def distance_x_from_tx( tx )
  4519.     sx = @x - tx
  4520.     if $game_map.loop_horizontal?         # When looping horizontally
  4521.       if sx.abs > $game_map.width / 2     # Larger than half the map width?
  4522.         sx -= $game_map.width             # Subtract map width
  4523.       end
  4524.     end
  4525.     return sx
  4526.   end
  4527.  
  4528.   #--------------------------------------------------------------------------#
  4529.   # * new-method :distance_y_from_ty
  4530.   #--------------------------------------------------------------------------#
  4531.   def distance_y_from_ty( ty )
  4532.     sy = @y - ty
  4533.     if $game_map.loop_vertical?           # When looping vertically
  4534.       if sy.abs > $game_map.height / 2    # Larger than half the map height?
  4535.         sy -= $game_map.height            # Subtract map height
  4536.       end
  4537.     end
  4538.     return sy
  4539.   end
  4540.  
  4541.   #--------------------------------------------------------------------------#
  4542.   # * new-method :move_toward_xy
  4543.   #--------------------------------------------------------------------------#
  4544.   def move_toward_xy( x, y )
  4545.     move_8d = false
  4546.     sx = distance_x_from_tx(x)
  4547.     sy = distance_y_from_ty(y)
  4548.     if move_8d
  4549.       # // Need to work on it
  4550.     else  
  4551.       if sx != 0 or sy != 0
  4552.         if sx.abs > sy.abs                  # Horizontal distance is longer
  4553.           sx > 0 ? move_left : move_right   # Prioritize left-right
  4554.           if @move_failed and sy != 0
  4555.             sy > 0 ? move_up : move_down
  4556.           end
  4557.         else                                # Vertical distance is longer
  4558.           sy > 0 ? move_up : move_down      # Prioritize up-down
  4559.           if @move_failed and sx != 0
  4560.             sx > 0 ? move_left : move_right
  4561.           end
  4562.         end
  4563.       end
  4564.     end  
  4565.   end
  4566.  
  4567.   #--------------------------------------------------------------------------#
  4568.   # * new-method :move_away_from_xy
  4569.   #--------------------------------------------------------------------------#
  4570.   def move_away_from_xy( x, y )
  4571.     move_8d = false
  4572.     sx = distance_x_from_tx(x)
  4573.     sy = distance_y_from_ty(y)
  4574.     if move_8d
  4575.       # // Need to work on it
  4576.     else  
  4577.       if sx != 0 or sy != 0
  4578.         if sx.abs > sy.abs                  # Horizontal distance is longer
  4579.           sx > 0 ? move_right : move_left   # Prioritize left-right
  4580.           if @move_failed and sy != 0
  4581.             sy > 0 ? move_down : move_up
  4582.           end
  4583.         else                                # Vertical distance is longer
  4584.           sy > 0 ? move_down : move_up      # Prioritize up-down
  4585.           if @move_failed and sx != 0
  4586.             sx > 0 ? move_right : move_left
  4587.           end
  4588.         end
  4589.       end
  4590.     end  
  4591.   end
  4592.  
  4593.   #--------------------------------------------------------------------------#
  4594.   # * new-method :move_toward_char
  4595.   #--------------------------------------------------------------------------#
  4596.   def move_toward_char( char )
  4597.     move_toward_xy( char.x, char.y )
  4598.   end
  4599.  
  4600.   #--------------------------------------------------------------------------#
  4601.   # * new-method :move_away_from_xy
  4602.   #--------------------------------------------------------------------------#
  4603.   def move_away_from_char( char )
  4604.     move_away_from_xy( char.x, char.y )
  4605.   end
  4606.  
  4607.   #--------------------------------------------------------------------------#
  4608.   # * new-method :move_toward_event
  4609.   #--------------------------------------------------------------------------#
  4610.   def move_toward_event( event_id )
  4611.     move_toward_char( $game_map.events[event_id] )
  4612.   end  
  4613.  
  4614.   #--------------------------------------------------------------------------#
  4615.   # * new-method :move_away_from_event
  4616.   #--------------------------------------------------------------------------#
  4617.   def move_away_from_event( event_id )
  4618.     move_away_from_char( $game_map.events[event_id] )
  4619.   end
  4620.  
  4621.   #--------------------------------------------------------------------------#
  4622.   # * new-method :thrust_wait
  4623.   #--------------------------------------------------------------------------#
  4624.   def thrust_wait( t=30 ) ; @wait_count = t ; end
  4625.  
  4626.   #--------------------------------------------------------------------------#
  4627.   # * new-method :half_down
  4628.   #--------------------------------------------------------------------------#
  4629.   def half_down( turn_ok=true )
  4630.     turn_down if turn_ok
  4631.     @y = $game_map.round_y(@y + 0.5)
  4632.     @real_y = ((@y - 0.5)*256)
  4633.     @move_failed = false
  4634.   end
  4635.  
  4636.   #--------------------------------------------------------------------------#
  4637.   # * new-method :half_left
  4638.   #--------------------------------------------------------------------------#
  4639.   def half_left( turn_ok=true )
  4640.     turn_left if turn_ok
  4641.     @x = $game_map.round_x(@x-0.5)
  4642.     @real_x = ((@x+0.5)*256)
  4643.     @move_failed = false
  4644.   end
  4645.  
  4646.   #--------------------------------------------------------------------------#
  4647.   # * new-method :half_right
  4648.   #--------------------------------------------------------------------------#
  4649.   def half_right( turn_ok=true )
  4650.     turn_right if turn_ok
  4651.     @x = $game_map.round_x(@x+0.5)
  4652.     @real_x = ((@x-0.5)*256)
  4653.     @move_failed = false
  4654.   end
  4655.  
  4656.   #--------------------------------------------------------------------------#
  4657.   # * new-method :half_up
  4658.   #--------------------------------------------------------------------------#
  4659.   def half_up( turn_ok=true )
  4660.     turn_up if turn_ok
  4661.     @y = $game_map.round_y(@y-0.5)
  4662.     @real_y = ((@y+0.5)*256)
  4663.     @move_failed = false
  4664.   end
  4665.  
  4666.   #--------------------------------------------------------------------------#
  4667.   # * new-method :half_forward
  4668.   #--------------------------------------------------------------------------#
  4669.   def half_forward()
  4670.     case @direction
  4671.     when 2 ; half_down
  4672.     when 4 ; half_left
  4673.     when 6 ; half_right
  4674.     when 8 ; half_up
  4675.     end
  4676.   end
  4677.  
  4678.   #--------------------------------------------------------------------------#
  4679.   # * new-method :half_backward
  4680.   #--------------------------------------------------------------------------#
  4681.   def half_backward()
  4682.     last_direction_fix = @direction_fix
  4683.     @direction_fix = true
  4684.     case @direction
  4685.     when 2;  half_up
  4686.     when 4;  half_right
  4687.     when 6;  half_left
  4688.     when 8;  half_down
  4689.     end
  4690.     @direction_fix = last_direction_fix
  4691.   end
  4692.  
  4693.   #--------------------------------------------------------------------------#
  4694.   # * new-method :free_move_toward_target
  4695.   #--------------------------------------------------------------------------#
  4696.   def free_move_toward_target( t_x, t_y )
  4697.     sx = fr_distance_x_from(t_x)
  4698.     sy = fr_distance_y_from(t_y)
  4699.     if sx != 0 or sy != 0
  4700.       if sx.abs > sy.abs                  # Horizontal distance is longer
  4701.         sx > 0 ? free_left : free_right   # Prioritize left-right
  4702.         if @move_failed and sy != 0
  4703.           sy > 0 ? free_up : free_down
  4704.         end
  4705.       else                                # Vertical distance is longer
  4706.         sy > 0 ? free_up : free_down      # Prioritize up-down
  4707.         if @move_failed and sx != 0
  4708.           sx > 0 ? free_left : free_right
  4709.         end
  4710.       end
  4711.     end
  4712.   end
  4713.  
  4714.   #--------------------------------------------------------------------------#
  4715.   # * new-method :fr_distance_x_from
  4716.   #--------------------------------------------------------------------------#
  4717.   def fr_distance_x_from( targ_x )
  4718.     sx = self.x - targ_x
  4719.     if $game_map.loop_horizontal?         # When looping horizontally
  4720.       if sx.abs > $game_map.width / 2     # Larger than half the map width?
  4721.         sx -= $game_map.width             # Subtract map width
  4722.       end
  4723.     end
  4724.     return sx
  4725.   end
  4726.  
  4727.   #--------------------------------------------------------------------------#
  4728.   # * new-method :fr_distance_y_from
  4729.   #--------------------------------------------------------------------------#
  4730.   def fr_distance_y_from( targ_y )
  4731.     sy = self.y - targ_y
  4732.     if $game_map.loop_vertical?           # When looping vertically
  4733.       if sy.abs > $game_map.height / 2    # Larger than half the map height?
  4734.         sy -= $game_map.height            # Subtract map height
  4735.       end
  4736.     end
  4737.     return sy
  4738.   end
  4739.  
  4740.   #--------------------------------------------------------------------------#
  4741.   # * new-method :limited_down
  4742.   #--------------------------------------------------------------------------#
  4743.   def limited_down( orx, ory, limit, dist=1 )
  4744.     dist_x = fr_distance_x_from(orx)
  4745.     dist_y = fr_distance_y_from(ory) + dist
  4746.     move_down() if (dist_x.abs + dist_y.abs) < limit  
  4747.     return (dist_x.abs + dist_y.abs)
  4748.   end  
  4749.  
  4750.   #--------------------------------------------------------------------------#
  4751.   # * new-method :limited_up
  4752.   #--------------------------------------------------------------------------#  
  4753.   def limited_up( orx, ory, limit, dist=1 )
  4754.     dist_x = fr_distance_x_from(orx)
  4755.     dist_y = fr_distance_y_from(ory) - dist
  4756.     move_up() if (dist_x.abs + dist_y.abs) < limit
  4757.     return (dist_x.abs + dist_y.abs)
  4758.   end
  4759.  
  4760.   #--------------------------------------------------------------------------#
  4761.   # * new-method :limited_left
  4762.   #--------------------------------------------------------------------------#  
  4763.   def limited_left( orx, ory, limit, dist=1 )
  4764.     dist_x = fr_distance_x_from(orx) - dist
  4765.     dist_y = fr_distance_y_from(ory)
  4766.     move_left() if (dist_x.abs + dist_y.abs) < limit
  4767.     return (dist_x.abs + dist_y.abs)
  4768.   end
  4769.  
  4770.   #--------------------------------------------------------------------------#
  4771.   # * new-method :limited_right
  4772.   #--------------------------------------------------------------------------#  
  4773.   def limited_right( orx, ory, limit, dist=1 )
  4774.     dist_x = fr_distance_x_from(orx) + dist
  4775.     dist_y = fr_distance_y_from(ory)
  4776.     move_right() if (dist_x.abs + dist_y.abs) < limit
  4777.     return (dist_x.abs + dist_y.abs)
  4778.   end  
  4779.  
  4780.   #--------------------------------------------------------------------------#
  4781.   # * new-method :thrust_down
  4782.   #--------------------------------------------------------------------------#
  4783.   def thrust_down()
  4784.     dudspeed = @move_speed
  4785.     @move_speed = 6
  4786.     half_down()
  4787.     thrust_wait()
  4788.     half_up( false )
  4789.     @move_speed = dudspeed
  4790.   end
  4791.  
  4792.   #--------------------------------------------------------------------------#
  4793.   # * new-method :thrust_up
  4794.   #--------------------------------------------------------------------------#
  4795.   def thrust_up()
  4796.     dudspeed = @move_speed
  4797.     @move_speed = 6
  4798.     half_up()
  4799.     thrust_wait()
  4800.     half_down( false )
  4801.     @move_speed = dudspeed
  4802.   end
  4803.  
  4804.   #--------------------------------------------------------------------------#
  4805.   # * new-method :thrust_left
  4806.   #--------------------------------------------------------------------------#  
  4807.   def thrust_left()
  4808.     dudspeed = @move_speed
  4809.     @move_speed = 6
  4810.     half_left()
  4811.     thrust_wait()
  4812.     half_right( false )
  4813.     @move_speed = dudspeed
  4814.   end
  4815.  
  4816.   #--------------------------------------------------------------------------#
  4817.   # * new-method :thrust_right
  4818.   #--------------------------------------------------------------------------#
  4819.   def thrust_right()
  4820.     dudspeed = @move_speed
  4821.     @move_speed = 6
  4822.     half_right()
  4823.     thrust_wait()
  4824.     half_left( false )
  4825.     @move_speed = dudspeed
  4826.   end
  4827.  
  4828.   #--------------------------------------------------------------------------#
  4829.   # * new-method :thrust_forward
  4830.   #--------------------------------------------------------------------------#
  4831.   def thrust_forward()
  4832.     case @direction
  4833.     when 2 ; thrust_down()
  4834.     when 4 ; thrust_left()
  4835.     when 6 ; thrust_right()
  4836.     when 8 ; thrust_up()
  4837.     end
  4838.   end
  4839.  
  4840.   #--------------------------------------------------------------------------#
  4841.   # * new-method :thrust_backward
  4842.   #--------------------------------------------------------------------------#
  4843.   def thrust_backward()
  4844.     last_direction_fix = @direction_fix
  4845.     @direction_fix = true
  4846.     case @direction
  4847.     when 2 ; thrust_up
  4848.     when 4 ; thrust_right
  4849.     when 6 ; thrust_left
  4850.     when 8 ; thrust_down
  4851.     end
  4852.     @direction_fix = last_direction_fix
  4853.   end
  4854.  
  4855.   #--------------------------------------------------------------------------#
  4856.   # * new-method :ygg_dodge
  4857.   #--------------------------------------------------------------------------#
  4858.   def ygg_dodge()
  4859.     last_direction_fix = @direction_fix
  4860.     @direction_fix = true
  4861.     dodge_val = rand(2)
  4862.     case @direction
  4863.     when 2, 8; dodge_val == 0 ? thrust_left() : thrust_right()
  4864.     when 4, 6; dodge_val == 0 ? thrust_up() : thrust_down()
  4865.     end
  4866.     @direction_fix = last_direction_fix
  4867.   end
  4868.  
  4869.   #--------------------------------------------------------------------------#
  4870.   # * new-method :free_down
  4871.   #--------------------------------------------------------------------------#
  4872.   def free_down( turn_ok=true )
  4873.     if passable?(@x, @y.round.to_i+0.1)                  # Passable
  4874.       turn_down
  4875.       @y = $game_map.round_y(@y+0.1)
  4876.       @real_y = (@y-0.1)*256
  4877.       increase_steps
  4878.       @move_failed = false
  4879.     else                                    # Impassable
  4880.       turn_down if turn_ok
  4881.       check_event_trigger_touch(@x, @y.round+1)   # Touch event is triggered?
  4882.       @move_failed = true
  4883.     end
  4884.   end
  4885.  
  4886.   #--------------------------------------------------------------------------#
  4887.   # * new-method :free_left
  4888.   #--------------------------------------------------------------------------#
  4889.   def free_left( turn_ok=true )
  4890.     if passable?(@x.round.to_i-1, @y)                  # Passable
  4891.       turn_left
  4892.       @x = $game_map.round_x(@x-0.1)
  4893.       @real_x = (@x+0.1)*256
  4894.       increase_steps
  4895.       @move_failed = false
  4896.     else                                    # Impassable
  4897.       turn_left if turn_ok
  4898.       check_event_trigger_touch(@x.round-1, @y)   # Touch event is triggered?
  4899.       @move_failed = true
  4900.     end
  4901.   end
  4902.  
  4903.   #--------------------------------------------------------------------------#
  4904.   # * new-method :free_right
  4905.   #--------------------------------------------------------------------------#
  4906.   def free_right( turn_ok=true )
  4907.     if passable?(@x.round.to_i+1, @y)                  # Passable
  4908.       turn_right
  4909.       @x = $game_map.round_x(@x+0.1)
  4910.       @real_x = (@x-0.1)*256
  4911.       increase_steps
  4912.       @move_failed = false
  4913.     else                                    # Impassable
  4914.       turn_right if turn_ok
  4915.       check_event_trigger_touch(@x.round+1, @y)   # Touch event is triggered?
  4916.       @move_failed = true
  4917.     end
  4918.   end
  4919.  
  4920.   #--------------------------------------------------------------------------#
  4921.   # * new-method :free_up
  4922.   #--------------------------------------------------------------------------#
  4923.   def free_up( turn_ok=true )
  4924.     if passable?(@x, @y.truncate-1)                  # Passable
  4925.       turn_up
  4926.       @y = $game_map.round_y(@y-0.1)
  4927.       @real_y = (@y+0.1)*256
  4928.       increase_steps
  4929.       @move_failed = false
  4930.     else                                    # Impassable
  4931.       turn_up if turn_ok
  4932.       check_event_trigger_touch(@x, @y.truncate-1)   # Touch event is triggered?
  4933.       @move_failed = true
  4934.     end
  4935.   end
  4936.  
  4937.   #--------------------------------------------------------------------------#
  4938.   # * new-method :hit_away
  4939.   #--------------------------------------------------------------------------#
  4940.   def hit_away( atk_direction )
  4941.     def_speed = @move_speed
  4942.     @move_speed = 6
  4943.     case atk_direction
  4944.     when 2
  4945.       turn_up
  4946.       move_backward
  4947.     when 4
  4948.       turn_right
  4949.       move_backward
  4950.     when 6
  4951.       turn_left
  4952.       move_backward
  4953.     when 8
  4954.       turn_down
  4955.       move_backward
  4956.     end
  4957.     @move_speed = def_speed
  4958.   end
  4959.  
  4960.   #--------------------------------------------------------------------------#
  4961.   # * new-method :turn_to_coord
  4962.   #--------------------------------------------------------------------------#
  4963.   def turn_to_coord( sx, sy )
  4964.     if sx > self.x and sy == self.y    ; turn_right()
  4965.     elsif sx < self.x and sy == self.y ; turn_left()
  4966.     elsif sx == self.x and sy > self.y ; turn_down()
  4967.     elsif sx == self.x and sy < self.y ; turn_up()
  4968.     end  
  4969.   end
  4970.  
  4971.   #--------------------------------------------------------------------------#
  4972.   # * new-method :set_origin
  4973.   #--------------------------------------------------------------------------#
  4974.   def set_origin()
  4975.     @origin ||= ::YGG::Pos.new( self.x, self.y ) ; @origin.set( self.x, self.y )
  4976.   end
  4977.    
  4978. end
  4979.  
  4980. #==============================================================================#
  4981. # ** YGG::MixIns::Battle
  4982. #==============================================================================#
  4983. module YGG::MixIns::Battle
  4984.  
  4985.   #--------------------------------------------------------------------------#
  4986.   # * Public Instance Variable(s)
  4987.   #--------------------------------------------------------------------------#
  4988.   attr_accessor :ygg_delay_max
  4989.  
  4990.   #--------------------------------------------------------------------------#
  4991.   # * new-method :ai_operated?
  4992.   #--------------------------------------------------------------------------#
  4993.   def ai_operated?()
  4994.     return @ai_operated
  4995.   end
  4996.  
  4997.   #--------------------------------------------------------------------------#
  4998.   # * new-method :hp_visible?
  4999.   #--------------------------------------------------------------------------#
  5000.   def hp_visible?()
  5001.     return $game_yggdrasil.on?() && @hp_visible
  5002.   end
  5003.    
  5004.   #--------------------------------------------------------------------------#
  5005.   # * new-method :mp_visible?
  5006.   #--------------------------------------------------------------------------#
  5007.   def mp_visible?()
  5008.     return $game_yggdrasil.on?() && @mp_visible
  5009.   end
  5010.    
  5011.   #--------------------------------------------------------------------------#
  5012.   # * new-method :ygg_can_move?
  5013.   #--------------------------------------------------------------------------#
  5014.   def ygg_can_move?() ; return true ; end
  5015.    
  5016.   #--------------------------------------------------------------------------#
  5017.   # * new-method :ygg_attacker | ygg_battler
  5018.   #--------------------------------------------------------------------------#
  5019.   def ygg_attacker() ; return nil ; end  
  5020.   def ygg_battler()  ; return ygg_attacker() ; end
  5021.    
  5022.   #--------------------------------------------------------------------------#
  5023.   # * new-method :wild_type?
  5024.   #--------------------------------------------------------------------------#
  5025.   def wild_type?() ; return false ; end  
  5026.    
  5027.   #--------------------------------------------------------------------------#
  5028.   # * new-method :ygg_enemy?
  5029.   #--------------------------------------------------------------------------#
  5030.   def ygg_enemy?() ; return false ; end  
  5031.    
  5032.   #--------------------------------------------------------------------------#
  5033.   # * new-method :ygg_ally?
  5034.   #--------------------------------------------------------------------------#
  5035.   def ygg_ally?() ; return false ; end  
  5036.    
  5037.   #--------------------------------------------------------------------------#
  5038.   # * new-method :ygg_death
  5039.   #--------------------------------------------------------------------------#
  5040.   def ygg_death() ; end  
  5041.    
  5042.   #--------------------------------------------------------------------------#
  5043.   # * new-method :ygg_boss?
  5044.   #--------------------------------------------------------------------------#
  5045.   def ygg_boss?() ; return false end  
  5046.    
  5047.   #--------------------------------------------------------------------------#
  5048.   # * new-method :process_extension_actions
  5049.   #--------------------------------------------------------------------------#
  5050.   def process_extension_actions() ; end
  5051.    
  5052.   #--------------------------------------------------------------------------#
  5053.   # * new-method :ygg_can_attack?
  5054.   #--------------------------------------------------------------------------#
  5055.   def ygg_can_attack?() ; return true ; end
  5056.  
  5057.   #--------------------------------------------------------------------------#
  5058.   # * new-method :targetable?
  5059.   #--------------------------------------------------------------------------#
  5060.   def targetable?( target )
  5061.     return false if self.ygg_battler.nil?()
  5062.     return true if target.upcase == "ALL"
  5063.     return true if self.ygg_ally?() && target == "ALLY"
  5064.     return true if self.ygg_enemy?() && target == "ENEMY"
  5065.     return false
  5066.   end  
  5067.  
  5068.   #--------------------------------------------------------------------------#
  5069.   # * new-method :ally_character?
  5070.   #--------------------------------------------------------------------------#  
  5071.   def ally_character?( char )
  5072.     return true if self.ygg_ally?() && char.ygg_ally?()
  5073.     return true if self.ygg_enemy?() && char.ygg_enemy?()
  5074.     return false
  5075.   end
  5076.  
  5077.   #--------------------------------------------------------------------------#
  5078.   # * new-method :enemy_character?
  5079.   #--------------------------------------------------------------------------#  
  5080.   def enemy_character?( char )
  5081.     return !ally_character?( char )
  5082.   end
  5083.  
  5084.   #--------------------------------------------------------------------------#
  5085.   # * new-method :ygg_correct_target
  5086.   #--------------------------------------------------------------------------#  
  5087.   def ygg_correct_target( target )
  5088.     return "ALLY" if self.ygg_enemy?() && target =~ /ENEMY/i
  5089.     return "ENEMY" if self.ygg_enemy?() && target =~ /ALLY/i
  5090.     return target
  5091.   end
  5092.  
  5093.   #--------------------------------------------------------------------------#
  5094.   # * new-method :ygg_abs_update
  5095.   #--------------------------------------------------------------------------#  
  5096.   def ygg_abs_update()
  5097.     @guard_time = [@guard_time - 1, 0].max
  5098.   end  
  5099. # ---------------------------------------------------------------------------- #    
  5100. # Calculations
  5101.  
  5102.   #--------------------------------------------------------------------------#
  5103.   # * new-method :Get Targets
  5104.   #--------------------------------------------------------------------------#
  5105.   # This is used to get all targets at a given location
  5106.   # l_x - x coordiante
  5107.   # l_y - y coordiante
  5108.   # target - "A", "E", "N", "W"
  5109.   # exclude_self - If the target that is encountered, happens to be the
  5110.   #                user, should they be ignored?
  5111.   #--------------------------------------------------------------------------#
  5112.   def ygg_get_targets( l_x=0, l_y=0, target="ALL", exclude_self = false )
  5113.     objects = $game_yggdrasil.battlers_xy( l_x, l_y ).inject([]) { |result, event|
  5114.       if event.targetable?( target )
  5115.         result.push( event )  
  5116.       end unless (exclude_self && event == self)
  5117.       result
  5118.     }
  5119.     if $game_player.pos?( l_x, l_y ) and $game_player.targetable?( target )
  5120.       objects.push( $game_player )  
  5121.     end unless (exclude_self && $game_player == self)
  5122.     return objects
  5123.   end
  5124.  
  5125. # ---------------------------------------------------------------------------- #    
  5126. # Processes
  5127.   #--------------------------------------------------------------------------#
  5128.   # * new-method :update_battler
  5129.   #--------------------------------------------------------------------------#
  5130.   def update_battler()
  5131.     update_states()
  5132.     self.ygg_battler.update_obj_handles()
  5133.     self.ygg_battler.update_cooldown()
  5134.   end
  5135.  
  5136.   #--------------------------------------------------------------------------#
  5137.   # * new-method :update_states
  5138.   #--------------------------------------------------------------------------#
  5139.   def update_states()
  5140.     self.ygg_battler.update_states
  5141.   end
  5142.    
  5143. # ---------------------------------------------------------------------------- #    
  5144. # Yggdrasil Battle Actions
  5145.  
  5146.   #--------------------------------------------------------------------------#
  5147.   # * new-method :get_targets_nearby
  5148.   #--------------------------------------------------------------------------#
  5149.   def get_targets_nearby( range=1, type ="ALL" )
  5150.     coords = []
  5151.     if YGG::FULL_FIELD_SCAN
  5152.       coords.concat( YGG.create_range_data( range ) )  
  5153.     else  
  5154.       case direction
  5155.       when 2
  5156.         for i in 0..range
  5157.           coords.push( [0, i] )
  5158.         end  
  5159.       when 4
  5160.         for i in 0..range
  5161.           coords.push( [-i, 0] )
  5162.         end  
  5163.       when 6
  5164.         for i in 0..range
  5165.           coords.push( [i, 0] )
  5166.         end  
  5167.       when 8
  5168.         for i in 0..range
  5169.           coords.push( [0, -i] )
  5170.         end  
  5171.       end  
  5172.     end  
  5173.     for coo in coords
  5174.       o = ygg_get_targets( coo[0]+self.x, coo[1]+self.y, type, true )
  5175.       return o unless o.empty?()
  5176.     end
  5177.     return []
  5178.   end
  5179.  
  5180. end
  5181.  
  5182. #==============================================================================#
  5183. # ** YGG::MixIns::AI
  5184. #==============================================================================#
  5185. module YGG::MixIns::AI
  5186.  
  5187.   #--------------------------------------------------------------------------#
  5188.   # * Public Instance Variables
  5189.   #--------------------------------------------------------------------------#  
  5190.   attr_accessor :ai_engine
  5191.  
  5192.   #--------------------------------------------------------------------------#
  5193.   # * new-method :setup_ai_engine
  5194.   #--------------------------------------------------------------------------#  
  5195.   def setup_ai_engine( engine, setup_data={} )
  5196.     @ai_engine = engine.new( self, setup_data )
  5197.   end
  5198.  
  5199.   #--------------------------------------------------------------------------#
  5200.   # * new-method :terminate_ai_engine
  5201.   #--------------------------------------------------------------------------#  
  5202.   def terminate_ai_engine()
  5203.     @ai_engine = nil
  5204.   end
  5205.  
  5206.   #--------------------------------------------------------------------------#
  5207.   # * new-method :ygg_update_ai
  5208.   #--------------------------------------------------------------------------#
  5209.   def ygg_update_ai()
  5210.     @ai_engine.update() unless @ai_engine.nil?()
  5211.   end
  5212.  
  5213. end
  5214.  
  5215. #==============================================================================#
  5216. # ** YGG::MixIns::Player
  5217. #==============================================================================#
  5218. module YGG::MixIns::Player
  5219.  
  5220.   #--------------------------------------------------------------------------#
  5221.   # * new-method :drop_attraction?
  5222.   #--------------------------------------------------------------------------#
  5223.   def drop_attraction?()
  5224.     return self.ygg_battler.drops_attraction? unless self.ygg_battler.nil?()
  5225.     return false
  5226.   end
  5227.  
  5228. end  
  5229. #==============================================================================#
  5230. # // Mix In
  5231. class Game_Actor     ; include YGG::MixIns::Actor    ; end
  5232. class Game_Enemy     ; include YGG::MixIns::Enemy    ; end
  5233. class Game_Character ; include YGG::MixIns::Movement ; end
  5234. class Game_Character ; include YGG::MixIns::Battle   ; end
  5235. class Game_Event     ; include YGG::MixIns::AI       ; end
  5236. class Game_Player    ; include YGG::MixIns::Player   ; end
  5237. #==============================================================================#  
  5238. #==============================================================================#
  5239. # ** Game_Character
  5240. #==============================================================================#
  5241. class Game_Character
  5242.  
  5243.   #--------------------------------------------------------------------------#
  5244.   # * Public Instance Variable(s)
  5245.   #--------------------------------------------------------------------------#
  5246.   attr_accessor :use_equipment
  5247.  
  5248.   attr_accessor :ygg_atk_delay
  5249.   attr_accessor :ygg_atk_delay_max
  5250.   attr_accessor :ygg_anims
  5251.  
  5252.   attr_accessor :move_speed_mod
  5253.   attr_accessor :tone
  5254.   attr_accessor :zoom_x, :zoom_y
  5255.   attr_accessor :wait_count
  5256.  
  5257.   attr_reader :action_handle
  5258.   attr_accessor :ygg_invincible
  5259.   attr_accessor :guard_time
  5260.  
  5261.   #--------------------------------------------------------------------------#
  5262.   # * alias-method :initialize
  5263.   #--------------------------------------------------------------------------#
  5264.   alias :ygg_gmc_mixin_initialize :initialize unless $@
  5265.   def initialize( *args, &block )
  5266.     ygg_gmc_mixin_initialize( *args, &block )
  5267.     ygg_initialize()
  5268.   end
  5269.  
  5270.   #--------------------------------------------------------------------------#
  5271.   # * new-method :ygg_initialize
  5272.   #--------------------------------------------------------------------------#
  5273.   def ygg_initialize()
  5274.     @use_equipment     = false
  5275.     @equipment_handles = [::YGG::Handlers::Equip.new( self, 0 ),
  5276.                           ::YGG::Handlers::Equip.new( self, 1 )]
  5277.     @action_handle     = ::YGG::Handlers::Action.new( self, [] )
  5278.     @free_act_handles  = []
  5279.     @ygg_registered    = false
  5280.    
  5281.     @ygg_boss          = false
  5282.     @ygg_anims         = []
  5283.     @ygg_slip_counter  = 0
  5284.     @ygg_invincible    = false
  5285.    
  5286.     @move_speed_mod    = 0
  5287.    
  5288.     reset_tone()
  5289.    
  5290.     @zoom_x, @zoom_y   = 1.0, 1.0
  5291.    
  5292.     @ai_operated       = false
  5293.     @hp_visible        = true
  5294.     @mp_visible        = true
  5295.    
  5296.     @guard_time        = 0
  5297.    
  5298.     ygg_register() if $game_system.yggdrasil_on?()  
  5299.   end
  5300.  
  5301.   #--------------------------------------------------------------------------#
  5302.   # * new-method :pop_enabled?
  5303.   #--------------------------------------------------------------------------#  
  5304.   def pop_enabled?() ; return true ; end
  5305.  
  5306.   #--------------------------------------------------------------------------#
  5307.   # * new-method :reset_tone
  5308.   #--------------------------------------------------------------------------#  
  5309.   def reset_tone()
  5310.     @tone              = Tone.new( 0, 0, 0, 0 )
  5311.     @target_tone       = Tone.new( 0, 0, 0, 0 )
  5312.     @tone_time         = 60.0
  5313.   end
  5314.  
  5315.   #--------------------------------------------------------------------------#
  5316.   # * new-method :screen_rect
  5317.   #--------------------------------------------------------------------------#  
  5318.   def screen_rect()
  5319.     @screen_rect ||= Rect.new( -32, -32, Graphics.width, Graphics.height )
  5320.     return @screen_rect
  5321.   end unless method_defined? :screen_rect
  5322.  
  5323.   #--------------------------------------------------------------------------#
  5324.   # * new-method :onScreen?
  5325.   #--------------------------------------------------------------------------#  
  5326.   def onScreen?()
  5327.     r = self.screen_rect
  5328.     return self.screen_x.between?( r.x, r.width ) && self.screen_y.between?( r.y, r.height )
  5329.   end
  5330.  
  5331.   #--------------------------------------------------------------------------#
  5332.   # * new-method :limitedOnScreen?
  5333.   #--------------------------------------------------------------------------#  
  5334.   def limitedOnScreen?()
  5335.     return false unless screen_x.between?( 0, Graphics.width ) && screen_y.between?( 0, Graphics.height )
  5336.     return true
  5337.   end
  5338.  
  5339.   #--------------------------------------------------------------------------#
  5340.   # * overwrite-method :collide_with_characters?
  5341.   #--------------------------------------------------------------------------#
  5342.   def collide_with_characters?( x, y )
  5343.     for event in $game_map.events_xy( x, y )          # Matches event position
  5344.       unless event.through                          # Passage OFF?
  5345.         return true if event.priority_type == 1     # Target is normal char
  5346.       end
  5347.     end
  5348.     if @priority_type == 1                          # Self is normal char
  5349.       return true if $game_player.pos_nt?(x, y)     # Matches player position
  5350.       return true if $game_map.boat.pos_nt?(x, y)   # Matches boat position
  5351.       return true if $game_map.ship.pos_nt?(x, y)   # Matches ship position
  5352.     end
  5353.     return false
  5354.   end
  5355.  
  5356.   #--------------------------------------------------------------------------#
  5357.   # * overwrite-method :update_move
  5358.   #--------------------------------------------------------------------------#  
  5359.   def update_move()
  5360.     distance = 2 ** self.move_speed   # Convert to movement distance
  5361.     distance *= 2 if dash?        # If dashing, double it
  5362.     @real_x = [@real_x - distance, @x * 256].max if @x * 256 < @real_x
  5363.     @real_x = [@real_x + distance, @x * 256].min if @x * 256 > @real_x
  5364.     @real_y = [@real_y - distance, @y * 256].max if @y * 256 < @real_y
  5365.     @real_y = [@real_y + distance, @y * 256].min if @y * 256 > @real_y
  5366.     update_bush_depth unless moving?
  5367.     if @walk_anime
  5368.       @anime_count += 1.5
  5369.     elsif @step_anime
  5370.       @anime_count += 1
  5371.     end
  5372.   end
  5373.  
  5374.   #--------------------------------------------------------------------------#
  5375.   # * overwrite-method :update_animation
  5376.   #--------------------------------------------------------------------------#  
  5377.   def update_animation()
  5378.     speed = self.move_speed + (dash? ? 1 : 0)
  5379.     if @anime_count > 18 - speed * 2
  5380.       if not @step_anime and @stop_count > 0
  5381.         @pattern = @original_pattern
  5382.       else
  5383.         @pattern = (@pattern + 1) % 4
  5384.       end
  5385.       @anime_count = 0
  5386.     end
  5387.   end
  5388.  
  5389.   #--------------------------------------------------------------------------#
  5390.   # * new-method :extra_speed_mod
  5391.   #--------------------------------------------------------------------------#  
  5392.   def extra_speed_mod()
  5393.     return self.ygg_battler.nil?() ? 0 : ygg_battler.move_mod  
  5394.   end
  5395.  
  5396.   #--------------------------------------------------------------------------#
  5397.   # * new-method :move_speed
  5398.   #--------------------------------------------------------------------------#  
  5399.   def move_speed()
  5400.     return @move_speed + @move_speed_mod + extra_speed_mod
  5401.   end
  5402.  
  5403.   #--------------------------------------------------------------------------#
  5404.   # * new-method :equip_handle
  5405.   #--------------------------------------------------------------------------#
  5406.   def equip_handle( eq_id ) ; @equipment_handles[eq_id] ; end
  5407.    
  5408.   #--------------------------------------------------------------------------#
  5409.   # * new-method :equip_icon
  5410.   #--------------------------------------------------------------------------#  
  5411.   def equip_icon( eq_id )
  5412.     return 0 if self.ygg_battler.nil?()
  5413.     return self.ygg_battler.equip_icon( eq_id )
  5414.   end
  5415.  
  5416.   #--------------------------------------------------------------------------#
  5417.   # * new-method :equip_atk_act_name
  5418.   #--------------------------------------------------------------------------#    
  5419.   def equip_atk_act_name( eq_id )
  5420.     return "" if self.ygg_battler.nil?()
  5421.     return self.ygg_battler.equip_atk_act_name( eq_id )
  5422.   end
  5423.  
  5424.   #--------------------------------------------------------------------------#
  5425.   # * new-method :equip_grd_act_name
  5426.   #--------------------------------------------------------------------------#    
  5427.   def equip_grd_act_name( eq_id )
  5428.     return "" if self.ygg_battler.nil?()
  5429.     return self.ygg_battler.equip_grd_act_name( eq_id )
  5430.   end
  5431.    
  5432.   #--------------------------------------------------------------------------#
  5433.   # * alias-method :update
  5434.   #--------------------------------------------------------------------------#
  5435.   alias :ygg_gmc_mixin_update :update unless $@
  5436.   def update( *args, &block )
  5437.     ygg_gmc_mixin_update( *args, &block )
  5438.     if self.ygg_battler.nil?()
  5439.       ygg_unregister() if @ygg_registered
  5440.     else
  5441.       abs_on = $game_system.yggdrasil_on?()  
  5442.       if abs_on
  5443.         @target_tone = self.ygg_battler.effect_tone
  5444.         if self.ygg_battler.character_need_refresh
  5445.           self.ygg_battler.character_need_refresh = false
  5446.         end  
  5447.         ygg_register() unless @ygg_registered
  5448.         @equipment_handles.each { |eq| eq.update() }
  5449.         self.ygg_engage.update() unless self.ygg_engage.nil?()
  5450.         @action_handle.update()
  5451.         @free_act_handles = @free_act_handles.inject([]) { |r, h|
  5452.           h.update() ; r << h if h.busy?() ; r
  5453.         } unless @free_act_handles.empty?()
  5454.       end  
  5455.     end  
  5456.     [:red, :green, :blue, :gray].each { |s|
  5457.       v1, v2 = @tone.send(s), @target_tone.send(s)
  5458.       if v1 > v2
  5459.         @tone.send( s.to_s+"=", [v1-(255.0/@tone_time), v2].max )
  5460.       elsif v1 < v2
  5461.         @tone.send( s.to_s+"=", [v1+(255.0/@tone_time), v2].min )
  5462.       end  
  5463.     }
  5464.   end
  5465.  
  5466.   #--------------------------------------------------------------------------#
  5467.   # * new-method :ygg_engage
  5468.   #--------------------------------------------------------------------------#
  5469.   def ygg_engage()
  5470.     return ygg_battler.ygg_engage
  5471.   end
  5472.  
  5473.   #--------------------------------------------------------------------------#
  5474.   # * new-method :ygg_register
  5475.   #--------------------------------------------------------------------------#
  5476.   def ygg_register()
  5477.     $game_yggdrasil.add_battler( self )
  5478.     @ygg_registered = true
  5479.   end  
  5480.  
  5481.   #--------------------------------------------------------------------------#
  5482.   # * new-method :ygg_unregister
  5483.   #--------------------------------------------------------------------------#
  5484.   def ygg_unregister()
  5485.     $game_yggdrasil.remove_battler( self )
  5486.     @ygg_registered = false
  5487.   end
  5488.  
  5489.   #--------------------------------------------------------------------------#
  5490.   # * new-method :get_target_events
  5491.   #--------------------------------------------------------------------------#
  5492.   def get_target_events( xy_list )
  5493.     return xy_list.inject([]) { |result, point|
  5494.       result + $game_yggdrasil.battlers_xy( *point )
  5495.     }
  5496.   end
  5497.    
  5498.   #--------------------------------------------------------------------------#
  5499.   # * new-method :set_through
  5500.   #--------------------------------------------------------------------------#  
  5501.   def set_through( bool ) ; @through = bool ; end
  5502.    
  5503. end
  5504.  
  5505. # // (YGG_VG)
  5506. #==============================================================================#
  5507. # // Start Yggdrasil Visual Code
  5508. #==============================================================================#
  5509. # ** YGG
  5510. #==============================================================================#
  5511. module YGG
  5512. #==============================================================================#
  5513. # ** YGG::Sprites::ValueBar_Base
  5514. #==============================================================================#  
  5515.   class Sprites::ValueBar_Base < ::Sprite
  5516.    
  5517.     BAR_DRAW_MODE = 0 # // 0 Use 2 sprites, 1 Draw onto base
  5518.    
  5519.     #--------------------------------------------------------------------------#
  5520.     # * super-method :initialize
  5521.     #--------------------------------------------------------------------------#        
  5522.     def initialize( parent, base_name, bar_name, value_proc, max_proc )
  5523.       super( parent.viewport )
  5524.       @parent       = parent
  5525.       @base_name    = base_name
  5526.       @bar_name     = bar_name
  5527.       case BAR_DRAW_MODE
  5528.       when 0
  5529.         self.bitmap   = Cache.system( base_name )
  5530.         @bar          = ::Sprite_Base.new( self.viewport )
  5531.         @bar.bitmap   = Cache.system( bar_name )
  5532.         @bar.x        = self.x       = @parent.x
  5533.         @bar.y        = self.y       = @parent.y
  5534.         @bar.visible  = self.visible = @parent.visible
  5535.       when 1
  5536.         base_ref      = Cache.system( base_name )
  5537.         self.bitmap   = Bitmap.new( base_ref.width, base_ref.height )
  5538.       end  
  5539.       @value_proc     = value_proc
  5540.       @max_proc       = max_proc
  5541.       @last_value     = -1
  5542.       @last_max       = -1
  5543.       @offsets        = ::YGG::Pos.new( 0, 0, 0 )
  5544.       @baroffsets     = ::YGG::Pos.new( 0, 0, 1 )
  5545.     end
  5546.    
  5547.     #--------------------------------------------------------------------------#
  5548.     # * super-method :dispose
  5549.     #--------------------------------------------------------------------------#    
  5550.     def dispose()
  5551.       case BAR_DRAW_MODE
  5552.       when 0
  5553.         @bar.dispose()
  5554.       when 1
  5555.         self.bitmap.dispose()
  5556.       end  
  5557.       super()
  5558.     end
  5559.    
  5560.   case BAR_DRAW_MODE
  5561.   when 0
  5562.    
  5563.     #--------------------------------------------------------------------------#
  5564.     # * super-method :update
  5565.     #--------------------------------------------------------------------------#    
  5566.     def update()
  5567.       super()
  5568.       val = @value_proc.call() #* 100
  5569.       max = @max_proc.call() #* 100
  5570.       if (val != @last_value || max != @last_max)
  5571.         if max.eql?( 0 )
  5572.           @bar.src_rect.width = 0
  5573.         else  
  5574.           bar_width = @bar.bitmap.width * val / max
  5575.           @bar.src_rect.width = bar_width
  5576.         end  
  5577.         @last_value = val
  5578.         @last_max   = max
  5579.       end
  5580.       pox = @parent.src_rect.width / 2 - (@parent.src_rect.width +
  5581.         self.bitmap.width) / 2
  5582.       @bar.x       = @baroffsets.x + self.x       = @parent.x + pox + @offsets.x
  5583.       @bar.y       = @baroffsets.y + self.y       = @parent.y + @offsets.y
  5584.       @bar.z       = @baroffsets.z + self.z       = @parent.z + @offsets.z
  5585.       @bar.visible = self.visible# = @parent.visible
  5586.       @bar.opacity = self.opacity
  5587.     end
  5588.    
  5589.   when 1  
  5590.    
  5591.     #--------------------------------------------------------------------------#
  5592.     # * super-method :update
  5593.     #--------------------------------------------------------------------------#    
  5594.     def update()
  5595.       super()
  5596.       val = @value_proc.call() #* 100
  5597.       max = @max_proc.call() #* 100
  5598.       if (val != @last_value || max != @last_max)
  5599.         self.bitmap.clear()
  5600.         base = Cache.system( @base_name )
  5601.         bar  = Cache.system( @bar_name )
  5602.         self.bitmap.blt( 0, 0, base, base.rect )
  5603.         unless max.eql?( 0 )
  5604.           bar_width = bar.width * val / max
  5605.           rect = bar.rect.clone()
  5606.           rect.width = bar_width
  5607.           self.bitmap.blt( @baroffsets.x, @baroffsets.y, bar, rect )
  5608.         end  
  5609.         @last_value = val
  5610.         @last_max   = max
  5611.       end
  5612.       pox = @parent.src_rect.width / 2 - (@parent.src_rect.width +
  5613.       self.bitmap.width) / 2
  5614.       self.x       = @parent.x + pox + @offsets.x
  5615.       self.y       = @parent.y + @offsets.y
  5616.       self.z       = @parent.z + @offsets.z
  5617.       #self.visible = @parent.visible
  5618.     end  
  5619.    
  5620.   end
  5621.    
  5622.   end
  5623. #==============================================================================#
  5624. # ** YGG::Sprites::HpBar
  5625. #==============================================================================#    
  5626.   class Sprites::HpBar < Sprites::ValueBar_Base
  5627.    
  5628.     #--------------------------------------------------------------------------#
  5629.     # * super-method :initialize
  5630.     #--------------------------------------------------------------------------#    
  5631.     def initialize( parent )
  5632.       val_proc = Proc.new { @parent.character.ygg_attacker.hp }
  5633.       max_proc = Proc.new { @parent.character.ygg_attacker.maxhp }
  5634.       base_name= "1x6Graphics/EventBarBase"
  5635.       if parent.character.ygg_attacker.actor?()
  5636.         bar_name = "1x6Graphics/EventBar2"
  5637.       else
  5638.         bar_name = "1x6Graphics/EventBar3"
  5639.       end  
  5640.       super( parent, base_name, bar_name, val_proc, max_proc )
  5641.       @offsets.set( 0, 0, 0 )
  5642.       @baroffsets.set( 1, 1, 0 )
  5643.     end
  5644.  
  5645.     #--------------------------------------------------------------------------#
  5646.     # * super-method :update
  5647.     #--------------------------------------------------------------------------#
  5648.     def update()
  5649.       self.opacity = @parent.character.ygg_engage.bar_opacity
  5650.       self.visible = @parent.character.hp_visible?() && @parent.visible
  5651.       super()
  5652.     end
  5653.    
  5654.   end
  5655. #==============================================================================#
  5656. # ** YGG::Sprites::MpBar
  5657. #==============================================================================#  
  5658.   class Sprites::MpBar < Sprites::ValueBar_Base
  5659.    
  5660.     #--------------------------------------------------------------------------#
  5661.     # * super-method :initialize
  5662.     #--------------------------------------------------------------------------#    
  5663.     def initialize( parent )
  5664.       val_proc = Proc.new { @parent.character.ygg_attacker.mp }
  5665.       max_proc = Proc.new { @parent.character.ygg_attacker.maxmp }
  5666.       base_name= "1x6Graphics/EventBarBase"
  5667.       bar_name = "1x6Graphics/EventBar5"
  5668.       super( parent, base_name, bar_name, val_proc, max_proc )
  5669.       @offsets.set( 0, 6, 0 )
  5670.       @baroffsets.set( 1, 1, 1 )
  5671.     end
  5672.    
  5673.     #--------------------------------------------------------------------------#
  5674.     # * super-method :update
  5675.     #--------------------------------------------------------------------------#
  5676.     def update()
  5677.       #self.opacity = @parent.character.ygg_engage.bar_opacity
  5678.       self.visible = @parent.character.mp_visible?() && @parent.visible
  5679.       super()
  5680.     end
  5681.    
  5682.   end
  5683.    
  5684. end  
  5685.  
  5686. #==============================================================================#
  5687. # ** Sprite_Character
  5688. #==============================================================================#
  5689. class Sprite_Character < Sprite_Base
  5690.  
  5691.   #--------------------------------------------------------------------------#
  5692.   # * alias-method :initialize
  5693.   #--------------------------------------------------------------------------#
  5694.   alias :ygg1x6_hpmp_spc_initialize :initialize unless $@
  5695.   def initialize( *args )
  5696.     ygg1x6_hpmp_spc_initialize( *args )
  5697.     create_bars()
  5698.     update_bars()
  5699.   end
  5700.  
  5701.   #--------------------------------------------------------------------------#
  5702.   # * new-method :create_bars
  5703.   #--------------------------------------------------------------------------#
  5704.   def create_bars()
  5705.     unless @character.ygg_battler.nil?()
  5706.       create_hp_bar() if @hp_bar.nil?() if ::YGG::USE_HPBAR
  5707.       create_mp_bar() if @mp_bar.nil?() if ::YGG::USE_MPBAR
  5708.     end
  5709.   end
  5710.  
  5711.   #--------------------------------------------------------------------------#
  5712.   # * new-method :create_hp_bar
  5713.   #--------------------------------------------------------------------------#
  5714.   def create_hp_bar()
  5715.     return if @character.ygg_battler.nil?()
  5716.     @hp_bar = ::YGG::Sprites::HpBar.new( self )
  5717.   end
  5718.  
  5719.   #--------------------------------------------------------------------------#
  5720.   # * new-method :create_mp_bar
  5721.   #--------------------------------------------------------------------------#  
  5722.   def create_mp_bar()
  5723.     return if @character.ygg_battler.nil?()
  5724.     @mp_bar = ::YGG::Sprites::MpBar.new( self )
  5725.   end
  5726.  
  5727.   #--------------------------------------------------------------------------#
  5728.   # * alias-method :dispose
  5729.   #--------------------------------------------------------------------------#
  5730.   alias :ygg1x6_hpmp_spc_dispose :dispose unless $@
  5731.   def dispose()
  5732.     dispose_bars()
  5733.     ygg1x6_hpmp_spc_dispose()
  5734.   end
  5735.  
  5736.   #--------------------------------------------------------------------------#
  5737.   # * new-method :dispose_bars
  5738.   #--------------------------------------------------------------------------#  
  5739.   def dispose_bars()
  5740.     dispose_hp_bar() unless @hp_bar.nil?()
  5741.     dispose_mp_bar() unless @mp_bar.nil?()
  5742.   end
  5743.  
  5744.   #--------------------------------------------------------------------------#
  5745.   # * new-method :dispose_hp_bar
  5746.   #--------------------------------------------------------------------------#  
  5747.   def dispose_hp_bar() ; @hp_bar.dispose() ; @hp_bar = nil ; end
  5748.  
  5749.   #--------------------------------------------------------------------------#
  5750.   # * new-method :dispose_mp_bar
  5751.   #--------------------------------------------------------------------------#  
  5752.   def dispose_mp_bar() ; @mp_bar.dispose() ; @mp_bar = nil ; end
  5753.  
  5754.   #--------------------------------------------------------------------------#
  5755.   # * alias-method :update
  5756.   #--------------------------------------------------------------------------#  
  5757.   alias :ygg1x6_hpmp_spc_update :update unless $@
  5758.   def update()
  5759.     ygg1x6_hpmp_spc_update()
  5760.     update_bars() unless @character.nil?()
  5761.   end
  5762.  
  5763.   #--------------------------------------------------------------------------#
  5764.   # * new-method :update_bars
  5765.   #--------------------------------------------------------------------------#  
  5766.   def update_bars()
  5767.     update_hp_bar() unless @hp_bar.nil?()
  5768.     update_mp_bar() unless @mp_bar.nil?()
  5769.   end
  5770.  
  5771.   #--------------------------------------------------------------------------#
  5772.   # * new-method :update_hp_bar
  5773.   #--------------------------------------------------------------------------#  
  5774.   def update_hp_bar()
  5775.     if @hp_bar.nil?() && !@character.ygg_attacker.nil?()
  5776.       create_hp_bar()
  5777.     elsif !@hp_bar.nil?() && @character.ygg_attacker.nil?()  
  5778.       dispose_hp_bar()
  5779.     end
  5780.     @hp_bar.update() unless @hp_bar.nil?()
  5781.   end
  5782.  
  5783.   #--------------------------------------------------------------------------#
  5784.   # * new-method :update_mp_bar
  5785.   #--------------------------------------------------------------------------#  
  5786.   def update_mp_bar()
  5787.     if @mp_bar.nil?() && !@character.ygg_attacker.nil?()
  5788.       create_mp_bar()
  5789.     elsif !@mp_bar.nil?() && @character.ygg_attacker.nil?()  
  5790.       dispose_mp_bar()
  5791.     end
  5792.     @mp_bar.update() unless @mp_bar.nil?()
  5793.   end
  5794.  
  5795. end if ::YGG::USE_STAT_BARS
  5796.  
  5797. #==============================================================================#
  5798. # ** YGG
  5799. #==============================================================================#
  5800. module YGG  
  5801. #==============================================================================#
  5802. # ** PopText
  5803. #==============================================================================#  
  5804.   PopText = Struct.new( :text, :font, :move_rule )
  5805. #==============================================================================#  
  5806.   class PopText
  5807.    
  5808.   #--------------------------------------------------------------------------#
  5809.   # * new-class-method :create_pop
  5810.   #--------------------------------------------------------------------------#  
  5811.     def self.create_pop( setup_data={} )
  5812.       character  = setup_data[:character]
  5813.       bat        = setup_data[:battler] || (character.nil?() ? nil : character.ygg_battler)
  5814.       type       = setup_data[:type] || :nil
  5815.       parameters = setup_data[:parameters] || []
  5816.       move_rule  = :default
  5817.       pop_stack  = []
  5818.       font_size_add = 0
  5819.       case type
  5820.       when :attack_damage, :skill_damage, :item_damage
  5821.         case type
  5822.         when :attack_damage
  5823.           move_rule = bat.critical ? :shatter : :attack_default
  5824.         when :skill_damage  
  5825.           move_rule = bat.critical ? :shatter : :skill_default
  5826.         when :item_damage
  5827.           move_rule = bat.critical ? :shatter : :item_default
  5828.         end
  5829.         font_size_add += ::YGG::CRITICAL_FONTSIZE_ADD if bat.critical
  5830.         if bat.hp_damage > 0
  5831.           rule = YGG::POPUP_RULES["HP_DMG"]
  5832.           text = sprintf( YGG::POPUP_SETTINGS[:hp_dmg], bat.hp_damage.abs )
  5833.         elsif bat.hp_damage < 0
  5834.           rule = YGG::POPUP_RULES["HP_HEAL"]
  5835.           text = sprintf( YGG::POPUP_SETTINGS[:hp_heal], bat.hp_damage.abs )
  5836.         elsif bat.missed    
  5837.           rule = YGG::POPUP_RULES["MISSED"]
  5838.           text = YGG::POPUP_SETTINGS[:missed]
  5839.         elsif bat.evaded    
  5840.           rule = YGG::POPUP_RULES["EVADED"]
  5841.           text = YGG::POPUP_SETTINGS[:evaded]
  5842.         elsif bat.skipped  
  5843.           rule = YGG::POPUP_RULES["NULLED"]
  5844.           text = YGG::POPUP_SETTINGS[:nulled]
  5845.         elsif bat.hp_damage == 0
  5846.           rule = YGG::POPUP_RULES["HP_NO_DMG"]
  5847.           text = sprintf( YGG::POPUP_SETTINGS[:hp_dmg], bat.hp_damage.abs )
  5848.         end
  5849.         pop_stack << [text, rule, move_rule]  
  5850.         pop_stack << [YGG::POPUP_SETTINGS[:critical],
  5851.                       YGG::POPUP_RULES["CRITICAL"],
  5852.                       :crit_default] if bat.critical if YGG::SHOW_CRITICAL
  5853.         pop_stack << [POPUP_SETTINGS[:guard],
  5854.                       YGG::POPUP_RULES["GUARD"],
  5855.                       :guard_default] if bat.guarding?() if YGG::SHOW_GUARD            
  5856.         if type == :skill_damage || type == :item_damage          
  5857.           skip_stack = false
  5858.           if bat.mp_damage > 0
  5859.             rule = YGG::POPUP_RULES["MP_DMG"]
  5860.             text = sprintf( YGG::POPUP_SETTINGS[:mp_dmg], bat.mp_damage.abs )
  5861.           elsif bat.mp_damage < 0
  5862.             rule = YGG::POPUP_RULES["MP_HEAL"]
  5863.             text = sprintf( YGG::POPUP_SETTINGS[:mp_heal], bat.mp_damage.abs )
  5864.           elsif bat.missed  
  5865.             skip_stack = true
  5866.             #rule = YGG::POPUP_RULES["MISSED"]
  5867.             #text = YGG::POPUP_SETTINGS[:missed]
  5868.           elsif bat.evaded    
  5869.             skip_stack = true
  5870.             #rule = YGG::POPUP_RULES["EVADED"]
  5871.             #text = YGG::POPUP_SETTINGS[:evaded]
  5872.           elsif bat.skipped  
  5873.             skip_stack = true
  5874.             #rule = YGG::POPUP_RULES["NULLED"]
  5875.             #text = YGG::POPUP_SETTINGS[:nulled]
  5876.           elsif bat.mp_damage == 0
  5877.             skip_stack = true
  5878.           #  rule = YGG::POPUP_RULES["MP_NO_DMG"]
  5879.           #  text = sprintf( YGG::POPUP_SETTINGS[:mp_dmg], bat.mp_damage.abs )
  5880.           end
  5881.           pop_stack << [text, rule, move_rule] unless skip_stack
  5882.         end
  5883.       when :gain_exp
  5884.         rule = YGG::POPUP_RULES["EXP_POP"]
  5885.         text = sprintf( YGG::POPUP_SETTINGS[:exp_pop], parameters[0] )
  5886.         move_rule = :exp_default
  5887.         pop_stack << [text, rule, move_rule]
  5888.       when :level_up  
  5889.         rule = YGG::POPUP_RULES["LVL_POP"]
  5890.         text = sprintf( YGG::POPUP_SETTINGS[:lvl_pop], parameters[0] )
  5891.         move_rule = :lvl_default
  5892.         pop_stack << [text, rule, move_rule]
  5893.       when :custom
  5894.         rule = [
  5895.           setup_data[:font_size] || font.size,
  5896.           setup_data[:font_color] || Font.default_color,
  5897.           [(setup_data[:font_bold] || Font.default_bold) ? "BOLD" : "NO BOLD",
  5898.            (setup_data[:font_italic] || Font.default_italic) ? "ITALIC" : "NO ITALIC",
  5899.            (setup_data[:font_shadow] || Font.default_shadow) ? "SHADOW" : "NO SHADOW"
  5900.           ],
  5901.           setup_data[:font_name]
  5902.         ]
  5903.         pop_stack << [setup_data[:text] || "", rule, setup_data[:move_rule] || :default]
  5904.       end
  5905.       pop_stack.each { |pop|
  5906.         text, rule, move_rule = *pop
  5907.         font        = Font.new()
  5908.         proprule    = rule[2].inject([]) { |r, s| s.upcase }
  5909.         colors      = rule[1].kind_of?( Array ) ? rule[1] : [rule[1], rule[1]]
  5910.         font.name   = rule[3].empty? ? Font.default_name : rule[3]
  5911.         font.size   = (rule[0] || Font.default_size) + font_size_add
  5912.         font.bold   = proprule.include?("BOLD")
  5913.         font.italic = proprule.include?("ITALIC")
  5914.         font.shadow = proprule.include?("SHADOW")
  5915.         font.bold   = false if proprule.include?("NO BOLD")
  5916.         font.italic = false if proprule.include?("NO ITALIC")
  5917.         font.shadow = false if proprule.include?("NO SHADOW")
  5918.         font.color  = bat.nil?() ? colors[1] : (bat.actor?() ? colors[1] : colors[0])
  5919.         $game_yggdrasil.add_pop( self.new( text, font, move_rule ), character.x, character.y )
  5920.       }
  5921.     end
  5922.    
  5923.   end  
  5924.  
  5925. #==============================================================================#
  5926. # ** PopHandler
  5927. #==============================================================================#  
  5928.   class PopHandler < ::YGG::Handlers::Screen
  5929.    
  5930.     class BounceHandle
  5931.    
  5932.     #--------------------------------------------------------------------------#
  5933.     # * Public Instance Variable(s)
  5934.     #--------------------------------------------------------------------------#    
  5935.       attr_accessor :x, :y
  5936.       attr_accessor :ox, :oy
  5937.      
  5938.       attr_accessor :x_velocity, :y_velocity
  5939.       attr_accessor :x_boost, :y_boost
  5940.       attr_accessor :x_add, :y_add
  5941.    
  5942.       attr_accessor :cap_duration
  5943.       attr_accessor :finished
  5944.       attr_accessor :pause_update
  5945.       attr_accessor :gravity
  5946.       attr_accessor :floor_val
  5947.      
  5948.     #--------------------------------------------------------------------------#
  5949.     # * Constant(s)
  5950.     #--------------------------------------------------------------------------#      
  5951.       GRAVITY = 0.58
  5952.       TRANSEPARENT_START = 0
  5953.       TRANSEPARENT_X_SLIDE = 0    
  5954.      
  5955.     #--------------------------------------------------------------------------#
  5956.     # * new-method :initialize
  5957.     #--------------------------------------------------------------------------#
  5958.       def initialize( setup_data={} )
  5959.         @start_settings = [setup_data[:x] || 0, setup_data[:y] || 0, 0, 0]
  5960.         @cap_duration = setup_data[:cap_duration] || 80
  5961.         @x_velocity = setup_data[:x_velocity] || 0.4
  5962.         @y_velocity = setup_data[:y_velocity] || 1.5
  5963.         @x_boost    = setup_data[:x_boost] || 8
  5964.         @y_boost    = setup_data[:y_boost] || 4
  5965.         @x_add      = setup_data[:x_add] || 0
  5966.         @y_add      = setup_data[:y_add] || 4
  5967.         @gravity    = setup_data[:gravity] || GRAVITY
  5968.         @floor_val  = setup_data[:floor_val] || 0
  5969.         reset()
  5970.       end
  5971.      
  5972.     #--------------------------------------------------------------------------#
  5973.     # * new-method :reset
  5974.     #--------------------------------------------------------------------------#
  5975.       def reset()
  5976.         @x, @y, @ox, @oy = *@start_settings
  5977.         @finished = false
  5978.         @pause_update = false
  5979.         prep_pop()
  5980.       end
  5981.      
  5982.     #--------------------------------------------------------------------------#
  5983.     # * new-method :x_init_velocity
  5984.     #--------------------------------------------------------------------------#
  5985.       def x_init_velocity()
  5986.         return @x_velocity * ( rand(@x_boost) + @x_add )
  5987.       end
  5988.      
  5989.     #--------------------------------------------------------------------------#
  5990.     # * new-method :y_init_velocity
  5991.     #--------------------------------------------------------------------------#
  5992.       def y_init_velocity()
  5993.         return @y_velocity * ( rand(@y_boost) + @y_add )  
  5994.       end
  5995.      
  5996.     #--------------------------------------------------------------------------#
  5997.     # * new-method :prep_pop
  5998.     #--------------------------------------------------------------------------#
  5999.       def prep_pop()
  6000.         @now_x_speed = x_init_velocity
  6001.         @now_y_speed = y_init_velocity
  6002.         @potential_x_energy = 0.0
  6003.         @potential_y_energy = 0.0
  6004.         @speed_off_x = rand(2)
  6005.         @pop_duration = @cap_duration
  6006.       end
  6007.      
  6008.     #--------------------------------------------------------------------------#
  6009.     # * new-method :update
  6010.     #--------------------------------------------------------------------------#
  6011.       def update()
  6012.         return if @finished or @pause_update
  6013.         if @pop_duration <= TRANSEPARENT_START
  6014.           @x += TRANSEPARENT_X_SLIDE if @speed_off_x == 0
  6015.           @x -= TRANSEPARENT_X_SLIDE if @speed_off_x == 1
  6016.         end
  6017.         n = @oy + @now_y_speed
  6018.         if n <= @floor_val #0
  6019.           @now_y_speed *= -1
  6020.           @now_y_speed /=  2
  6021.           @now_x_speed /=  2
  6022.         end      
  6023.         @oy = [n, @floor_val].max
  6024.         @potential_y_energy += @gravity
  6025.         speed                = @potential_y_energy.floor
  6026.         @now_y_speed        -= speed
  6027.         @potential_y_energy -= speed
  6028.         @potential_x_energy += @now_x_speed
  6029.         speed                = @potential_x_energy.floor
  6030.         @ox                 += speed if @speed_off_x == 0
  6031.         @ox                 -= speed if @speed_off_x == 1
  6032.         @potential_x_energy -= speed
  6033.         @pop_duration       -= 1
  6034.         if @pop_duration == 0
  6035.           @finished = true
  6036.         end
  6037.       end
  6038.    
  6039.     end
  6040.  
  6041.   #--------------------------------------------------------------------------#
  6042.   # * Public Instance Variable(s)
  6043.   #--------------------------------------------------------------------------#    
  6044.     attr_accessor :ox, :oy, :oz
  6045.     attr_accessor :width, :height
  6046.     attr_accessor :zoom_x, :zoom_y
  6047.     attr_accessor :opacity
  6048.    
  6049.     attr_accessor :poptext
  6050.     attr_accessor :completed
  6051.    
  6052.   #--------------------------------------------------------------------------#
  6053.   # * new-method :initialize
  6054.   #--------------------------------------------------------------------------#                      
  6055.     def initialize( poptext, x, y, z )
  6056.       super( x, y, z )
  6057.       @frame     = 0
  6058.       @poptext   = poptext
  6059.       @ox        = 0
  6060.       @oy        = 0
  6061.       @oz        = 0
  6062.       @width     = 128
  6063.       @height    = 32
  6064.       @opacity   = 255
  6065.       @zoom_x    = 1.0
  6066.       @zoom_y    = 1.0
  6067.       @completed = false
  6068.       @bounce_handle = BounceHandle.new( { :x => 0, :y => 0 } )
  6069.     end
  6070.    
  6071.   #--------------------------------------------------------------------------#
  6072.   # * new-method :complete?()
  6073.   #--------------------------------------------------------------------------#                    
  6074.     def complete?() ; return @completed ; end
  6075.      
  6076.   #--------------------------------------------------------------------------#
  6077.   # * new-method :update
  6078.   #--------------------------------------------------------------------------#                  
  6079.     def update()
  6080.       case @poptext.move_rule
  6081.       when :default
  6082.         case @frame
  6083.         when 0..10
  6084.           @ox += 2
  6085.         when 11..20
  6086.           @ox -= 2
  6087.         when 21..40
  6088.           @oy -= 2
  6089.         when 41..60
  6090.           @oy -= 4
  6091.           @opacity -= 255 / 20
  6092.         when 61
  6093.           @completed = true
  6094.         end
  6095.       when :attack_default, :skill_default, :item_default  
  6096.         @bounce_handle.update()
  6097.         @ox, @oy = @bounce_handle.ox, -@bounce_handle.oy
  6098.         @completed = @bounce_handle.finished
  6099.       when :exp_default
  6100.         case @frame
  6101.         when 0...1
  6102.           @oy -= 16
  6103.         when 1..32
  6104.           @oy += 1
  6105.         when 33..64
  6106.           @opacity -= 255 / 32
  6107.         when 65
  6108.           @completed = true
  6109.         end
  6110.       when :lvl_default
  6111.         case @frame
  6112.         when 0..64
  6113.           @ox -= 1
  6114.         when 65..96  
  6115.           @opacity -= 255 / 32
  6116.         when 97
  6117.           @completed = true
  6118.         end  
  6119.       when :crit_default
  6120.         case @frame
  6121.         when 0...1
  6122.           @oy -= 16
  6123.         when 1..32
  6124.           @oy -= 2
  6125.           @zoom_x += 1.0 / 32
  6126.           @zoom_y = @zoom_x
  6127.         when 33..64
  6128.           @opacity -= 255 / 32
  6129.           @zoom_x -= 1.0 / 32
  6130.           @zoom_y = @zoom_x
  6131.         when 65
  6132.           @completed = true
  6133.         end
  6134.       when :guard_default  
  6135.         case @frame
  6136.         when 0...1
  6137.           @oy -= 16
  6138.         when 1..32
  6139.           @oy -= 2
  6140.           @zoom_x += 0.5 / 32
  6141.           @zoom_y = @zoom_x
  6142.         when 33..64
  6143.           @opacity -= 255 / 32
  6144.           @zoom_x -= 0.5 / 32
  6145.           @zoom_y = @zoom_x
  6146.         when 65
  6147.           @completed = true
  6148.         end
  6149.       when :shatter
  6150.         case @frame
  6151.         when 0..5
  6152.           @ox += 3
  6153.         when 6..10
  6154.           @ox -= 3
  6155.         when 11..30
  6156.           @ox += 3
  6157.           @oy -= 1
  6158.           @opacity -= 255 / 80
  6159.         when 31..50
  6160.           @ox -= 3
  6161.           @oy -= 1
  6162.           @opacity -= 255 / 80
  6163.         when 51..60  
  6164.           @opacity -= 255 / 40
  6165.         when 61
  6166.           @completed = true
  6167.         end
  6168.       end
  6169.       @frame += 1
  6170.     end  
  6171.    
  6172.   #--------------------------------------------------------------------------#
  6173.   # * new-method :screen_|x/y/z
  6174.   #--------------------------------------------------------------------------#                
  6175.     def screen_x() ; return super() + @ox      ; end    
  6176.     def screen_y() ; return super() + @oy + 32 ; end    
  6177.     def screen_z() ; return super() + @oz      ; end
  6178.    
  6179.   end
  6180.    
  6181. #==============================================================================#
  6182. # ** PopSprite