Advertisement
IceDragon200

Yggdrasil 1.6a

Nov 30th, 2011
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 386.12 KB | None | 0 0
  1. #==============================================================================#
  2. # ** Yggdrasil 1x6 - Engine (Full)
  3. #------------------------------------------------------------------------------#
  4. # ** Created by    : IceDragon (http://www.rpgmakervx.net/)
  5. # ** Script-Status : CBS (Custom Battle System)
  6. # ** Script Type   : Engine (ABS Base)
  7. # ** Date Created  : 10/11/2010
  8. # ** Date Modified : 11/30/2011
  9. # ** Version       : 1.6a
  10. #------------------------------------------------------------------------------#
  11. #==============================================================================#
  12. # ** INTRODUCTION
  13. #------------------------------------------------------------------------------#
  14. #  Well what do I say... Okay so this is my First CBS (Custom Battle System)
  15. #  This is not meant to be Noob friendly.
  16. #  >.> The customization is also a bit complicated
  17. #  But hey, welcome to my world, nothing is simple.
  18. #  Well enough of my Ranting.
  19. #
  20. #  Yggdrasil is a Large Addon based ABS (Active Battle System)
  21. #  This script does not support skills, or actions (These are other scripts)
  22. #  This is meant to be the core script.
  23. #  
  24. #  If you encounter any bugs (Except Lag) please report them.
  25. #  If you have suggestions or just want to drop a line.
  26. #  Drop by at http://www.rpgmakervx.net/ and feel free to send me a PM or post
  27. #  your concerns in the forum.
  28. #
  29. #------------------------------------------------------------------------------#
  30. #==============================================================================#
  31. # ** FEATURES
  32. #------------------------------------------------------------------------------#
  33. #
  34. #------------------------------------------------------------------------------#
  35. #==============================================================================#
  36. # ** RECOMMENDED
  37. #------------------------------------------------------------------------------#
  38. #
  39. # IRME - Icy Random Map Encounters
  40. #
  41. # YEM Keyboard Input (Has been merged with the current Yggdrasil Version)
  42. #
  43. #------------------------------------------------------------------------------#
  44. #==============================================================================#
  45. # ** CHANGE LOG
  46. #------------------------------------------------------------------------------#
  47. #
  48. # (MM/DD/YYYY)
  49. #  10/11/2010 - BETA  Started Script
  50. #  11/09/2010 - V1.0  Finished Script
  51. #  11/15/2010 - V1.1  A whole lot of stuff happened
  52. #                     Several bug fixes, new features (Too many to list)
  53. #  ??/??/???? - V1.2  Several Improvements and BugFixes
  54. #  12/17/2010 - V1.3  AI improvements, AI can now use skills
  55. #  02/19/2011 - V1.4  So many changes, I tottaly forgot,
  56. #                     Main things though, Targetting has been changed slightly
  57. #                     Some fixes (Which I don't remember) have been done.
  58. #  07/01/2011 - V1.59 Started Revamping entire code.
  59. #  10/14/2011 - V1.6  Finished 1.6
  60. #  11/30/2011 - V1.6a Fixed 3 bugs, added 5 new feature
  61. #                     Stats didn't change when equipment was changed.
  62. #                     Disabling the Shift System would cause an error.
  63. #                     Disabling the level up window would cause an error
  64. #                     Added pickup sounds:
  65. #                       <pksfx: filename, vol, pit>
  66. #                     Added popup enabling and disabling (For event comments)
  67. #                       <enable pop>
  68. #                       <disable pop> or <no pop>
  69. #                     Added Bar Hiding (For event comments)
  70. #                       <hide hp bar> ; <show hp bar>
  71. #                       <hide mp bar> ; <show mp bar>
  72. #                     Added changable attack animation for enemies:
  73. #                       <atk animation id: n>
  74. #                     Added extended drops for enemies:
  75. #                       <drop item n>
  76. #                       item_id: n
  77. #                       weapon_id: n
  78. #                       armor_id: n
  79. #                       prob: n
  80. #                       </drop item>
  81. #
  82. #------------------------------------------------------------------------------#
  83. #==============================================================================#
  84. # ** KNOWN ISSUES
  85. #------------------------------------------------------------------------------#
  86. #  Non at the moment.
  87. #
  88. #------------------------------------------------------------------------------#
  89. #==============================================================================#  
  90. # ** YGG
  91. #==============================================================================#
  92. module YGG
  93. #==============================================================================#
  94. #                           Start Customization
  95. #------------------------------------------------------------------------------#
  96. #==============================================================================#
  97.   #--------------------------------------------------------------------------#
  98.   # * ABS_SYSTEM_SWITCH
  99.   #--------------------------------------------------------------------------#
  100.   # This is the switch which controls Yggdrasil
  101.   # If you set this constant to nil, Yggdrasil will always be active.
  102.   #--------------------------------------------------------------------------#
  103.     ABS_SYSTEM_SWITCH = 2
  104.  
  105.   #--------------------------------------------------------------------------#
  106.   # * ITEM_MAP
  107.   #--------------------------------------------------------------------------#
  108.   # Currently this is not used for 1.6, but its still nice to have it
  109.   # just in case XD
  110.   #--------------------------------------------------------------------------#
  111.     ITEM_MAP = 2
  112.    
  113.   #--------------------------------------------------------------------------#
  114.   # * DEFAULT_ATK_ANIM
  115.   #--------------------------------------------------------------------------#
  116.   # This is the default animation, that will be used for attacks.
  117.   #--------------------------------------------------------------------------#  
  118.     DEFAULT_ATK_ANIM = 120
  119.    
  120.   #--------------------------------------------------------------------------#
  121.   # * DONT_SCAN_EVENTS
  122.   #--------------------------------------------------------------------------#
  123.   # Because events can either be allies or enemies, this tends to be a
  124.   # bit slow for each event, you can disable event scanning,
  125.   # so the events can only target the player.
  126.   #--------------------------------------------------------------------------#  
  127.     DONT_SCAN_EVENTS = true
  128.  
  129.   #--------------------------------------------------------------------------#
  130.   # * FULL_FIELD_SCAN
  131.   #--------------------------------------------------------------------------#
  132.   # *Warning this may cause Lag*
  133.   # Events will scan all around them for targets
  134.   # That means infront, behind, and beside
  135.   #--------------------------------------------------------------------------#  
  136.     FULL_FIELD_SCAN = true
  137.    
  138.   #--------------------------------------------------------------------------#
  139.   # * DIE_WAIT_TIME
  140.   #--------------------------------------------------------------------------#
  141.   # Time in frames for events to die.
  142.   # Default is 30
  143.   #--------------------------------------------------------------------------#  
  144.     DIE_WAIT_TIME = 30
  145.    
  146.   #--------------------------------------------------------------------------#
  147.   # * MAX_ATTACK_WAIT_TIME
  148.   #--------------------------------------------------------------------------#
  149.   # Time in frames for attack charges.
  150.   # Default is 40
  151.   #--------------------------------------------------------------------------#  
  152.     MAX_ATTACK_WAIT_TIME = 1200
  153.    
  154.   #--------------------------------------------------------------------------#
  155.   # * HIT_COUNT_DOWN
  156.   #--------------------------------------------------------------------------#
  157.   # When you attack, the hit count will increase.
  158.   # Each time you get a successful attack, the hit count down will reset
  159.   # Once it runs down, the hit count will return to 0
  160.   # By default this is not shown
  161.   #--------------------------------------------------------------------------#  
  162.     HIT_COUNT_DOWN = 120
  163.  
  164.   #--------------------------------------------------------------------------#
  165.   # * DRAW_RANGES
  166.   #--------------------------------------------------------------------------#
  167.   # Should the ranges for attacks/skills/etc be drawn?
  168.   #--------------------------------------------------------------------------#  
  169.     DRAW_RANGES = false
  170.    
  171.   #--------------------------------------------------------------------------#
  172.   # * ALL_DEAD_GAMEOVER
  173.   #--------------------------------------------------------------------------#
  174.   # >.> Quite Obviously you will set this to true..
  175.   # I don't even know why I made a constant for it anyway...
  176.   # When this is true, if all party members are dead, the Gameover will
  177.   # be triggered.
  178.   #--------------------------------------------------------------------------#  
  179.     ALL_DEAD_GAMEOVER = true  
  180.        
  181.   #--------------------------------------------------------------------------#
  182.   # * TARGETTING_EVENT_ID
  183.   #--------------------------------------------------------------------------#
  184.   # This is the event, used for Targetting mode, it is located on the Item
  185.   # Map
  186.   #--------------------------------------------------------------------------#  
  187.     TARGETTING_EVENT_ID = 1
  188.    
  189.   #--------------------------------------------------------------------------#
  190.   # * TOTAL_WILD_ANIMS
  191.   #--------------------------------------------------------------------------#
  192.   # In addition to each characters own animations, Yggdrasil has a wild anim
  193.   # set, where these animations are stand alone and can be triggered from
  194.   # anywhere on the map.
  195.   # Note greater numbers means more anims that can be shown at a time
  196.   # This will increase the number of updates and may result in Lagging.
  197.   # I reccomend keeping it around 8 to 16
  198.   #--------------------------------------------------------------------------#  
  199.     TOTAL_WILD_ANIMS = 16
  200.    
  201.   #--------------------------------------------------------------------------#
  202.   # * DEFAULT_ANIM_ANGLE
  203.   #--------------------------------------------------------------------------#
  204.   # This is an angle that will be added to a characters animations
  205.   # if using the Rotate Anim code.
  206.   # Currently the animations are set up to work with animations, pointing to the
  207.   # left
  208.   #--------------------------------------------------------------------------#  
  209.     DEFAULT_ANIM_ANGLE = 0
  210.  
  211.   #--------------------------------------------------------------------------#
  212.   # * STATE_TURN_COUNTER
  213.   #--------------------------------------------------------------------------#
  214.   # This is used for state turns, in other words how many frames make a turn
  215.   # Default is 240
  216.   #--------------------------------------------------------------------------#
  217.     STATE_TURN_COUNTER = 480 #240
  218.  
  219.   #--------------------------------------------------------------------------#
  220.   # * SLIP_DAMAGE_FREQUENCY
  221.   #--------------------------------------------------------------------------#
  222.   # How often should slip damage occur
  223.   #--------------------------------------------------------------------------#
  224.     SLIP_DAMAGE_FREQUENCY = 5
  225.    
  226.   #--------------------------------------------------------------------------#
  227.   # * ACTION_BUTTONS
  228.   #--------------------------------------------------------------------------#
  229.   # Yggdrasil 1x6 uses unlimited buttons instead of 3 ( 1.0..1.5 series )
  230.   #--------------------------------------------------------------------------#
  231.     # // Jump to (YGG_PlayerInputConfig)
  232.    
  233.   #--------------------------------------------------------------------------#
  234.   # * TEXT_POP
  235.   #--------------------------------------------------------------------------#
  236.   # As of 1.6 TEXT POP is now built into the main script.
  237.   # Ignore this section.
  238.   #--------------------------------------------------------------------------#  
  239.     USE_TEXT_POP = true
  240.     # Copied from BEM So you can recycle
  241.     POPUP_SETTINGS = {
  242.       :hp_dmg     => "%s",        # SprintF for HP damage.
  243.       :hp_heal    => "+%s",       # SprintF for HP healing.
  244.       :mp_dmg     => "%s SP",     # SprintF for MP damage.
  245.       :mp_heal    => "+%s SP",    # SprintF for MP healing.
  246.       :critical   => "CRITICAL!", # Text display for critical hit.
  247.       :missed     => "MISS",      # Text display for missed attack.
  248.       :evaded     => "EVADE!",    # Text display for evaded attack.
  249.       :nulled     => "NULLED",    # Text display for nulled attack.
  250.       :add_state  => "+%s",       # SprintF for added states.
  251.       :rem_state  => "-%s",       # SprintF for removed states.
  252.      
  253.       :exp_pop    => "Exp: %s",   # SprintF for Exp Pops.
  254.       :lvl_pop    => "Level %s"# SprintF for Level Pops.
  255.     } # Do Not Remove
  256.    
  257.   #--------------------------------------------------------------------------#
  258.   # * POPUP_RULES
  259.   #--------------------------------------------------------------------------#
  260.   # If you don't have IEX - Text Pop, Ignore this section
  261.   # Text Properties
  262.   # "Bold"      = Pop will be drawn Bold
  263.   # "Italic"    = Pop will be drawn with Italics
  264.   # "Shadow"    = Pop will be drawn with Shadows
  265.   # "No Bold"   = Pop will not be drawn Bold
  266.   # "No Italic" = Pop will not be drawn with Italics
  267.   # "No Shadow" = Pop will not be drawn with Shadow
  268.   #
  269.   # Font names is an array of font names (If the first one isn't present on
  270.   # the system, the next one is used, if non are present from the array
  271.   # the default is used)
  272.   #--------------------------------------------------------------------------#
  273.     COLOR_SETS = {#Ally                      Damage
  274.       :hp_no_dmg => [Color.new(180, 205, 180), Color.new(180, 205, 180)],
  275.       :hp_dmg    => [Color.new(128, 128, 240), Color.new(240, 128, 128)],
  276.       :hp_heal   => [Color.new(144, 238, 144), Color.new(198, 238, 144)],
  277.    
  278.       :mp_no_dmg => [Color.new(180, 180, 205), Color.new(180, 180, 205)],
  279.       :mp_dmg    => [Color.new(199, 21 , 112), Color.new(199, 21 , 112)],
  280.       :mp_heal   => [Color.new(173, 216, 230), Color.new(173, 216, 230)],
  281.     }
  282.    
  283.     POPUP_RULES = {
  284.     #                        
  285.    #"something"=> [fontsize, [color, color], [text_properties], [font_names]]
  286.       "HP_NO_DMG"=> [16, COLOR_SETS[:hp_no_dmg]  , [           ], [          ]],
  287.       "HP_DMG"   => [21, COLOR_SETS[:hp_dmg]     , [           ], [          ]],
  288.       "HP_HEAL"  => [21, COLOR_SETS[:hp_heal]    , ["Italic"   ], [          ]],
  289.    
  290.       "MP_NO_DMG"=> [16, COLOR_SETS[:mp_no_dmg]  , [           ], [          ]],
  291.       "MP_DMG"   => [21, COLOR_SETS[:mp_dmg]     , [           ], [          ]],
  292.       "MP_HEAL"  => [21, COLOR_SETS[:mp_heal]    , ["Italic"   ], [          ]],
  293.    
  294.       "MISSED"   => [19, Color.new(176, 196, 222), ["Italic"   ], [          ]],
  295.       "EVADED"   => [19, Color.new(198, 198, 198), ["Italic"   ], [          ]],
  296.       "NULLED"   => [19, Color.new(255, 160, 122), ["Bold"     ], [          ]],
  297.    
  298.       "ADD_STATE"=> [26, Color.new(255, 255, 224), ["No Shadow"], [          ]],
  299.       "REM_STATE"=> [26, Color.new(250, 250, 210), ["No Shadow"], [          ]],
  300.    
  301.       "EXP_POP"  => [18, Color.new(255, 215, 0  ), [           ], [          ]],
  302.       "LVL_POP"  => [21, Color.new(180, 215, 255), [           ], [          ]],
  303.    
  304.       "CRITICAL" => [24, Color.new(220, 20 , 60 ), ["Bold"     ], [          ]],
  305.     } # Do Not Remove
  306.    
  307.   #--------------------------------------------------------------------------#
  308.   # * CRITICAL_FONTSIZE_ADD
  309.   #--------------------------------------------------------------------------#
  310.   # When a critcial is done how much should be added to the Damage pop's
  311.   # font size
  312.   #--------------------------------------------------------------------------#
  313.     CRITICAL_FONTSIZE_ADD = 4
  314.    
  315.   #--------------------------------------------------------------------------#
  316.   # * SHOW_CRITICAL
  317.   #--------------------------------------------------------------------------#
  318.   # Should the "Critical" text be drawn when it is done?
  319.   #--------------------------------------------------------------------------#  
  320.     SHOW_CRITICAL = true
  321.  
  322.   #--------------------------------------------------------------------------#
  323.   # * LEVEL_UP_ALERT
  324.   #--------------------------------------------------------------------------#
  325.   # Should something happen on level up?
  326.   #--------------------------------------------------------------------------#
  327.     LEVEL_UP_ALERT = false
  328.    
  329.   #--------------------------------------------------------------------------#
  330.   # * ANIM_ON_LEVEL
  331.   #--------------------------------------------------------------------------#
  332.   # Animation used for level up. If set to 0, no anim is played
  333.   # This is disabled if LEVEL_UP_ALERT = false
  334.   #--------------------------------------------------------------------------#  
  335.     ANIM_ON_LEVEL = 0 # 257
  336.    
  337.   #--------------------------------------------------------------------------#
  338.   # * POP_LEVEL_UP
  339.   #--------------------------------------------------------------------------#
  340.   # Should a text pop with Level Up be used?
  341.   # This is disabled if LEVEL_UP_ALERT = false
  342.   #--------------------------------------------------------------------------#  
  343.     POP_LEVEL_UP = false
  344.  
  345.   #--------------------------------------------------------------------------#
  346.   # * POP_EXP
  347.   #--------------------------------------------------------------------------#
  348.   # Should a text pop be used for EXP?
  349.   #--------------------------------------------------------------------------#  
  350.     POP_EXP = true
  351.  
  352.   #--------------------------------------------------------------------------#
  353.   # * EXP_GAINING_METHOD
  354.   #--------------------------------------------------------------------------#
  355.   # 0 Dead   - When the target is defeated the character gains EXP
  356.   # 1 Per Hit- On every successful hit, exp is gained
  357.   #--------------------------------------------------------------------------#  
  358.     EXP_GAINING_METHOD = 0
  359.    
  360.   #--------------------------------------------------------------------------#
  361.   # * EXP_PER_HIT_FORMULA
  362.   #--------------------------------------------------------------------------#
  363.   # If you have no idea about scripting, don't touch this.
  364.   #--------------------------------------------------------------------------#  
  365.     EXP_PER_HIT_FORMULA = Proc.new { |damage, atker, defer| defer.exp * damage / defer.maxhp}
  366.    
  367.   #--------------------------------------------------------------------------#
  368.   # * EXP_SAHRE_METHOD
  369.   #--------------------------------------------------------------------------#
  370.   # 0 Active Member Only - Only the active member gains EXP
  371.   # 1 All Members Equal  - All members gain EXP
  372.   # 2 All Members Split  - The EXP is split amongst all Members
  373.   #--------------------------------------------------------------------------#  
  374.     # 0 Only Active Member, 1 All Members Equal, 2 All Members Spilt
  375.     EXP_SAHRE_METHOD = 1
  376.  
  377.   #--------------------------------------------------------------------------#
  378.   # * GOLD_DROP_ICON
  379.   #--------------------------------------------------------------------------#
  380.   # This is the icon that is used for gold drops
  381.   #--------------------------------------------------------------------------#
  382.     GOLD_DROP_ICON = 147
  383.    
  384.   #--------------------------------------------------------------------------#
  385.   # * DROP_SCATTER_DISTANCE
  386.   #--------------------------------------------------------------------------#
  387.   # This is how far a drop can be placed from its origin
  388.   #--------------------------------------------------------------------------#    
  389.     DROP_SCATTER_DISTANCE = 3
  390.    
  391.   #--------------------------------------------------------------------------#
  392.   # * ITEM_FADE_TIME
  393.   #--------------------------------------------------------------------------#
  394.   # How long, in frames until an item drop fades out
  395.   #--------------------------------------------------------------------------#    
  396.     ITEM_FADE_TIME = 480
  397.    
  398.   #--------------------------------------------------------------------------#
  399.   # * GOLD_FADE_TIME
  400.   #--------------------------------------------------------------------------#
  401.   # How long, in frames until an gold drop fades out
  402.   #--------------------------------------------------------------------------#    
  403.     GOLD_FADE_TIME = 640
  404.    
  405.   #--------------------------------------------------------------------------#
  406.   # * DROP_FADE_THRESHOLD
  407.   #--------------------------------------------------------------------------#
  408.   # When this frame is reached the drop will begin to fade out
  409.   #--------------------------------------------------------------------------#  
  410.     DROP_FADE_THRESHOLD = 60
  411.   #--------------------------------------------------------------------------#
  412.   # * USE_SHIFT_SYSTEM (YGG_ShiftSystem)
  413.   #--------------------------------------------------------------------------#
  414.   # Unlike its predecessors, 1.6 has a built-in Shift System
  415.   # This simply allows the quick changing between characters
  416.   #--------------------------------------------------------------------------#
  417.     USE_SHIFT_SYSTEM = false
  418.  
  419.   #--------------------------------------------------------------------------#
  420.   # * HUD
  421.   #--------------------------------------------------------------------------#
  422.   # Options for HUD
  423.   #--------------------------------------------------------------------------#
  424.     USE_HUD = true
  425.     HUD_SWITCH = 1
  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.     ["SET GUARD"    , []                              ]
  495.   ]
  496.  
  497.   ACTION_LIST["ESCAPE_ACTION"] = [
  498.   ]
  499.  
  500.   ACTION_LIST["WAIT_ACTION"] = [
  501.     ["PARENT WAIT"  , [20]                            ]
  502.   ]
  503.  
  504. # oo========================================================================oo #    
  505. # // Normal Attack # For Enemies  
  506.   ACTION_LIST["NULL_ACTION_EN"] = [] # // Unused D:
  507.  
  508.   ACTION_LIST["NORMAL_ATTACK_EN"] = [
  509.     ["RANGE"        , ["ADD", 0, 1]                   ],
  510.     ["TARGET"       , ["RANGE"]                       ],
  511.     ["SUBTARGET"    , ["ALLIES"]                      ],
  512.     ["ANIMATION"    , ["ATTACK", "POS", "WILD", 0, 1] ],
  513.     ["ATTACK EFFECT", ["USER", "TARGETS"]             ]
  514.   ]
  515.  
  516.   ACTION_LIST["GUARD_ACTION_EN"] = [
  517.     ["SET GUARD"    , []                              ]
  518.   ]
  519.  
  520.   ACTION_LIST["ESCAPE_ACTION_EN"] = [
  521.   ]
  522.  
  523.   ACTION_LIST["WAIT_ACTION_EN"] = [
  524.     ["PARENT WAIT"  , [20]                            ]
  525.   ]
  526. # oo========================================================================oo #    
  527. # // Skill Scopes                                                           // #
  528.   # // None Scope Skill
  529.   ACTION_LIST["NORMAL_OBJ0"] = [
  530.     ["TARGET"      , ["USER"]                      ],
  531.     ["ANIMATION"   , ["OBJ", "POS", "WILD", 0, 0]  ],
  532.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  533.   ]
  534.  
  535.   # // User Skill
  536.   ACTION_LIST["NORMAL_OBJ1"] = [
  537.     ["TARGET"      , ["USER"]                      ],
  538.     ["ANIMATION"   , ["OBJ", "POS", "WILD", 0, 0]  ],
  539.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  540.   ]
  541.  
  542.   # // Enemy Skill Single
  543.   ACTION_LIST["NORMAL_OBJ2_1"] = [
  544.     ["RANGE"       , ["ADD", 0, 1]                 ],
  545.     ["TARGET"      , ["RANGE"]                     ],
  546.     ["SUBTARGET"   , ["ALLIES"]                    ],
  547.     ["ANIMATION"   , ["OBJ", "POS", "WILD", 0, 1]  ],
  548.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  549.   ]
  550.  
  551.   # // Enemy Skill Dual
  552.   ACTION_LIST["NORMAL_OBJ2_2"] = [
  553.     ["RANGE"       , ["ADD", 0, 1]                 ],
  554.     ["TARGET"      , ["RANGE"]                     ],
  555.     ["SUBTARGET"   , ["ALLIES"]                    ],
  556.     ["ANIMATION"   , ["OBJ", "POS", "WILD", 0, 1]  ],
  557.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  558.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  559.   ]
  560.  
  561.   # // Enemy Skill Triple
  562.   ACTION_LIST["NORMAL_OBJ2_3"] = [
  563.     ["RANGE"       , ["ADD", 0, 1]                 ],
  564.     ["TARGET"      , ["RANGE"]                     ],
  565.     ["SUBTARGET"   , ["ALLIES"]                    ],
  566.     ["ANIMATION"   , ["OBJ", "POS", "WILD", 0, 1]  ],
  567.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  568.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  569.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  570.   ]
  571.  
  572.   # // Enemy Skill Random 1
  573.   ACTION_LIST["NORMAL_OBJ2_R1"] = [
  574.     ["TARGET"      , ["SCREEN"]                    ],
  575.     ["SUBTARGET"   , ["ALLIES"]                    ],
  576.     ["TARGET"      , ["RANDTARGET"]                ],
  577.     ["ANIMATION"   , ["OBJ", "TARGET", "WILD"]     ],
  578.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  579.   ]
  580.  
  581.   # // Enemy Skill Random 2
  582.   ACTION_LIST["NORMAL_OBJ2_R2"] = [
  583.     ["ACTION", ["NORMAL_OBJ2_R1"] ],
  584.     ["ACTION", ["NORMAL_OBJ2_R1"] ]
  585.   ]
  586.  
  587.   # // Enemy Skill Random 3
  588.   ACTION_LIST["NORMAL_OBJ2_R3"] = [
  589.     ["ACTION", ["NORMAL_OBJ2_R1"] ],
  590.     ["ACTION", ["NORMAL_OBJ2_R1"] ],
  591.     ["ACTION", ["NORMAL_OBJ2_R1"] ]
  592.   ]
  593.  
  594.   # // Ally Skill
  595.   ACTION_LIST["NORMAL_OBJ3_1"] = [
  596.     ["RANGE"       , ["ADD", 0, 1]                 ],
  597.     ["TARGET"      , ["RANGE"]                     ],
  598.     ["SUBTARGET"   , ["ENEMIES"]                   ],
  599.     ["ANIMATION"   , ["OBJ", "POS", "WILD", 0, 1]  ],
  600.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  601.   ]
  602.  
  603.   # // Ally Skill Dual
  604.   ACTION_LIST["NORMAL_OBJ3_2"] = [
  605.     ["RANGE"       , ["ADD", 0, 1]                 ],
  606.     ["TARGET"      , ["RANGE"]                     ],
  607.     ["SUBTARGET"   , ["ENEMIES"]                   ],
  608.     ["ANIMATION"   , ["OBJ", "POS", "WILD", 0, 1]  ],
  609.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  610.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  611.   ]
  612.  
  613.   # // Ally Skill Triple
  614.   ACTION_LIST["NORMAL_OBJ3_3"] = [
  615.     ["RANGE"       , ["ADD", 0, 1]                 ],
  616.     ["TARGET"      , ["RANGE"]                     ],
  617.     ["SUBTARGET"   , ["ENEMIES"]                   ],
  618.     ["ANIMATION"   , ["OBJ", "POS", "WILD", 0, 1]  ],
  619.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  620.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  621.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  622.   ]
  623.  
  624.   # // Ally Skill Random 1
  625.   ACTION_LIST["NORMAL_OBJ3_R1"] = [
  626.     ["TARGET"      , ["SCREEN"]                    ],
  627.     ["SUBTARGET"   , ["ENEMIES"]                   ],
  628.     ["TARGET"      , ["RANDTARGET"]                ],
  629.     ["ANIMATION"   , ["OBJ", "TARGET", "WILD"]     ],
  630.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  631.   ]
  632.  
  633.   # // Ally Obj Random 2
  634.   ACTION_LIST["NORMAL_OBJ3_R2"] = [
  635.     ["ACTION", ["NORMAL_OBJ3_R1"] ],
  636.     ["ACTION", ["NORMAL_OBJ3_R1"] ],
  637.   ]
  638.  
  639.   # // Enemy Obj Random 3
  640.   ACTION_LIST["NORMAL_OBJ3_R3"] = [
  641.     ["ACTION", ["NORMAL_OBJ3_R1"] ],
  642.     ["ACTION", ["NORMAL_OBJ3_R1"] ],
  643.     ["ACTION", ["NORMAL_OBJ3_R1"] ],
  644.   ]
  645.  
  646.   # // All Enemies
  647.   ACTION_LIST["NORMAL_OBJ4"] = [
  648.     ["TARGET"      , ["SCREEN"]                    ],
  649.     ["SUBTARGET"   , ["ALLIES"]                    ],
  650.     ["ANIMATION"   , ["OBJ", "TARGETS", "WILD"]    ],
  651.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  652.   ]
  653.  
  654.   # // All Allies
  655.   ACTION_LIST["NORMAL_OBJ5"] = [
  656.     ["TARGET"      , ["SCREEN"]                    ],
  657.     ["SUBTARGET"   , ["ENEMIES"]                   ],
  658.     ["ANIMATION"   , ["OBJ", "TARGETS", "WILD"]    ],
  659.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  660.   ]
  661.  
  662.   # // Target Enemy Skill Single
  663.   ACTION_LIST["NORMAL_OBJ2_T1"] = [
  664.     ["TARGET"      , ["SCREEN"]                    ],
  665.     ["SUBTARGET"   , ["ALLIES"]                    ],
  666.     ["TARGET SELECT",[1, "TARGETS"]                ],
  667.     ["ANIMATION"   , ["OBJ", "TARGETS", "WILD"]    ],
  668.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  669.   ]
  670.  
  671.   # // Target Enemy Skill Dual
  672.   ACTION_LIST["NORMAL_OBJ2_T2"] = [
  673.     ["TARGET"      , ["SCREEN"]                    ],
  674.     ["SUBTARGET"   , ["ALLIES"]                    ],
  675.     ["TARGET SELECT",[1, "TARGETS"]                ],
  676.     ["ANIMATION"   , ["OBJ", "TARGETS", "WILD"]    ],
  677.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  678.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  679.   ]
  680.  
  681.   # // Target Enemy Skill Triple
  682.   ACTION_LIST["NORMAL_OBJ2_T3"] = [
  683.     ["TARGET"      , ["SCREEN"]                    ],
  684.     ["SUBTARGET"   , ["ALLIES"]                    ],
  685.     ["TARGET SELECT",[1, "TARGETS"]                ],
  686.     ["ANIMATION"   , ["OBJ", "TARGETS", "WILD"]    ],
  687.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  688.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  689.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  690.   ]
  691.  
  692.   # // Target Ally Skill
  693.   ACTION_LIST["NORMAL_OBJ3_T1"] = [
  694.     ["TARGET"      , ["SCREEN"]                    ],
  695.     ["SUBTARGET"   , ["ENEMIES"]                   ],
  696.     ["TARGET SELECT",[1, "TARGETS"]                ],
  697.     ["ANIMATION"   , ["OBJ", "TARGETS", "WILD"]    ],
  698.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  699.   ]
  700.  
  701.   # // Target Ally Skill Dual
  702.   ACTION_LIST["NORMAL_OBJ3_T2"] = [
  703.     ["TARGET"      , ["SCREEN"]                    ],
  704.     ["SUBTARGET"   , ["ENEMIES"]                   ],
  705.     ["TARGET SELECT",[1, "TARGETS"]                ],
  706.     ["ANIMATION"   , ["OBJ", "TARGETS", "WILD"]    ],
  707.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  708.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  709.   ]
  710.  
  711.   # // Target Ally Skill Triple
  712.   ACTION_LIST["NORMAL_OBJ3_T3"] = [
  713.     ["TARGET"      , ["SCREEN"]                    ],
  714.     ["SUBTARGET"   , ["ENEMIES"]                   ],
  715.     ["TARGET SELECT",[1, "TARGETS"]                ],
  716.     ["ANIMATION"   , ["OBJ", "TARGETS", "WILD"]    ],
  717.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  718.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ],
  719.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ]
  720.   ]
  721.  
  722.   # // Breath all targets in range
  723.   ACTION_LIST["BREATH_ATTACK1"] = [
  724.     ["RANGE"       , ["CREATE", 3, 0, 3, 2]        ], # // Point Range downward
  725.     ["TARGET"      , ["RANGE"]                     ], # // Get all targets within range
  726.     ["ANIMATION"   , ["OBJ", "POS", 0, 1]          ], # // Show animation infront
  727.     ["OBJ EFFECT"  , ["USER", "TARGETS"]           ], # // Object Damage
  728.   ]
  729.  
  730. # oo========================================================================oo #    
  731. # \\ End Default Actions //                                                 // #
  732. # oo========================================================================oo #
  733. #==============================================================================#
  734. #                           End Customization
  735. #------------------------------------------------------------------------------#
  736. #==============================================================================#  
  737. end
  738. #==============================================================================#
  739. # ** YGG # // Forward Declarations
  740. #==============================================================================#
  741. module YGG
  742. #==============================================================================#
  743. # ** Handlers
  744. #==============================================================================#
  745.   module Handlers   ; end
  746. #==============================================================================#
  747. # ** Containers
  748. #==============================================================================#    
  749.   module Containers ; end
  750. #==============================================================================#
  751. # ** MixIns
  752. #==============================================================================#    
  753.   module MixIns     ; end
  754. #==============================================================================#
  755. # ** Objects
  756. #==============================================================================#        
  757.   module Objects    ; end      
  758. #==============================================================================#
  759. # ** Scenes
  760. #==============================================================================#            
  761.   module Scenes     ; end  
  762. #==============================================================================#
  763. # ** Sprites
  764. #==============================================================================#        
  765.   module Sprites    ; end  
  766. #==============================================================================#
  767. # ** REGEXP
  768. #==============================================================================#            
  769.   module REGEXP     ; end
  770. #==============================================================================#
  771. # ** Windows
  772. #==============================================================================#                
  773.   module Windows    ; end  
  774. #==============================================================================#
  775. # ** Pos
  776. #==============================================================================#                
  777.   class Pos ; end
  778. #==============================================================================#
  779. # ** Handlers::Screen
  780. #==============================================================================#    
  781.   class Handlers::Screen < Pos ; end
  782. #==============================================================================#
  783. # ** Objects::Projectiles
  784. #==============================================================================#      
  785.   module Objects::Projectiles ; end
  786. end    
  787.  
  788. #==============================================================================#  
  789. # ** Input # // DONT MESS WITH THIS
  790. #==============================================================================#
  791. module Input
  792.   #--------------------------------------------------------------------------#
  793.   # * Constants - Created by OriginalWij and Yanfly
  794.   #--------------------------------------------------------------------------#
  795.   LETTERS = {}        
  796.   LETTERS['A'] = 65; LETTERS['B'] = 66; LETTERS['C'] = 67; LETTERS['D'] = 68
  797.   LETTERS['E'] = 69; LETTERS['F'] = 70; LETTERS['G'] = 71; LETTERS['H'] = 72
  798.   LETTERS['I'] = 73; LETTERS['J'] = 74; LETTERS['K'] = 75; LETTERS['L'] = 76
  799.   LETTERS['M'] = 77; LETTERS['N'] = 78; LETTERS['O'] = 79; LETTERS['P'] = 80
  800.   LETTERS['Q'] = 81; LETTERS['R'] = 82; LETTERS['S'] = 83; LETTERS['T'] = 84
  801.   LETTERS['U'] = 85; LETTERS['V'] = 86; LETTERS['W'] = 87; LETTERS['X'] = 88
  802.   LETTERS['Y'] = 89; LETTERS['Z'] = 90
  803.   NUMBERS = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57]
  804.   NUMPAD = [96, 97, 98, 99, 100, 101, 102, 103, 104, 105]
  805.   BACK   = 138; ENTER  = 143; SPACE  = 32;  SCOLON = 186; ESC    = 157
  806.   QUOTE  = 222; EQUALS = 187; COMMA  = 188; USCORE = 189; PERIOD = 190
  807.   SLASH  = 191; LBRACE = 219; RBRACE = 221; BSLASH = 220; TILDE  = 192
  808.   F10    = 121; F11    = 122; CAPS   = 20;  NMUL   = 106; NPLUS  = 107
  809.   NSEP   = 108; NMINUS = 109; NDECI  = 110; NDIV   = 111; Extras =
  810.   [USCORE, EQUALS, LBRACE, RBRACE, BSLASH, SCOLON, QUOTE, COMMA, PERIOD, SLASH,
  811.    NMUL, NPLUS, NSEP, NMINUS, NDECI, NDIV]
  812. end
  813.  
  814. #==============================================================================#
  815. # ** YGG::MixIns::Player (YGG_PlayerInputConfig)
  816. #==============================================================================#
  817. module YGG::MixIns::Player
  818.  
  819.   #--------------------------------------------------------------------------#
  820.   # * new-method :get_obj_actions
  821.   #--------------------------------------------------------------------------#  
  822.   def get_obj_actions( obj, id )
  823.     return [],[] if obj.nil?()
  824.     return obj.ygg_actions[id].to_a(), obj.ygg_pre_actions[id].to_a()
  825.   end
  826.  
  827.   #--------------------------------------------------------------------------#
  828.   # * new-method :ygg_attack_input
  829.   #--------------------------------------------------------------------------#
  830.   def ygg_attack_input()
  831.     #return unless ygg_can_attack?()
  832.     return if $game_map.interpreter.running?()
  833.     return if ygg_battler.nil?()
  834.     return if @action_handle.busy?()
  835.     acthand_ret = ygg_attack_input1()              # // ASD Input
  836.     acthand_ret = ygg_attack_input2( acthand_ret ) # // Skill Input 1..5
  837.     ygg_attack_input3( acthand_ret )               # // Item Input 6..9 and 0
  838.   end
  839.  
  840.   #--------------------------------------------------------------------------#
  841.   # * new-method :ygg_attack_input1
  842.   #--------------------------------------------------------------------------#
  843.   def ygg_attack_input1()
  844.     act, pact = nil, nil
  845.     obj = nil
  846.     if Input.trigger?( Input::LETTERS["A"] )
  847.       return 0 unless ygg_battler.ygg_can_attack?()
  848.       obj = ygg_battler.weapons[0]
  849.       act, pact = *get_obj_actions( obj, 1 )
  850.     elsif Input.trigger?( Input::LETTERS["S"] ) && ygg_battler.two_swords_style  
  851.       return 0 unless ygg_battler.ygg_can_attack?()
  852.       obj = ygg_battler.weapons[1]
  853.       act, pact = *get_obj_actions( obj, 1 )
  854.     elsif Input.trigger?( Input::LETTERS["D"] ) && !ygg_battler.two_swords_style  
  855.       return 0 unless ygg_battler.ygg_can_attack?()
  856.       obj = ygg_battler.armors[0]
  857.       act, pact = *get_obj_actions( obj, 1 )
  858.     end  
  859.     return 0 if act.nil?() || pact.nil?()
  860.     return 0 if act.empty?() && pact.empty?()
  861.     if pact.empty?()
  862.       @action_handle.setup( act )
  863.     else  
  864.       @action_handle.list_stack << act
  865.       @action_handle.setup( pact )
  866.     end  
  867.     @action_handle.execute( self )
  868.     ygg_battler.cooldown += obj.user_charge_cap
  869.     return 1
  870.   end
  871.  
  872.   #--------------------------------------------------------------------------#
  873.   # * new-method :ygg_attack_input2
  874.   #--------------------------------------------------------------------------#
  875.   def ygg_attack_input2( acthand_ret )
  876.     for i in 1..5
  877.       act, pact, obj = nil, nil, nil
  878.       if Input.trigger?( Input::NUMBERS[i] )
  879.         slot_id = i-1
  880.         obj = ygg_battler.skill_slot( slot_id )
  881.         next unless ygg_battler.ygg_skill_can_use?( obj )
  882.         act, pact = *get_obj_actions( obj, 0 )
  883.       end
  884.       next if act.nil?() || pact.nil?() || obj.nil?()
  885.       next if act.empty?() && pact.empty?()
  886.       next unless skill_can_use?( obj )
  887.       if pact.empty?()
  888.         hnd = ::YGG::Handlers::Action.new( self, [] ) ; hnd.setup( act )
  889.         hnd.execute( self, [], { :skill_id => obj.id } )
  890.         @free_act_handles << hnd
  891.       else  
  892.         next if acthand_ret == 1
  893.         @action_handle.list_stack << act
  894.         @action_handle.setup( pact )
  895.         @action_handle.execute( self, [], { :skill_id => obj.id } )
  896.         acthand_ret = 1
  897.       end  
  898.       ygg_battler.get_skill_handle( obj.id ).reset_time()
  899.       ygg_battler.cooldown += obj.user_charge_cap
  900.       ygg_battler.ygg_use_skill( obj )
  901.     end  
  902.     return acthand_ret
  903.   end
  904.  
  905.   #--------------------------------------------------------------------------#
  906.   # * new-method :ygg_attack_input3
  907.   #--------------------------------------------------------------------------#
  908.   def ygg_attack_input3( acthand_ret )
  909.     for i in (6..9).to_a+[0]
  910.       act, pact, obj = nil, nil, nil
  911.       if Input.trigger?( Input::NUMBERS[i] )
  912.         slot_id = i==0 ? 10-6 : i-6
  913.         obj = ygg_battler.item_slot( slot_id )
  914.         next unless ygg_battler.ygg_item_can_use?( obj )
  915.         act, pact = *get_obj_actions( obj, 0 )
  916.       end
  917.       next if act.nil?() || pact.nil?() || obj.nil?()
  918.       next if act.empty?() && pact.empty?()
  919.       next unless item_can_use?( obj )
  920.       if pact.empty?()
  921.         hnd = ::YGG::Handlers::Action.new( self, [] ) ; hnd.setup( act )
  922.         hnd.execute( self, [], { :item_id => obj.id } )
  923.         @free_act_handles << hnd
  924.       else  
  925.         next if acthand_ret == 1
  926.         @action_handle.list_stack << act
  927.         @action_handle.setup( pact )
  928.         @action_handle.execute( self, [], { :item_id => obj.id } )
  929.         acthand_ret = 1
  930.       end  
  931.       ygg_battler.get_item_handle( obj.id ).reset_time()
  932.       ygg_battler.cooldown += obj.user_charge_cap
  933.       ygg_battler.ygg_use_item( obj )
  934.     end  
  935.     return acthand_ret
  936.   end
  937.  
  938.   #--------------------------------------------------------------------------#
  939.   # * new-method :skill_can_use?
  940.   #--------------------------------------------------------------------------#  
  941.   def skill_can_use?( obj )
  942.     return false if obj.nil?()
  943.     return false if ygg_battler.nil?()
  944.     return ygg_battler.skill_can_use?( obj )
  945.   end
  946.  
  947.   #--------------------------------------------------------------------------#
  948.   # * new-method :item_can_use?
  949.   #--------------------------------------------------------------------------#  
  950.   def item_can_use?( obj )
  951.     return false if obj.nil?()
  952.     return false if ygg_battler.nil?()
  953.     return $game_party.item_can_use?( obj )
  954.   end
  955.  
  956. end  
  957.  
  958. # // (YGG_AIEngine_Setup)
  959. #==============================================================================#
  960. # ** YGG::Handlers::AIEngines
  961. #==============================================================================#
  962. module YGG::Handlers::AIEngines
  963. #==============================================================================#
  964. # ** Base (Forward Declaration)
  965. #==============================================================================#  
  966.   class Base           ; end
  967. #==============================================================================#
  968. # ** Default (Forward Declaration)
  969. #==============================================================================#      
  970.   class Default < Base ; end
  971. #==============================================================================#
  972. # ** Guard (Forward Declaration)
  973. #==============================================================================#      
  974.   class Guard < Base   ; end
  975. #==============================================================================#
  976. # ** Wall (Forward Declaration)
  977. #==============================================================================#      
  978.   class Wall < Base    ; end  
  979. #==============================================================================#
  980. # ** ImmortalVarBoss (Forward Declaration)
  981. #==============================================================================#          
  982.   class ImmortalVarBoss < Base  ; end
  983.    
  984.   #--------------------------------------------------------------------------#
  985.   # * ENGINES
  986.   #--------------------------------------------------------------------------#
  987.   # This hash contains references to the Engine's Class, NOT AN INSTANCE
  988.   # of the class.
  989.   #--------------------------------------------------------------------------#  
  990.   ENGINES = {
  991.     # // Default AI that uses the Game_Battler's make_action
  992.     # // to attack
  993.     "default" => Default,         # // Default (Make Action) AI
  994.     # // An AI that only attacks/moves/acts when an enemy enters its field
  995.     "guard"   => Guard,           # // Specialized AI
  996.     # // An AI that does nothing, but its HP slowly depletes
  997.     "wall"    => Wall,            
  998.     # // An invincible boss, thats hp is controlled by a variable
  999.     # // This is a 2nd level subclass
  1000.     "ivboss"  => ImmortalVarBoss,
  1001.   }
  1002.  
  1003. end
  1004.  
  1005. #==============================================================================#
  1006. # ** YGG::AI_ENGINES
  1007. #==============================================================================#
  1008. YGG::AI_ENGINES = YGG::Handlers::AIEngines::ENGINES
  1009.  
  1010. #==============================================================================#
  1011. # ** YGG::Handlers::AIEngines::Base
  1012. #==============================================================================#
  1013. class YGG::Handlers::AIEngines::Base
  1014.  
  1015.   #--------------------------------------------------------------------------#
  1016.   # * Public Instance Variables
  1017.   #--------------------------------------------------------------------------#  
  1018.   attr_accessor :parent
  1019.  
  1020.   #--------------------------------------------------------------------------#
  1021.   # * new-method :initialize
  1022.   #--------------------------------------------------------------------------#  
  1023.   def initialize( parent, setup_data={} )
  1024.     @parent = parent
  1025.     @update_time = 0
  1026.   end
  1027.  
  1028.   #--------------------------------------------------------------------------#
  1029.   # * new-method :pause
  1030.   #--------------------------------------------------------------------------#  
  1031.   def pause()
  1032.     @paused = true
  1033.   end
  1034.  
  1035.   #--------------------------------------------------------------------------#
  1036.   # * new-method :unpause
  1037.   #--------------------------------------------------------------------------#  
  1038.   def unpause()
  1039.     @paused = false
  1040.   end
  1041.  
  1042.   #--------------------------------------------------------------------------#
  1043.   # * new-method :update
  1044.   #--------------------------------------------------------------------------#  
  1045.   def update()
  1046.     return if @paused
  1047.     @update_time = [@update_time - 1, 0].max
  1048.     ai_update() if @update_time == 0
  1049.   end
  1050.  
  1051. end  
  1052.  
  1053. #==============================================================================#
  1054. # ** YGG::Handlers::AIEngines::Default
  1055. #==============================================================================#
  1056. class YGG::Handlers::AIEngines::Default
  1057.  
  1058.   #--------------------------------------------------------------------------#
  1059.   # * super-method :initialize
  1060.   #--------------------------------------------------------------------------#
  1061.   def initialize( parent, setup_data={} )
  1062.     super( parent, setup_data )
  1063.     @update_time_cap = (setup_data["update_time"] || 90).to_i
  1064.   end
  1065.  
  1066.   #--------------------------------------------------------------------------#
  1067.   # * new-method :ai_update
  1068.   #--------------------------------------------------------------------------#  
  1069.   def ai_update()
  1070.     #return # // Remove this later
  1071.     return if @parent.ygg_battler.cooldown > 0
  1072.     return if @parent.ygg_battler.nil?()  
  1073.     @parent.ygg_battler.make_action()
  1074.     case @parent.ygg_battler.action.kind
  1075.     when 0 # // Basic
  1076.       case @parent.ygg_battler.action.basic
  1077.       when 0 # // Attack      
  1078.         @update_time = @update_time_cap / 3
  1079.         t = @parent.get_targets_nearby( 1, @parent.ygg_correct_target( "ENEMY" ) )
  1080.         return @update_time = @update_time_cap / 4 if t[0].nil?()
  1081.         @parent.turn_to_coord( t[0].x, t[0].y )
  1082.         @parent.action_handle.setup( @parent.ygg_battler.get_action_by_id( 0 ) )
  1083.         @parent.action_handle.execute( @parent )
  1084.       when 1 # // Guard
  1085.         @parent.action_handle.setup( @parent.ygg_battler.get_action_by_id( 1 ) )
  1086.         @parent.action_handle.execute( @parent )
  1087.       when 2 # // Escape
  1088.         @parent.action_handle.setup( @parent.ygg_battler.get_action_by_id( 2 ) )
  1089.         @parent.action_handle.execute( @parent )
  1090.       when 3 # // Wait  
  1091.         @parent.action_handle.setup( @parent.ygg_battler.get_action_by_id( 3 ) )
  1092.         @parent.action_handle.execute( @parent )
  1093.       end  
  1094.     when 1 # // Skill
  1095.       obj = $data_skills[@parent.ygg_battler.action.skill_id]
  1096.       next unless @parent.ygg_battler.ygg_skill_can_use?( obj )
  1097.       if obj.for_opponent?()
  1098.         t = @parent.get_targets_nearby( 1, @parent.ygg_correct_target( "ENEMY" ) )
  1099.       elsif obj.for_friend?()  
  1100.         t = @parent.get_targets_nearby( 1, @parent.ygg_correct_target( "ALLY" ) )
  1101.       else  
  1102.         t = @parent.get_targets_nearby( 1, "ALL" )
  1103.       end  
  1104.       return @update_time = @update_time_cap / 4 if t[0].nil?()
  1105.       @parent.ygg_battler.ygg_use_skill( obj )
  1106.       @parent.turn_to_coord( t[0].x, t[0].y )
  1107.       @parent.action_handle.setup( obj.ygg_actions[0] )
  1108.       @parent.action_handle.execute( @parent, [],
  1109.         { :skill_id=> @parent.ygg_battler.action.skill_id } )
  1110.     when 2 # // Item Enemies cant use items
  1111.     end  
  1112.     @update_time = @update_time_cap
  1113.   end
  1114.  
  1115. end  
  1116.  
  1117. #==============================================================================#
  1118. # ** YGG::Handlers::AIEngines::Guard
  1119. #==============================================================================#
  1120. class YGG::Handlers::AIEngines::Guard
  1121.  
  1122.   #--------------------------------------------------------------------------#
  1123.   # * super-method :initialize
  1124.   #--------------------------------------------------------------------------#  
  1125.   def initialize( parent, setup_data={} )
  1126.     sd = setup_data
  1127.     super( parent, sd )
  1128.     setup_area( sd )
  1129.     @update_time_cap = (sd["update_time"] || 90).to_i
  1130.     @__temprect = []
  1131.   end
  1132.  
  1133.   #--------------------------------------------------------------------------#
  1134.   # * new-method :setup_area
  1135.   #--------------------------------------------------------------------------#  
  1136.   def setup_area( setup_data={} )
  1137.     # // area_id (id)
  1138.     @prox = setup_data["proxy_area"].to_i == 1
  1139.     if !setup_data["area_id"].nil?()
  1140.       @guard_area = Rect.new( *$data_areas[setup_data["area_id"].to_i].rect.to_a )
  1141.     # // area_x (center), area_y (center), area_range (center, relative side)
  1142.     elsif !setup_data["area_range"].nil?()
  1143.       ax  = (!setup_data["area_x"].nil?()) ? setup_data["area_x"].to_i : 0
  1144.       ay  = (!setup_data["area_y"].nil?()) ? setup_data["area_y"].to_i : 0
  1145.       rng = (!setup_data["area_range"].nil?()) ? setup_data["area_range"].to_i : 0
  1146.       @guard_area = Rect.new( ax-rng, ay-rng, rng*2, rng*2 )
  1147.     # // area_x (left), area_y (left), area_width (left), area_height (left)    
  1148.     else  
  1149.       @guard_area = Rect.new(
  1150.         (!setup_data["area_x"].nil?()) ? setup_data["area_x"].to_i : 0,
  1151.         (!setup_data["area_y"].nil?()) ? setup_data["area_y"].to_i : 0,
  1152.         (!setup_data["area_width"].nil?()) ? setup_data["area_width"].to_i : 0,
  1153.         (!setup_data["area_height"].nil?()) ? setup_data["area_height"].to_i : 0
  1154.       )
  1155.     end
  1156.     @__guardarea_data ||= {} ; @__guardarea_data.clear()
  1157.     @__guardarea_data["proxy_area"]  = setup_data["proxy_area"]
  1158.     @__guardarea_data["area_id"]     = setup_data["area_id"]
  1159.     @__guardarea_data["area_range"]  = setup_data["area_range"]
  1160.     @__guardarea_data["area_x"]      = setup_data["area_x"]
  1161.     @__guardarea_data["area_y"]      = setup_data["area_y"]
  1162.     @__guardarea_data["area_width"]  = setup_data["area_width"]
  1163.     @__guardarea_data["area_height"] = setup_data["area_height"]
  1164.   end
  1165.  
  1166.   #--------------------------------------------------------------------------#
  1167.   # * new-method :reset_area
  1168.   #--------------------------------------------------------------------------#  
  1169.   def reset_area()
  1170.     setup_area( @__guardarea_data )
  1171.   end
  1172.  
  1173.   #--------------------------------------------------------------------------#
  1174.   # * new-method :ai_update
  1175.   #--------------------------------------------------------------------------#  
  1176.   def ai_update()
  1177.     return if @parent.ygg_battler.nil?()
  1178.     @__temprect = @guard_area.to_vector4_a()
  1179.     @__temprect[0] += @prox ? @parent.x : 0
  1180.     @__temprect[1] += @prox ? @parent.y : 0
  1181.     @__temprect[2] += @prox ? @parent.x : 0
  1182.     @__temprect[3] += @prox ? @parent.y : 0
  1183.     bats = $game_yggdrasil.battlers_range( *@__temprect )  
  1184.     unless bats.empty?()
  1185.       bats -= [@parent]
  1186.       unless bats.empty?()
  1187.         @parent.balloon_id = 1
  1188.         pro = Projectiles::Homing.new( @parent,
  1189.           ::YGG::PROJETILE_SETUP["ProjectileTest"].merge(
  1190.             { :target => bats[rand(bats.size)] } )
  1191.         )    
  1192.         pro.moveto( @parent.x, @parent.y ) ; pro.set_direction( @parent.direction )
  1193.         $game_yggdrasil.add_projectile( pro )
  1194.       end  
  1195.     end  
  1196.     @update_time = @update_time_cap
  1197.   end
  1198.  
  1199. end  
  1200.  
  1201. #==============================================================================#
  1202. # ** YGG::Handlers::AIEngines::Wall
  1203. #==============================================================================#
  1204. class YGG::Handlers::AIEngines::Wall
  1205.  
  1206.   #--------------------------------------------------------------------------#
  1207.   # * super-method :initialize
  1208.   #--------------------------------------------------------------------------#
  1209.   def initialize( parent, setup_data={} )
  1210.     super( parent, setup_data )
  1211.     @burn_time = @burn_cap = setup_data["burn_cap"].to_i
  1212.     @death_anim = (setup_data["death_anim"] || 0).to_i
  1213.   end
  1214.  
  1215.   #--------------------------------------------------------------------------#
  1216.   # * overwrite-method :ai_update
  1217.   #--------------------------------------------------------------------------#
  1218.   def ai_update()
  1219.     return if @parent.ygg_battler.nil?()
  1220.     @burn_time = [@burn_time - 1, 0].max
  1221.     @parent.ygg_battler.hp -= [Integer(@parent.ygg_battler.maxhp / @burn_cap.to_f), 1].max + [@burn_time, 0].min.abs
  1222.     @parent.ygg_engage.engage( 300 )
  1223.     if @parent.ygg_battler.dead?()
  1224.       @parent.ygg_anims << @death_anim if @death_anim > 0
  1225.       $game_map.remove_event( @parent.id )
  1226.     end  
  1227.   end
  1228.  
  1229. end  
  1230.  
  1231. #==============================================================================#
  1232. # ** YGG::Handlers::AIEngines::Wall
  1233. #==============================================================================#
  1234. class YGG::Handlers::AIEngines::ImmortalVarBoss
  1235.  
  1236.   #--------------------------------------------------------------------------#
  1237.   # * super-method :initialize
  1238.   #--------------------------------------------------------------------------#  
  1239.   def initialize( parent, setup_data )
  1240.     super( parent, setup_data )
  1241.     @hp_var    = setup_data["hp_var"].to_i
  1242.     @maxhp_var = setup_data["maxhp_var"].to_i
  1243.     @mp_var    = setup_data["mp_var"].nil?() ? nil : setup_data["mp_var"].to_i
  1244.     @maxmp_var = setup_data["maxmp_var"].nil?() ? nil : setup_data["maxmp_var"].to_i
  1245.     @parent.ygg_invincible = true
  1246.     set_variables()
  1247.   end
  1248.  
  1249.   #--------------------------------------------------------------------------#
  1250.   # * new-method :set_variables
  1251.   #--------------------------------------------------------------------------#  
  1252.   def set_variables()
  1253.     return if @parent.ygg_battler.nil?()
  1254.     $game_variables[@hp_var] = @parent.ygg_battler.hp
  1255.     $game_variables[@maxhp_var] = @parent.ygg_battler.maxhp
  1256.     $game_variables[@mp_var] = @parent.ygg_battler.mp unless @mp_var.nil?()
  1257.     $game_variables[@maxmp_var] = @parent.ygg_battler.maxmp unless @maxmp_var.nil?()
  1258.   end
  1259.  
  1260.   #--------------------------------------------------------------------------#
  1261.   # * overwrite-method :ai_update
  1262.   #--------------------------------------------------------------------------#  
  1263.   def ai_update()
  1264.     return if @parent.ygg_battler.nil?()
  1265.     @parent.ygg_battler.hp = $game_variables[@hp_var]
  1266.     $game_variables[@maxhp_var] = @parent.ygg_battler.maxhp
  1267.     $game_variables[@mp_var] = @parent.ygg_battler.mp unless @mp_var.nil?()
  1268.     $game_variables[@maxmp_var] = @parent.ygg_battler.maxmp unless @maxmp_var.nil?()
  1269.   end
  1270.  
  1271. end  
  1272.  
  1273. # // (YGG_Projectiles)
  1274. Projectiles = YGG::Objects::Projectiles
  1275. #==============================================================================#
  1276. # ** YGG::Objects::Projectiles::Base
  1277. #==============================================================================#
  1278. class YGG::Objects::Projectiles::Base < ::Game_Character
  1279.  
  1280.   #--------------------------------------------------------------------------#
  1281.   # * Public Instance Variables
  1282.   #--------------------------------------------------------------------------#  
  1283.   attr_accessor :character_name
  1284.   attr_accessor :character_index
  1285.  
  1286.   attr_accessor :through
  1287.   attr_accessor :action_name
  1288.   attr_accessor :direction
  1289.   attr_accessor :detonate_cap
  1290.   attr_accessor :move_cap
  1291.   attr_accessor :target_type
  1292.  
  1293.   attr_accessor :registered
  1294.   attr_accessor :action
  1295.  
  1296.   #--------------------------------------------------------------------------#
  1297.   # * new-method :initialize
  1298.   #--------------------------------------------------------------------------#  
  1299.   def initialize( parent, assignments )
  1300.     @parent          = parent
  1301.     super()
  1302.     # // Main Properties
  1303.     @character_name  = ""
  1304.     @character_index = 0
  1305.     @through         = true
  1306.     @move_speed      = 5
  1307.    
  1308.     # // Projectile Properties
  1309.     @detonate_cap    = -1
  1310.     @move_cap        = 5
  1311.     @target_type     = ""
  1312.    
  1313.     @terminated      = false
  1314.     @detonate_count  = 0
  1315.     @move_count      = 0
  1316.    
  1317.     @action_name     = ""
  1318.     @action          = nil
  1319.    
  1320.     @registered      = false
  1321.    
  1322.     assignments.keys.each { |key| self.send( key.to_s+"=", assignments[key] ) }
  1323.     @action ||= ::YGG.get_action_list( @action_name )
  1324.   end
  1325.  
  1326.   #--------------------------------------------------------------------------#
  1327.   # * new-method :hp_visible?
  1328.   #--------------------------------------------------------------------------#
  1329.   def hp_visible?() ; return false ; end
  1330.    
  1331.   #--------------------------------------------------------------------------#
  1332.   # * new-method :mp_visible?
  1333.   #--------------------------------------------------------------------------#
  1334.   def mp_visible?() ; return false ; end
  1335.  
  1336.   #--------------------------------------------------------------------------#
  1337.   # * new-method :registered?
  1338.   #--------------------------------------------------------------------------#
  1339.   def registered?()
  1340.     return @registered
  1341.   end
  1342.  
  1343.   #--------------------------------------------------------------------------#
  1344.   # * new-method :ygg_register
  1345.   #--------------------------------------------------------------------------#
  1346.   def ygg_register()
  1347.     @ygg_registered = true
  1348.   end  
  1349.  
  1350.   #--------------------------------------------------------------------------#
  1351.   # * new-method :ygg_unregister
  1352.   #--------------------------------------------------------------------------#
  1353.   def ygg_unregister()
  1354.     $game_yggdrasil.remove_battler( self )
  1355.     @ygg_registered = false
  1356.   end
  1357.  
  1358.   #--------------------------------------------------------------------------#
  1359.   # * new-method :ygg_attacker
  1360.   #--------------------------------------------------------------------------#  
  1361.   def ygg_attacker()
  1362.     return @parent.ygg_attacker
  1363.   end
  1364.  
  1365.   #--------------------------------------------------------------------------#
  1366.   # * new-method :ygg_boss
  1367.   #--------------------------------------------------------------------------#  
  1368.   def ygg_boss?() ; return false ; end
  1369.  
  1370.   #--------------------------------------------------------------------------#
  1371.   # * new-method :ygg_ally?
  1372.   #--------------------------------------------------------------------------#  
  1373.   def ygg_ally?()
  1374.     return @parent.ygg_ally?()
  1375.   end
  1376.  
  1377.   #--------------------------------------------------------------------------#
  1378.   # * new-method :ygg_enemy?
  1379.   #--------------------------------------------------------------------------#  
  1380.   def ygg_enemy?()
  1381.     return @parent.ygg_enemy?()
  1382.   end
  1383.  
  1384.   #--------------------------------------------------------------------------#
  1385.   # * new-method :passable?
  1386.   #--------------------------------------------------------------------------#  
  1387.   def passable?( x, y )
  1388.     x = $game_map.round_x(x)                        
  1389.     y = $game_map.round_y(y)                        
  1390.     return false unless $game_map.valid?(x, y)      
  1391.     return true if @through or debug_through?      
  1392.     return false unless map_passable?( x, y )          
  1393.     return true                                    
  1394.   end
  1395.  
  1396.   #--------------------------------------------------------------------------#
  1397.   # * overwrite-method :check_event_trigger_touch
  1398.   #--------------------------------------------------------------------------#  
  1399.   def check_event_trigger_touch( *args, &block ) ; end
  1400.  
  1401.   #--------------------------------------------------------------------------#
  1402.   # * super-method :update
  1403.   #--------------------------------------------------------------------------#  
  1404.   def update()
  1405.     update_projectile() unless @wait_count > 0
  1406.     super()
  1407.   end
  1408.  
  1409.   #--------------------------------------------------------------------------#
  1410.   # * overwrite-method :update_states
  1411.   #--------------------------------------------------------------------------#  
  1412.   def update_states() ; end
  1413.  
  1414.   #--------------------------------------------------------------------------#
  1415.   # * overwrite-method :move_speed
  1416.   #--------------------------------------------------------------------------#  
  1417.   def move_speed() ; return @move_speed ; end
  1418.    
  1419.   #--------------------------------------------------------------------------#
  1420.   # * new-method :update_projectile
  1421.   #--------------------------------------------------------------------------#  
  1422.   def update_projectile()
  1423.     process_move() if can_move?()
  1424.     process_detonate() if can_detonate?()
  1425.     process_terminate() if can_terminate?()
  1426.   end
  1427.  
  1428.   #--------------------------------------------------------------------------#
  1429.   # * new-method :actual_*x/y
  1430.   #--------------------------------------------------------------------------#  
  1431.   def actual_x() ; return @real_x / 256 ; end
  1432.   def actual_y() ; return @real_y / 256 ; end
  1433.  
  1434.   #--------------------------------------------------------------------------#
  1435.   # * new-method :pos?
  1436.   #--------------------------------------------------------------------------#  
  1437.   def pos?( x, y )  
  1438.     return (actual_x == x && actual_y == y)
  1439.   end
  1440.  
  1441.   #--------------------------------------------------------------------------#
  1442.   # * new-method :target_xy?
  1443.   #--------------------------------------------------------------------------#  
  1444.   def target_xy?( x, y )
  1445.     return !ygg_get_targets( x, y, ygg_correct_target( @target_type ), true ).empty?()
  1446.   end
  1447.  
  1448.   #--------------------------------------------------------------------------#
  1449.   # * new-method :terminated?
  1450.   #--------------------------------------------------------------------------#  
  1451.   def terminated?()
  1452.     return @terminated
  1453.   end
  1454.  
  1455.   #--------------------------------------------------------------------------#
  1456.   # * new-method :can_move?
  1457.   #--------------------------------------------------------------------------#  
  1458.   def can_move?()
  1459.     return false if self.terminated?()
  1460.     return false if jumping?()
  1461.     return false if moving?()
  1462.     return false if (@move_cap > 0 && @move_count >= @move_cap)
  1463.     return true
  1464.   end
  1465.  
  1466.   #--------------------------------------------------------------------------#
  1467.   # * new-method :can_detonate?
  1468.   #--------------------------------------------------------------------------#  
  1469.   def can_detonate?()
  1470.     return false if self.terminated?()
  1471.     return false if (@detonate_cap > 0 && @detonate_count >= @detonate_cap)
  1472.     return target_xy?( self.actual_x, self.actual_y )
  1473.   end
  1474.  
  1475.   #--------------------------------------------------------------------------#
  1476.   # * new-method :can_terminate?
  1477.   #--------------------------------------------------------------------------#  
  1478.   def can_terminate?()
  1479.     return false if self.terminated?()
  1480.     return true if (@detonate_cap > 0 && @detonate_count >= @detonate_cap )
  1481.     return (@move_cap > 0 && @move_count >= @move_cap && !moving?())  
  1482.   end
  1483.  
  1484.   #--------------------------------------------------------------------------#
  1485.   # * new-method :process_move
  1486.   #--------------------------------------------------------------------------#  
  1487.   def process_move()
  1488.     @move_count += 1
  1489.   end
  1490.  
  1491.   #--------------------------------------------------------------------------#
  1492.   # * new-method :process_detonate
  1493.   #--------------------------------------------------------------------------#  
  1494.   def process_detonate()
  1495.     @detonate_count += 1
  1496.     @action_handle.setup( @action )
  1497.     @action_handle.execute( self )
  1498.   end
  1499.  
  1500.   #--------------------------------------------------------------------------#
  1501.   # * new-method :process_terminate
  1502.   #--------------------------------------------------------------------------#  
  1503.   def process_terminate()
  1504.     @terminated = true ; ygg_unregister()
  1505.   end
  1506.  
  1507.   #--------------------------------------------------------------------------#
  1508.   # * new-method :force_terminate
  1509.   #--------------------------------------------------------------------------#  
  1510.   def force_terminate()
  1511.     @terminated = true
  1512.   end
  1513.  
  1514. end
  1515.  
  1516. #==============================================================================#
  1517. # ** YGG::Objects::Projectiles::Linear
  1518. #==============================================================================#
  1519. class YGG::Objects::Projectiles::Linear < ::YGG::Objects::Projectiles::Base
  1520.  
  1521.   #--------------------------------------------------------------------------#
  1522.   # * super-method :initialize
  1523.   #--------------------------------------------------------------------------#  
  1524.   def initialize( parent, assignments )
  1525.     super( parent, assignments )
  1526.   end
  1527.  
  1528.   #--------------------------------------------------------------------------#
  1529.   # * super-method :process_move
  1530.   #--------------------------------------------------------------------------#  
  1531.   def process_move()
  1532.     move_forward()
  1533.     super()
  1534.   end
  1535.  
  1536. end
  1537.  
  1538. #==============================================================================#
  1539. # ** YGG::Objects::Projectiles::Hopping
  1540. #==============================================================================#
  1541. class YGG::Objects::Projectiles::Hopping < ::YGG::Objects::Projectiles::Base
  1542.  
  1543.   #--------------------------------------------------------------------------#
  1544.   # * Public Instance Variables
  1545.   #--------------------------------------------------------------------------#
  1546.   attr_accessor :jump_amount
  1547.  
  1548.   #--------------------------------------------------------------------------#
  1549.   # * super-method :initialize
  1550.   #--------------------------------------------------------------------------#  
  1551.   def initialize( parent, assignments )
  1552.     @jump_amount = 1
  1553.     super( parent, assignments )
  1554.   end
  1555.  
  1556.   #--------------------------------------------------------------------------#
  1557.   # * super-method :process_move
  1558.   #--------------------------------------------------------------------------#  
  1559.   def process_move()
  1560.     jump_forward( @jump_amount, 0 )
  1561.     super()
  1562.   end
  1563.  
  1564. end
  1565.  
  1566. #==============================================================================#
  1567. # ** YGG::Objects::Projectiles::Homing
  1568. #==============================================================================#
  1569. class YGG::Objects::Projectiles::Homing < ::YGG::Objects::Projectiles::Base
  1570.  
  1571.   #--------------------------------------------------------------------------#
  1572.   # * Public Instance Variables
  1573.   #--------------------------------------------------------------------------#
  1574.   attr_accessor :target
  1575.   attr_accessor :homing_range
  1576.  
  1577.   #--------------------------------------------------------------------------#
  1578.   # * super-method :initialize
  1579.   #--------------------------------------------------------------------------#  
  1580.   def initialize( parent, assignments )
  1581.     @homing_range = 5
  1582.     super( parent, assignments )
  1583.     set_target() if @target.nil?()
  1584.   end
  1585.  
  1586.   #--------------------------------------------------------------------------#
  1587.   # * new-method :target_xy?
  1588.   #--------------------------------------------------------------------------#  
  1589.   def target_xy?( x, y )
  1590.     self.pos?( @target.x, @target.y )
  1591.   end
  1592.  
  1593.   #--------------------------------------------------------------------------#
  1594.   # * new-method :set_target
  1595.   #--------------------------------------------------------------------------#  
  1596.   def set_target()
  1597.     @target = get_targets_nearby( @homing_range, ygg_correct_target( @target_type ) )[0]
  1598.   end
  1599.  
  1600.   #--------------------------------------------------------------------------#
  1601.   # * new-method :target_oor? # // target_out_of_range?
  1602.   #--------------------------------------------------------------------------#  
  1603.   def target_oor?()
  1604.     return @homing_range == -1 ? false : (@target.distance_from( self ) > @homing_range)
  1605.   end
  1606.  
  1607.   #--------------------------------------------------------------------------#
  1608.   # * super-method :process_move
  1609.   #--------------------------------------------------------------------------#  
  1610.   def process_move()
  1611.     move_toward_char( @target )
  1612.     super()
  1613.   end
  1614.  
  1615.   #--------------------------------------------------------------------------#
  1616.   # * super-method :can_terminate?
  1617.   #--------------------------------------------------------------------------#
  1618.   def can_terminate?()
  1619.     return true if target_oor?()
  1620.     super()
  1621.   end
  1622.    
  1623. end
  1624.  
  1625. #==============================================================================#
  1626. # ** YGG::Objects::Projectiles::Bomb
  1627. #==============================================================================#
  1628. class YGG::Objects::Projectiles::Bomb < ::YGG::Objects::Projectiles::Base
  1629.  
  1630.   #--------------------------------------------------------------------------#
  1631.   # * Public Instance Variables
  1632.   #--------------------------------------------------------------------------#  
  1633.   attr_accessor :time
  1634.  
  1635.   #--------------------------------------------------------------------------#
  1636.   # * super-method :initialize
  1637.   #--------------------------------------------------------------------------#  
  1638.   def initialize( parent, assignments )
  1639.     @time = 60
  1640.     super( parent, assignments )
  1641.   end
  1642.  
  1643.   #--------------------------------------------------------------------------#
  1644.   # * overwrite-method :target_xy?
  1645.   #--------------------------------------------------------------------------#  
  1646.   def target_xy?( x, y )
  1647.     return true
  1648.   end
  1649.  
  1650.   #--------------------------------------------------------------------------#
  1651.   # * super-method :update_projectile
  1652.   #--------------------------------------------------------------------------#  
  1653.   def update_projectile()
  1654.     @time = [@time-1, 0].max
  1655.     super()
  1656.   end
  1657.  
  1658.   #--------------------------------------------------------------------------#
  1659.   # * super-method :can_detonate?
  1660.   #--------------------------------------------------------------------------#  
  1661.   def can_detonate?()
  1662.     return false unless super()
  1663.     return true if @time == 0
  1664.     return false
  1665.   end
  1666.  
  1667. end
  1668.  
  1669. #==============================================================================#
  1670. # ** YGG::Objects::Projectiles::GhostBullet
  1671. #==============================================================================#
  1672. class YGG::Objects::Projectiles::GhostBullet < ::YGG::Objects::Projectiles::Base
  1673.  
  1674.   #--------------------------------------------------------------------------#
  1675.   # * super-method :initialize
  1676.   #--------------------------------------------------------------------------#  
  1677.   def initialize( parent, assignments )
  1678.     super( parent, assignments )
  1679.   end
  1680.  
  1681. end
  1682.  
  1683. #==============================================================================#
  1684. # ** YGG::Objects::Projectiles::ActionPilot
  1685. #==============================================================================#
  1686. class YGG::Objects::Projectiles::ActionPilot < ::YGG::Objects::Projectiles::Base
  1687.  
  1688.   #--------------------------------------------------------------------------#
  1689.   # * Public Instance Variables
  1690.   #--------------------------------------------------------------------------#  
  1691.   attr_accessor :pilot_list
  1692.  
  1693.   #--------------------------------------------------------------------------#
  1694.   # * super-method :update_projectile
  1695.   #--------------------------------------------------------------------------#  
  1696.   def initialize( parent, assignments )
  1697.     @pilot_list = []
  1698.     super( parent, assignments )
  1699.   end
  1700.  
  1701.   #--------------------------------------------------------------------------#
  1702.   # * new-method :update_projectile
  1703.   #--------------------------------------------------------------------------#  
  1704.   def update_projectile()
  1705.     @sleep_count = [@sleep_count - 1, 0].max
  1706.     return unless @sleep_count == 0
  1707.     while !@pilot_list.empty?()
  1708.       act_set = @pilot_list.shift()
  1709.       @action     = act_set[0]
  1710.       @parameters = act_set[1]
  1711.       for i in 0...@parameters.size() ; @parameters[i] = @parameters[i].to_s() ; end
  1712.       act_result = -1
  1713.       case @action.upcase()
  1714.       when "MOVE"
  1715.         act_result = pilot_move( @action, @parameters )
  1716.       when "DETONATE"  
  1717.         act_result = pilot_detonate( @action, @parameters )
  1718.       when "TERMINATE"  
  1719.         act_result = pilot_terminate( @action, @parameters )
  1720.       when "SEND"  
  1721.         act_result = pilot_send( @action, @parameters )
  1722.       when "SLEEP"  
  1723.         act_result = pilot_sleep( @action, @parameters )
  1724.       when "SCRIPT"  
  1725.         act_result = pilot_script( @action, @parameters )
  1726.       when "WAIT"  
  1727.         act_result = pilot_wait( @action, @parameters )
  1728.       end
  1729.       if act_result == -1
  1730.         puts "ERROR: -1 returned for pilot action #{self}"
  1731.       else
  1732.         puts "BING: #{act_result} returned for pilot action #{self}"
  1733.       end if YGG.debug_mode?
  1734.       break if act_result == 1
  1735.     end  
  1736.     return
  1737.   end
  1738.  
  1739.   #--------------------------------------------------------------------------#
  1740.   # * new-method :pilot_move
  1741.   #--------------------------------------------------------------------------#  
  1742.   def pilot_move( action, parameters )
  1743.     character = self
  1744.     case parameters[0].upcase
  1745.     when "FORWARD"
  1746.       character.move_forward()
  1747.     when "BACKWARD"
  1748.       character.move_backward()  
  1749.     when "UP"
  1750.       character.move_up()
  1751.     when "DOWN"
  1752.       character.move_down()
  1753.     when "LEFT"
  1754.       character.move_left()
  1755.     when "RIGHT"
  1756.       character.move_right()
  1757.     when "TURNUP", "TURN_UP", "TURN UP"
  1758.       character.turn_up()
  1759.     when "TURNDOWN", "TURN_DOWN", "TURN DOWN"
  1760.       character.turn_down()
  1761.     when "TURNLEFT", "TURN_LEFT", "TURN LEFT"
  1762.       character.turn_left()
  1763.     when "TURNRIGHT", "TURN_RIGHT", "TURN RIGHT"
  1764.       character.turn_right()
  1765.     when "TURNRIGHT90", "TURN_RIGHT_90", "TURN RIGHT 90"
  1766.       character.turn_right_90()
  1767.     when "TURNLEFT90", "TURN_LEFT_90", "TURN LEFT 90"
  1768.       character.turn_left_90()  
  1769.     when "TURN180", "TURN_180", "TURN 180"
  1770.       character.turn_180()
  1771.     when "TURNTO", "TURN_TO", "TURN TO"
  1772.       target = nil
  1773.       character.turn_to_coord( target.x, target.y ) unless target.nil?()
  1774.     end
  1775.     return 0
  1776.   end
  1777.  
  1778.   #--------------------------------------------------------------------------#
  1779.   # * new-method :pilot_send
  1780.   #--------------------------------------------------------------------------#  
  1781.   def pilot_send( action, parameters )
  1782.     case parameters[0]
  1783.     when "ONLY"
  1784.       self.send( parameters[1] )
  1785.     when "SET"  
  1786.       self.send( parameters[1], *parameters.slice( 2, parameters.size ) )
  1787.     end  
  1788.     return 0
  1789.   end
  1790.  
  1791.   #--------------------------------------------------------------------------#
  1792.   # * new-method :pilot_detonate
  1793.   #--------------------------------------------------------------------------#  
  1794.   def pilot_detonate( action, parameters )
  1795.     process_detonate()
  1796.     return 0
  1797.   end
  1798.  
  1799.   #--------------------------------------------------------------------------#
  1800.   # * new-method :pilot_terminate
  1801.   #--------------------------------------------------------------------------#  
  1802.   def pilot_terminate( action, parameters )
  1803.     process_terminate()
  1804.     return 0
  1805.   end
  1806.  
  1807.   #--------------------------------------------------------------------------#
  1808.   # * new-method :pilot_terminate
  1809.   #--------------------------------------------------------------------------#  
  1810.   def pilot_script( action, parameters )
  1811.     eval( parameters.to_s )
  1812.     return 0
  1813.   end
  1814.  
  1815.   #--------------------------------------------------------------------------#
  1816.   # * new-method :pilot_sleep
  1817.   #--------------------------------------------------------------------------#  
  1818.   def pilot_sleep( action, parameters )
  1819.     @sleep_count = parameters[0].to_i
  1820.     return 1
  1821.   end
  1822.  
  1823.   #--------------------------------------------------------------------------#
  1824.   # * new-method :pilot_wait
  1825.   #--------------------------------------------------------------------------#  
  1826.   def pilot_wait( action, parameters )
  1827.     @wait_count = parameters[0].to_i
  1828.     return 0
  1829.   end
  1830.  
  1831. end  
  1832.  
  1833. #==============================================================================#
  1834. # ** YGG
  1835. #==============================================================================#
  1836. module YGG
  1837.  
  1838.   PROJECTILE_MAP = {
  1839.     "linear"  => YGG::Objects::Projectiles::Linear,
  1840.     "hopping" => YGG::Objects::Projectiles::Hopping,
  1841.     "homing"  => YGG::Objects::Projectiles::Homing,
  1842.     "bomb"    => YGG::Objects::Projectiles::Bomb,
  1843.     "ghost"   => YGG::Objects::Projectiles::GhostBullet,
  1844.     "action"  => YGG::Objects::Projectiles::ActionPilot,
  1845.   }  
  1846.  
  1847.   PROJETILE_SETUP = {}
  1848.  
  1849. end
  1850.  
  1851. #==============================================================================#
  1852. # ** YGG::Handlers::Equip
  1853. #==============================================================================#
  1854. class YGG::Handlers::Equip < YGG::Pos
  1855.  
  1856.   #--------------------------------------------------------------------------#
  1857.   # * Class Method(s)
  1858.   #--------------------------------------------------------------------------#
  1859.  
  1860.   #--------------------------------------------------------------------------#
  1861.   # * new-method :angle_change_list
  1862.   #--------------------------------------------------------------------------#
  1863.   def self.angle_change_list( start, add_target, wait, maxspeed=1, shorten=0 )
  1864.     result = []
  1865.     target = start + add_target
  1866.     rate = add_target.to_f / wait.to_f ; accel = 0
  1867.     ang = start
  1868.     (wait-shorten).times { |i|
  1869.       accel = maxspeed.to_f * i.to_f / wait.to_f
  1870.       if ang < target
  1871.         ang += rate.abs
  1872.         ang += accel ; ang = [ang, target].min
  1873.       elsif ang > target
  1874.         ang -= rate.abs
  1875.         ang -= accel ; ang = [ang, target].max
  1876.       else ; ang = target  
  1877.       end  
  1878.       result += [["CHANGE ANGLE", (ang)%360], ["WAIT", 1]]
  1879.     }  
  1880.     return result
  1881.   end
  1882.  
  1883.   #--------------------------------------------------------------------------#
  1884.   # * new-method :move_to_list
  1885.   #--------------------------------------------------------------------------#
  1886.   def self.move_to_list( start, add_target, wait, axis, maxspeed=1, shorten=0 )
  1887.     result = []
  1888.     target = start + add_target
  1889.     rate = add_target.to_f / wait.to_f ; accel = 0
  1890.     pos = start
  1891.     (wait-shorten).times { |i|
  1892.       accel = maxspeed.to_f * i.to_f / wait.to_f
  1893.       if pos < target
  1894.         pos += rate.abs
  1895.         pos += accel ; pos = [pos, target].min
  1896.       elsif pos > target
  1897.         pos -= rate.abs
  1898.         pos -= accel ; pos = [pos, target].max
  1899.       else ; pos = target  
  1900.       end  
  1901.       result += [["MOVE", axis.upcase, pos], ["WAIT", 1]]
  1902.     }  
  1903.     return result
  1904.   end
  1905.  
  1906.   #--------------------------------------------------------------------------#
  1907.   # * new-method :alternate_mix
  1908.   #--------------------------------------------------------------------------#  
  1909.   def self.alternate_mix( *args )
  1910.     aresult = [] ; sizes = args.inject([]) { |result, array| result << array.size }
  1911.     sizes.max.times { |i| args.each { |array| aresult << array[i] unless array[i].nil?() } }
  1912.     return aresult
  1913.   end
  1914.  
  1915.   #--------------------------------------------------------------------------#
  1916.   # * Constant(s)
  1917.   #--------------------------------------------------------------------------#
  1918.   ACTIONS = {}
  1919.   # // Swing
  1920.   t  = 0
  1921.   at = 78
  1922.   ACTIONS["Swing1"]  = [["RESET"], ["SHOW"]]
  1923.   ACTIONS["Swing1"] += angle_change_list( t, at, 12 )
  1924.   ACTIONS["Swing1"] += [["HIDE"]]
  1925.   # // Swing + Return Swing
  1926.   ACTIONS["Swing2"]  = [["RESET"], ["SHOW"]]
  1927.   ACTIONS["Swing2"] += angle_change_list( t, at, 11, 24, 2 )
  1928.   ACTIONS["Swing2"] += angle_change_list( t+at, t-at, 11, 24, 2 )
  1929.   ACTIONS["Swing2"] += [["HIDE"]]
  1930.   # // Swing + Pull
  1931.   ACTIONS["Swing3"]  = [["RESET"], ["SHOW"]]
  1932.   ACTIONS["Swing3"] += angle_change_list( t, at, 11, 24, 2 )
  1933.   ACTIONS["Swing3"] += move_to_list( 0, -14, 8, "Y" )
  1934.   ACTIONS["Swing3"] += [["HIDE"]]
  1935.  
  1936.   # // Stab
  1937.   ACTIONS["Stab1"]   = [["RESET"], ["SHOW"]]
  1938.   ACTIONS["Stab1"]  += [["CHANGE ANGLE", 40]]
  1939.   ACTIONS["Stab1"]  += [["MOVE", "X", -5]]
  1940.   ACTIONS["Stab1"]  += move_to_list( 0,  -4, 5, "Y" )
  1941.   ACTIONS["Stab1"]  += move_to_list( -4, 8, 8, "Y" )
  1942.   ACTIONS["Stab1"]  += [["HIDE"]]
  1943.  
  1944. end  
  1945.  
  1946. #==============================================================================#
  1947. ($imported ||= {})["Yggdrasil_1x6_ABS"] = true
  1948. #==============================================================================#
  1949. # ** YGG
  1950. #==============================================================================#
  1951. module YGG    
  1952.  
  1953.   module_function()
  1954.  
  1955.   #--------------------------------------------------------------------------#
  1956.   # * new-method :silent_error?
  1957.   #--------------------------------------------------------------------------#  
  1958.   def silent_error?() ; return false ; end
  1959.   def debug_mode?()   ; return false ; end
  1960.    
  1961.   #--------------------------------------------------------------------------#
  1962.   # * new-method :get_action_list
  1963.   #--------------------------------------------------------------------------#
  1964.   def get_action_list( action_name )
  1965.     unless YGG::ACTION_LIST.has_key?( action_name )  
  1966.       return [] if silent_error?() # // Silent Error
  1967.       raise "Action List #{action_name} does not exist"
  1968.       exit
  1969.     end  
  1970.     return ACTION_LIST[action_name]
  1971.   end
  1972.  
  1973.   # // User Functions  
  1974.  
  1975.   #--------------------------------------------------------------------------#
  1976.   # * new-method :create_range_data
  1977.   #--------------------------------------------------------------------------#
  1978.   # If the range was done before, it is simply reloaded
  1979.   # rng    - Maximum Range
  1980.   # minrng - Minimum Range
  1981.   # type:
  1982.   #   0 - Diamond   < >
  1983.   #   1 - Cross      +
  1984.   #   2 - X          x
  1985.   #   3 - Breath     <
  1986.   #   4 - SnowFlake  *
  1987.   #   5 - Block     [ ]
  1988.   #   6 - Linear    ->
  1989.   # direction:
  1990.   #   2 - Down
  1991.   #   4 - Left
  1992.   #   6 - Right
  1993.   #   8 - Up
  1994.   #--------------------------------------------------------------------------#
  1995.   def create_range_data( rng, minrng=0, type=0, direction=2 )  
  1996.     return Handlers::Range.createRange( rng, minrng, type, direction )
  1997.   end
  1998.  
  1999.   #--------------------------------------------------------------------------#
  2000.   # * new-method :offset_xy_list
  2001.   #--------------------------------------------------------------------------#  
  2002.   def offset_xy_list( ox, oy, xy_list, direction=2 )
  2003.     return xy_list.inject([]) { |result, coords|
  2004.       result.push( offset_xy( ox, oy, coords, direction ) ) }
  2005.   end
  2006.  
  2007.   #--------------------------------------------------------------------------#
  2008.   # * new-method :offset_xy
  2009.   #--------------------------------------------------------------------------#  
  2010.   def offset_xy( ox, oy, coords, direction=2 )
  2011.     result = []
  2012.     case direction
  2013.     when 2
  2014.       result = [ ox + coords[0], oy + coords[1] ]
  2015.     when 4
  2016.       result = [ ox - coords[1], oy - coords[0] ]
  2017.     when 6
  2018.       result = [ ox + coords[1], oy + coords[0] ]
  2019.     when 8
  2020.       result = [ ox - coords[0], oy - coords[1] ]
  2021.     end
  2022.     return result
  2023.   end
  2024.  
  2025.   #--------------------------------------------------------------------------#
  2026.   # * new-method :parse_event_list
  2027.   #--------------------------------------------------------------------------#  
  2028.   def parse_event_list( list )
  2029.     return list
  2030.     # // Skip Parsing
  2031.     final_list = []
  2032.     list.each { |command|
  2033.       new_command = command.clone
  2034.       if [108, 408].include?( command.code )
  2035.         new_command = RPG::EventCommand.new
  2036.         new_command.indent = command.indent
  2037.         case command.parameters.to_s.upcase
  2038.         when "DETONATE"
  2039.           new_command.code = 1000
  2040.         end
  2041.       end  
  2042.       final_list << new_command
  2043.     }  
  2044.     return final_list
  2045.   end
  2046.  
  2047. #==============================================================================#
  2048. # // Main Classes
  2049. #==============================================================================#
  2050. # ** Pos  
  2051. #==============================================================================#
  2052.   class Pos  
  2053.    
  2054.     #--------------------------------------------------------------------------#
  2055.     # * Public Instance Variable(s)
  2056.     #--------------------------------------------------------------------------#  
  2057.     attr_accessor :x, :y, :z # // X, Y, Z
  2058.    
  2059.     #--------------------------------------------------------------------------#
  2060.     # * new-method :initialize
  2061.     #--------------------------------------------------------------------------#
  2062.     def initialize( x, y, z=0 ) ; set( x, y, z ) end
  2063.      
  2064.     #--------------------------------------------------------------------------#
  2065.     # * new-method :set
  2066.     #--------------------------------------------------------------------------#
  2067.     def set( x, y, z=@z ) ; @x = x ; @y = y ; @z = z ; end
  2068.      
  2069.     #--------------------------------------------------------------------------#
  2070.     # * super-method :==
  2071.     #--------------------------------------------------------------------------#  
  2072.     def ==( obj )
  2073.       return ( @x == obj.x &&
  2074.         @y == obj.y &&
  2075.         @z == obj.z ) if obj.kind_of?( self.class )
  2076.       return super( obj )  
  2077.     end
  2078.    
  2079.   end
  2080.  
  2081. #==============================================================================#
  2082. # ** YGG::Handlers::Screen
  2083. #==============================================================================#
  2084.   class Handlers::Screen < Pos
  2085.    
  2086.     #--------------------------------------------------------------------------#
  2087.     # * Public Instance Variable(s)
  2088.     #--------------------------------------------------------------------------#  
  2089.     attr_accessor :real_x, :real_y
  2090.    
  2091.     #--------------------------------------------------------------------------#
  2092.     # * super-method :initialize
  2093.     #--------------------------------------------------------------------------#
  2094.     def initialize( x, y, z=200 ) ; super( x, y, z ) ; moveto( x, y, z ) ; end
  2095.    
  2096.     #--------------------------------------------------------------------------#
  2097.     # * new-method :moveto
  2098.     #--------------------------------------------------------------------------#
  2099.     def moveto( x, y, z=@z )
  2100.       set( x % $game_map.width, y % $game_map.height, z )
  2101.       @real_x = @x * 256 ; @real_y = @y * 256
  2102.     end
  2103.    
  2104.     #--------------------------------------------------------------------------#
  2105.     # * new-method :screen_x
  2106.     #--------------------------------------------------------------------------#  
  2107.     def screen_x()
  2108.       return ($game_map.adjust_x(@real_x) + 8007) / 8 - 1000 + 16
  2109.     end
  2110.    
  2111.     #--------------------------------------------------------------------------#
  2112.     # * new-method :screen_y
  2113.     #--------------------------------------------------------------------------#  
  2114.     def screen_y()
  2115.       return ($game_map.adjust_y(@real_y) + 8007) / 8 - 1000 + 32
  2116.     end
  2117.    
  2118.     #--------------------------------------------------------------------------#
  2119.     # * new-method :screen_z
  2120.     #--------------------------------------------------------------------------#  
  2121.     def screen_z() ; return @z ; end
  2122.    
  2123.   end
  2124.  
  2125. #==============================================================================#
  2126. # ** Handlers::CharPos
  2127. #==============================================================================#
  2128.   class Handlers::CharPos < Handlers::Screen
  2129.    
  2130.     #--------------------------------------------------------------------------#
  2131.     # * Public Instance Variable(s)
  2132.     #--------------------------------------------------------------------------#
  2133.     attr_accessor :fade_amount
  2134.     attr_accessor :fade_max
  2135.    
  2136.     #--------------------------------------------------------------------------#
  2137.     # * super-method :initialize
  2138.     #--------------------------------------------------------------------------#
  2139.     def initialize( x=0, y=0, z=0, fade_out=0, fade_amt=0 )
  2140.       super( x, y, z )
  2141.       @fade_out    = fade_out
  2142.       @fade_amount = @fade_max = fade_amt
  2143.     end
  2144.    
  2145.     #--------------------------------------------------------------------------#
  2146.     # * new-method :fader_type
  2147.     #--------------------------------------------------------------------------#
  2148.     def fader_type() ; return @fade_out ; end
  2149.    
  2150.     #--------------------------------------------------------------------------#
  2151.     # * new-method :setup_pos
  2152.     #--------------------------------------------------------------------------#
  2153.     def setup_pos( x, y ) ; moveto( @x, @y ) ; end
  2154.    
  2155.   end  
  2156.    
  2157. #==============================================================================#
  2158. # ** Handlers::Range
  2159. #==============================================================================#
  2160.   class Handlers::Range  
  2161.    
  2162.     #--------------------------------------------------------------------------#
  2163.     # * Class Variable
  2164.     #--------------------------------------------------------------------------#
  2165.     @@_recorded_ranges = { }
  2166.    
  2167.     #--------------------------------------------------------------------------#
  2168.     # * class-method :createRange
  2169.     #--------------------------------------------------------------------------#
  2170.     def self.createRange( rng, minrng=0, type=0, direction=2 )
  2171.       datarray = [ rng, minrng, type, direction ]
  2172.       unless @@_recorded_ranges.has_key?( datarray )
  2173.         result   = []
  2174.         case type
  2175.         when 0 # // Normal - Diamond <>
  2176.           for x in 0..rng
  2177.             for y in 0..rng
  2178.               next if x+y > rng
  2179.               next if x+y < minrng
  2180.               result << [ x,  y] ; result << [-x,  y]
  2181.               result << [ x, -y] ; result << [-x, -y]
  2182.             end
  2183.           end
  2184.         when 1 # // Cross +
  2185.           for x in 0..rng
  2186.             for y in 0..rng
  2187.               next if x+y > rng
  2188.               next if x+y < minrng
  2189.               result << [ x,  0] ; result << [-x,  0]
  2190.               result << [ 0, -y] ; result << [ 0,  y]
  2191.             end
  2192.           end
  2193.         when 2 # // X - x
  2194.           for x in 0..rng
  2195.             for y in 0..rng
  2196.               next if x+y > rng
  2197.               next if x+y < minrng
  2198.               result << [ x,  x] ; result << [-x, -x]
  2199.               result << [-y,  y] ; result << [ y, -y]
  2200.             end
  2201.           end
  2202.         when 3 # // Breath <
  2203.           for x in 0..rng
  2204.             for y in 0..rng
  2205.               next if x+y > rng
  2206.               next if x+y < minrng
  2207.               case direction
  2208.               when 2 ; result << [ x,  y] ; result << [-x,  y]
  2209.               when 4 ; result << [-x,  y] ; result << [-x, -y]
  2210.               when 6 ; result << [ x,  y] ; result << [ x, -y]
  2211.               when 8 ; result << [ x, -y] ; result << [-x, -y]
  2212.               end  
  2213.             end
  2214.           end
  2215.         when 4 # // Snow Flake *
  2216.           for x in 0..rng
  2217.             next if x < minrng
  2218.             result << [ 0,  x] ; result << [ x,  0]
  2219.             result << [ 0, -x] ; result << [-x,  0]
  2220.             result << [ x,  x] ; result << [-x,  x]
  2221.             result << [ x, -x] ; result << [-x, -x]
  2222.           end  
  2223.         when 5 # // Block []
  2224.           for x in 0..rng
  2225.             for y in 0..rng
  2226.               next if x < minrng && y < minrng
  2227.               result << [ x,  y] ; result << [-x,  y]
  2228.               result << [ x, -y] ; result << [-x, -y]
  2229.             end
  2230.           end  
  2231.         when 6 # // Linear <-
  2232.           for x in 0..rng
  2233.             for y in 0..rng
  2234.               next if x+y > rng
  2235.               next if x+y < minrng
  2236.               case direction
  2237.               when 2 ; result << [ 0,  y]
  2238.               when 4 ; result << [-x,  0]
  2239.               when 6 ; result << [ x,  0]
  2240.               when 8 ; result << [ 0, -y]
  2241.               end  
  2242.             end
  2243.           end
  2244.         end
  2245.         @@_recorded_ranges[datarray] = result.compact.uniq
  2246.       end  
  2247.       return @@_recorded_ranges[datarray]
  2248.     end
  2249.    
  2250.   end
  2251.  
  2252. #==============================================================================#
  2253. # // YGG Construction
  2254. #==============================================================================#
  2255. # ** REGEXP
  2256. #==============================================================================#  
  2257.   module REGEXP
  2258. #==============================================================================#
  2259. # ** EVENT
  2260. #==============================================================================#
  2261.     module EVENT
  2262.       # Event Tags
  2263.       ABS_ALLY         = /<(?:ABS_ALLY|abs ally):[ ]*(\d+)>/i
  2264.       ABS_ENEMY        = /<(?:ABS_ENEMY|abs enemy):[ ]*(\d+)>/i
  2265.       ABS_SET_AS_ALLY  = /<(?:SET_AS_ALLY|SET AS ALLY)>/i
  2266.       ABS_SET_AS_ENEMY = /<(?:SET_AS_ENEMY|SET AS ENEMY)>/i
  2267.       ABS_BOSS         = /<(?:ABS_BOSS|abs boss)>/i
  2268.       SELF_SWITCH      = /<(?:DEAD_SELF_SWITCH|dead self switch):[ ]*(\w+)>/i
  2269.       SWITCH           = /<(?:DEAD_SWITCH|dead switch):[ ]*(\d+)[ ]*,[ ]*(\w+)>/i
  2270.       NO_FADE_DEATH    = /<(?:NO_FADE_DEATH|no fade death)>/i
  2271.       INSTANT_DEATH    = /<(?:INSTANT_DEATH|instant death)>/i
  2272.       DEATH_ANIM       = /<(?:DEATH_ANIMATION_ID|death animation id|death anim|DEATH_ANIM):[ ]*(\d+)>/i
  2273.       INVINCIBLE       = /<(?:INVINCIBLE|IMMORTAL)>/i
  2274.      
  2275.       AI_ENGINE1       = /<(?:AI_ENGINE|AI ENGINE):[ ](.*)>/i
  2276.       AI_ENGINE2       = /<\/(?:AI_ENGINE|AI ENGINE)>/i
  2277.       ENABLE_POP       = /<(?:ENABLE_POP|ENABLE POP|ENABLEPOP)>/i
  2278.       DISABLE_POP      = /<(?:DISABLE_POP|DISABLE POP|DISABLEPOP|NO POP|NO_POP|NOPOP)>/i
  2279.       SHOW_HP_BAR      = /<(?:SHOW_HP_BAR|SHOW HP BAR|SHOWHPBAR)>/i
  2280.       HIDE_HP_BAR      = /<(?:HIDE_HP_BAR|HIDE HP BAR|HIDEHPBAR)>/i
  2281.       SHOW_MP_BAR      = /<(?:SHOW_MP_BAR|SHOW MP BAR|SHOWMPBAR)>/i
  2282.       HIDE_MP_BAR      = /<(?:HIDE_MP_BAR|HIDE MP BAR|HIDEMPBAR)>/i
  2283.     end # // EVENT
  2284. #==============================================================================#
  2285. # ** BASE_ITEM
  2286. #==============================================================================#
  2287.     module BASE_ITEM
  2288.       # Equipment Tags
  2289.       ACTION_OPEN   = /<ACTION[ ]*(\d+)>/i
  2290.       ACTION_CLOSE  = /<\/ACTION>/i
  2291.       ACTION_ASSIGN = /<ACTION[ ]*(\d+)[ ]*\=[ ]*(.*)>/i
  2292.      
  2293.       PREACTION_OPEN   = /<PREACTION[ ]*(\d+)>/i
  2294.       PREACTION_CLOSE  = /<\/PREACTION>/i
  2295.       PREACTION_ASSIGN = /<PREACTION[ ]*(\d+)[ ]*\=[ ]*(.*)>/i
  2296.      
  2297.       ACTION_6      = /[ ]*(.*):[ ](.*),[ ](.*),[ ](.*),[ ](.*),[ ](.*),[ ](.*)/i
  2298.       ACTION_5      = /[ ]*(.*):[ ](.*),[ ](.*),[ ](.*),[ ](.*),[ ](.*)/i
  2299.       ACTION_4      = /[ ]*(.*):[ ](.*),[ ](.*),[ ](.*),[ ](.*)/i
  2300.       ACTION_3      = /[ ]*(.*):[ ](.*),[ ](.*),[ ](.*)/i
  2301.       ACTION_2      = /[ ]*(.*):[ ](.*),[ ](.*)/i
  2302.       ACTION_1      = /[ ]*(.*):[ ](.*)/i
  2303.      
  2304.       DROPS_ATTRACT = /<(?:ATTRACT_DROP|attract drop)s?>/i
  2305.      
  2306.       CHARGE_CAP    = /<(?:CHARGE_CAP|CHARGE CAP|COOLDOWN):[ ]*(\d+)>/i
  2307.     USER_CHARGE_CAP = /<(?:USER_CHARGE_CAP|USER CHARGE CAP|USER_COOLDOWN|USER COOLDOWN):[ ]*(\d+)>/i
  2308.    
  2309.       CANT_EQUIP    = /<(?:CANT_EQUIP_SLOT|CANT EQUIP SLOT)>/i  
  2310.      
  2311.       PICKUP_SFX    = /<(?:PICKUP_SFX|PICKUP SFX|PKSFX):[ ](.*),[ ](\d+),[ ](\d+)>/i
  2312.     end
  2313. #==============================================================================#
  2314. # ** SKILL
  2315. #==============================================================================#      
  2316.     module SKILL
  2317.       UTARGET_SELECT= /<(?:USE_TARGET_SELECT|USE TARGET SELECT)>/i
  2318.     end # // BASE_ITEM
  2319. #==============================================================================#
  2320. # ** STATE
  2321. #==============================================================================#    
  2322.     module STATE
  2323.       HOLD_TICKS = /<(?:HOLDTICKS|HOLD_TICKS|HOLD TICKS):[ ](\d+)>/i
  2324.       TONE       = /<TONE:[ ]([\+\-]?\d+),[ ]*([\+\-]?\d+),[ ]*([\+\-]?\d+),[ ]*(\d+)>/i
  2325.       MOVE_MOD   = /<(?:MOVEMOD|MOVE_MOD|MOVE MOD):[ ]([\+\-]\d+)>/i
  2326.       SLIP_FREQ  = /<(?:SLIPFREQ|SLIP_FREQ|SLIP FREQ):[ ](\d+)>/i
  2327.     end # // STATE
  2328. #==============================================================================#
  2329. # ** ENEMY
  2330. #==============================================================================#        
  2331.     module ENEMY
  2332.       ATK_ANIMATION_ID = /<(?:ATK_ANIMATION_ID|ATK ANIMATION ID):[ ](\d+)>/i
  2333.       DROP_ITEM1       = /<(?:DROP_ITEM|DROP ITEM|DROPITEM)[ ](\d+)>/i
  2334.       DROP_ITEM2       = /<\/(?:DROP_ITEM|DROP ITEM|DROPITEM)>/i
  2335.       DROP_CLEAR       = /<(?:DROPS_CLEAR|DROPS CLEAR|DROPSCLEAR)>/i
  2336.     end  
  2337.   end # // REGEXP
  2338. end # // YGG
  2339.  
  2340. #==============================================================================#
  2341. #
  2342. # OriginalWij and Yanfly Collaboration - Keyboard Input
  2343. # Last Date Updated: 2010.06.12
  2344. #
  2345. #==============================================================================#
  2346. # Updates
  2347. # -----------------------------------------------------------------------------#
  2348. # o 2010.06.12 - Started and Finished Script.
  2349. #==============================================================================#
  2350. unless $imported["KeyboardInput"]
  2351. ($imported ||= {})["KeyboardInput"] = true
  2352. #==============================================================================#
  2353. # ** Input
  2354. #==============================================================================#
  2355. class << Input  
  2356.   #--------------------------------------------------------------------------#
  2357.   # Aliases (Mods - Linked to Module) - Created by OriginalWij
  2358.   #--------------------------------------------------------------------------#
  2359.   alias ow_dt_i_press press? unless $@
  2360.   alias ow_dt_i_trigger trigger? unless $@
  2361.   alias ow_dt_i_repeat repeat? unless $@
  2362.   alias ow_dt_i_update update unless $@
  2363. end
  2364.  
  2365. module Input
  2366.  
  2367.   #--------------------------------------------------------------------------
  2368.   # * initial module settings - Created by OriginalWij and Yanfly
  2369.   #--------------------------------------------------------------------------
  2370.   GetKeyState = Win32API.new( "user32", "GetAsyncKeyState", "i", "i" )
  2371.   GetCapState = Win32API.new( "user32", "GetKeyState", "i", "i" )
  2372.   KeyRepeatCounter = {}
  2373.  
  2374.   module_function()
  2375.   #--------------------------------------------------------------------------
  2376.   # * alias-method :update - Created by OriginalWij
  2377.   #--------------------------------------------------------------------------
  2378.   def update()
  2379.     ow_dt_i_update()
  2380.     for key in KeyRepeatCounter.keys
  2381.       if (GetKeyState.call(key).abs & 0x8000 == 0x8000)
  2382.         KeyRepeatCounter[key] += 1
  2383.       else
  2384.         KeyRepeatCounter.delete(key)
  2385.       end
  2386.     end
  2387.   end
  2388.  
  2389.   #--------------------------------------------------------------------------
  2390.   # * alias-method :press? - Created by OriginalWij
  2391.   #--------------------------------------------------------------------------
  2392.   def press?( key )
  2393.     return ow_dt_i_press(key) if key < 30
  2394.     adjusted_key = adjust_key(key)
  2395.     return true unless KeyRepeatCounter[adjusted_key].nil?
  2396.     return key_pressed?(adjusted_key)
  2397.   end
  2398.  
  2399.   #--------------------------------------------------------------------------
  2400.   # * alias-method :trigger? - Created by OriginalWij
  2401.   #--------------------------------------------------------------------------
  2402.   def trigger?(key)
  2403.     return ow_dt_i_trigger(key) if key < 30
  2404.     adjusted_key = adjust_key(key)
  2405.     count = KeyRepeatCounter[adjusted_key]
  2406.     return ((count == 0) or (count.nil? ? key_pressed?(adjusted_key) : false))
  2407.   end
  2408.  
  2409.   #--------------------------------------------------------------------------
  2410.   # * alias-method :repeat? - Created by OriginalWij
  2411.   #--------------------------------------------------------------------------
  2412.   def repeat?(key)
  2413.     return ow_dt_i_repeat(key) if key < 30
  2414.     adjusted_key = adjust_key(key)
  2415.     count = KeyRepeatCounter[adjusted_key]
  2416.     return true if count == 0
  2417.     if count.nil?
  2418.       return key_pressed?(adjusted_key)
  2419.     else
  2420.       return (count >= 23 and (count - 23) % 6 == 0)
  2421.     end
  2422.   end
  2423.  
  2424.   #--------------------------------------------------------------------------
  2425.   # * new-method :adjust_key - Created by OriginalWij
  2426.   #--------------------------------------------------------------------------
  2427.   def adjust_key(key)
  2428.     key -= 130 if key.between?(130, 158)
  2429.     return key
  2430.   end
  2431.  
  2432.   #--------------------------------------------------------------------------
  2433.   # * new-method :key_pressed? - Created by OriginalWij
  2434.   #--------------------------------------------------------------------------
  2435.   def key_pressed?(key)
  2436.     if (GetKeyState.call(key).abs & 0x8000 == 0x8000)
  2437.       KeyRepeatCounter[key] = 0
  2438.       return true
  2439.     end
  2440.     return false
  2441.   end
  2442.  
  2443.   #--------------------------------------------------------------------------
  2444.   # * new-method :typing? - Created by Yanfly
  2445.   #--------------------------------------------------------------------------
  2446.   def typing?
  2447.     return true if repeat?(SPACE)
  2448.     for i in 'A'..'Z'
  2449.       return true if repeat?(LETTERS[i])
  2450.     end
  2451.     for i in 0...NUMBERS.size
  2452.       return true if repeat?(NUMBERS[i])
  2453.       return true if repeat?(NUMPAD[i])
  2454.     end
  2455.     for key in Extras
  2456.       return true if repeat?(key)
  2457.     end
  2458.     return false
  2459.   end
  2460.  
  2461.   #--------------------------------------------------------------------------
  2462.   # * new-method :key_type - Created by Yanfly
  2463.   #--------------------------------------------------------------------------
  2464.   def key_type()
  2465.     return " " if repeat?(SPACE)
  2466.     for i in 'A'..'Z'
  2467.       next unless repeat?(LETTERS[i])
  2468.       return upcase? ? i.upcase : i.downcase
  2469.     end
  2470.     for i in 0...NUMBERS.size
  2471.       return i.to_s if repeat?(NUMPAD[i])
  2472.       if !press?(SHIFT)
  2473.         return i.to_s if repeat?(NUMBERS[i])
  2474.       elsif repeat?(NUMBERS[i])
  2475.         case i
  2476.         when 1; return "!"
  2477.         when 2; return "@"
  2478.         when 3; return "#"
  2479.         when 4; return "$"
  2480.         when 5; return "%"
  2481.         when 6; return "^"
  2482.         when 7; return "&"
  2483.         when 8; return "*"
  2484.         when 9; return "("
  2485.         when 0; return ")"
  2486.         end
  2487.       end
  2488.     end
  2489.     for key in Extras
  2490.       next unless repeat?(key)
  2491.       case key
  2492.       when USCORE; return press?(SHIFT) ? "_" : "-"
  2493.       when EQUALS; return press?(SHIFT) ? "+" : "="
  2494.       when LBRACE; return press?(SHIFT) ? "{" : "["
  2495.       when RBRACE; return press?(SHIFT) ? "}" : "]"
  2496.       when BSLASH; return press?(SHIFT) ? "|" : "\\"
  2497.       when SCOLON; return press?(SHIFT) ? ":" : ";"
  2498.       when QUOTE;  return press?(SHIFT) ? '"' : "'"
  2499.       when COMMA;  return press?(SHIFT) ? "<" : ","
  2500.       when PERIOD; return press?(SHIFT) ? ">" : "."
  2501.       when SLASH;  return press?(SHIFT) ? "?" : "/"
  2502.       when NMUL;   return "*"
  2503.       when NPLUS;  return "+"
  2504.       when NSEP;   return ","
  2505.       when NMINUS; return "-"
  2506.       when NDECI;  return "."
  2507.       when NDIV;   return "/"
  2508.       end
  2509.     end
  2510.     return ""
  2511.   end
  2512.  
  2513.   #--------------------------------------------------------------------------
  2514.   # * new-method :upcase? - Created by Yanfly
  2515.   #--------------------------------------------------------------------------
  2516.   def upcase?()
  2517.     return !press?(SHIFT) if GetCapState.call(CAPS) == 1
  2518.     return true if press?(SHIFT)
  2519.     return false
  2520.   end
  2521.  
  2522. end # Input
  2523. end
  2524.  
  2525. #==============================================================================#
  2526. # ** Vocab
  2527. #==============================================================================#
  2528. module Vocab
  2529.  
  2530.   #--------------------------------------------------------------------------#
  2531.   # * new-method :maxhp
  2532.   #--------------------------------------------------------------------------#
  2533.   def self.maxhp ; return self.hp ; end
  2534.    
  2535.   #--------------------------------------------------------------------------#
  2536.   # * new-method :maxmp
  2537.   #--------------------------------------------------------------------------#  
  2538.   def self.maxmp ; return self.mp ; end
  2539.    
  2540. end
  2541.  
  2542. #==============================================================================#
  2543. # ** Array
  2544. #==============================================================================#
  2545. class Array
  2546.  
  2547.   #--------------------------------------------------------------------------#
  2548.   # * new-method :rotate
  2549.   #--------------------------------------------------------------------------#  
  2550.   def rotate( n=1 ) ; dup.rotate!( n ) ; end unless method_defined? :rotate
  2551.  
  2552.   #--------------------------------------------------------------------------#
  2553.   # * new-method :rotate!
  2554.   #--------------------------------------------------------------------------#
  2555.   def rotate!( n=1 )
  2556.     return self if empty?
  2557.     n %= size
  2558.     concat( slice!( 0, n ) )
  2559.   end unless method_defined? :rotate!
  2560.  
  2561. end
  2562.  
  2563. #==============================================================================#
  2564. # ** Rect
  2565. #==============================================================================#
  2566. class Rect
  2567.  
  2568.   #--------------------------------------------------------------------------#
  2569.   # * new-method :to_a
  2570.   #--------------------------------------------------------------------------#  
  2571.   def to_a() ; return self.x, self.y, self.width, self.height ; end
  2572.  
  2573.   #--------------------------------------------------------------------------#
  2574.   # * new-method :to_vector4_a
  2575.   #--------------------------------------------------------------------------#  
  2576.   def to_vector4_a()
  2577.     return self.x, self.y, self.x + self.width, self.y + self.height
  2578.   end
  2579.  
  2580. end
  2581.  
  2582. #==============================================================================#
  2583. # ** YGG::Caches1x6
  2584. #==============================================================================#
  2585. module YGG::Caches1x6
  2586.  
  2587.   #--------------------------------------------------------------------------#
  2588.   # * Public Instance Variable(s)
  2589.   #--------------------------------------------------------------------------#  
  2590.   attr_accessor :ygg_actions, :ygg_pre_actions
  2591.   attr_accessor :ygg_target_range
  2592.   attr_accessor :drops_attraction
  2593.   attr_accessor :atk_act_name, :grd_act_name
  2594.   attr_accessor :charge_cap
  2595.   attr_accessor :user_charge_cap
  2596.   attr_accessor :cant_equip_slot
  2597.  
  2598.   #--------------------------------------------------------------------------#
  2599.   # * new-method :ygg_add_to_cache
  2600.   #--------------------------------------------------------------------------#
  2601.   def ygg_add_to_cache( array )
  2602.     unless @__pre_action
  2603.       @ygg_actions[@__current_action] << array
  2604.     else  
  2605.       @ygg_pre_actions[@__current_action] << array
  2606.     end  
  2607.   end
  2608.  
  2609.   #--------------------------------------------------------------------------#
  2610.   # * new-method :yggdrasil_1x6_cache
  2611.   #--------------------------------------------------------------------------#
  2612.   def yggdrasil_1x6_cache()
  2613.     yggdrasil_1x6_cache_start()
  2614.     self.note.split(/[\r\n]+/).each { |line| yggdrasil_1x6_cache_check( line ) }
  2615.     yggdrasil_1x6_cache_end()
  2616.   end
  2617.  
  2618.   #--------------------------------------------------------------------------#
  2619.   # * new-method :yggdrasil_1x6_cache_start
  2620.   #--------------------------------------------------------------------------#
  2621.   def yggdrasil_1x6_cache_start()
  2622.     @charge_cap      = 0
  2623.     @user_charge_cap = 0
  2624.     @atk_act_name    = ""
  2625.     @grd_act_name    = ""
  2626.     case self
  2627.     when RPG::Item
  2628.       # // Yeah ....
  2629.     when RPG::Weapon
  2630.       @atk_act_name = "Swing1"
  2631.     when RPG::Armor  
  2632.       @grd_act_name = "GRise1"
  2633.     end  
  2634.     @ygg_actions      = []  
  2635.     @ygg_pre_actions  = []
  2636.     @ygg_target_range = 0
  2637.     @drops_attraction = false
  2638.     @__current_action = -1
  2639.     @__pre_action     = false
  2640.     @cant_equip_slot  = false
  2641.   end
  2642.  
  2643.   #--------------------------------------------------------------------------#
  2644.   # * new-method :yggdrasil_1x6_cache_check
  2645.   #--------------------------------------------------------------------------#
  2646.   def yggdrasil_1x6_cache_check( line )
  2647.     case line
  2648.     # // Action  
  2649.     when ::YGG::REGEXP::BASE_ITEM::ACTION_OPEN
  2650.       @__current_action = $1.to_i
  2651.       @ygg_actions[@__current_action] = []
  2652.       @__pre_action = false
  2653.     when ::YGG::REGEXP::BASE_ITEM::ACTION_CLOSE  
  2654.       @__pre_action = false
  2655.       @__current_action = -1
  2656.     when ::YGG::REGEXP::BASE_ITEM::ACTION_ASSIGN
  2657.       @ygg_actions[$1.to_i] = ::YGG.get_action_list( $2 )
  2658.     # // Pre Action  
  2659.     when ::YGG::REGEXP::BASE_ITEM::PREACTION_OPEN
  2660.       @__current_action = $1.to_i
  2661.       @ygg_pre_actions[@__current_action] = []
  2662.       @__pre_action = true
  2663.     when ::YGG::REGEXP::BASE_ITEM::PREACTION_CLOSE  
  2664.       @__current_action = -1
  2665.       @__pre_action = false
  2666.     when ::YGG::REGEXP::BASE_ITEM::PREACTION_ASSIGN
  2667.       @ygg_pre_actions[$1.to_i] = ::YGG.get_action_list( $2 )  
  2668.      
  2669.     when ::YGG::REGEXP::BASE_ITEM::DROPS_ATTRACT  
  2670.       @drops_attraction = true
  2671.     when ::YGG::REGEXP::BASE_ITEM::CHARGE_CAP  
  2672.       @charge_cap = $1.to_i
  2673.     when ::YGG::REGEXP::BASE_ITEM::USER_CHARGE_CAP  
  2674.       @user_charge_cap = $1.to_i
  2675.      
  2676.     when ::YGG::REGEXP::BASE_ITEM::CANT_EQUIP
  2677.       @cant_equip_slot = true
  2678.     else
  2679.       if @__current_action > -1
  2680.         case line
  2681.         # // Exception
  2682.         when /SCRIPT:[ ](.*)/i
  2683.           ygg_add_to_cache [ $1, [$2]                     ]
  2684.         # // Regular Actions  
  2685.         when ::YGG::REGEXP::BASE_ITEM::ACTION_6
  2686.           ygg_add_to_cache [ $1, [$2, $3, $4, $5, $6, $7] ]
  2687.         when ::YGG::REGEXP::BASE_ITEM::ACTION_5
  2688.           ygg_add_to_cache [ $1, [$2, $3, $4, $5, $6]     ]
  2689.         when ::YGG::REGEXP::BASE_ITEM::ACTION_4
  2690.           ygg_add_to_cache [ $1, [$2, $3, $4, $5]         ]  
  2691.         when ::YGG::REGEXP::BASE_ITEM::ACTION_3
  2692.           ygg_add_to_cache [ $1, [$2, $3, $4]             ]
  2693.         when ::YGG::REGEXP::BASE_ITEM::ACTION_2
  2694.           ygg_add_to_cache [ $1, [$2, $3]                 ]  
  2695.         when ::YGG::REGEXP::BASE_ITEM::ACTION_1
  2696.           ygg_add_to_cache [ $1, [$2]                     ]  
  2697.         else
  2698.           ygg_add_to_cache [ line, []                     ]
  2699.         end # // case line
  2700.       end # // if current_action > -1
  2701.     end # // case line
  2702.   end
  2703.  
  2704.   #--------------------------------------------------------------------------#
  2705.   # * new-method :yggdrasil_1x6_cache_end
  2706.   #--------------------------------------------------------------------------#
  2707.   def yggdrasil_1x6_cache_end()
  2708.     @__current_action = nil ; @__pre_action = nil
  2709.   end
  2710.  
  2711. end  
  2712.  
  2713. #==============================================================================#
  2714. # ** YGG::Containers::GoldItem  
  2715. #==============================================================================#
  2716. class YGG::Containers::GoldItem
  2717.  
  2718.   #--------------------------------------------------------------------------#
  2719.   # * Public Instance Variable(s)
  2720.   #--------------------------------------------------------------------------#  
  2721.   attr_accessor :name
  2722.   attr_accessor :gold_amount
  2723.   attr_accessor :icon_index
  2724.   attr_accessor :pickup_sfx
  2725.  
  2726.   #--------------------------------------------------------------------------#
  2727.   # * new-method :initialize
  2728.   #--------------------------------------------------------------------------#
  2729.   def initialize( amt )
  2730.     @name        = ::Vocab.gold
  2731.     @gold_amount = amt
  2732.     @icon_index  = ::YGG::GOLD_DROP_ICON
  2733.     @pickup_sfx  = ::YGG::SOUND_MONEY
  2734.   end
  2735.  
  2736. end
  2737.  
  2738. #==============================================================================#
  2739. # ** YGG::Handlers::Engage
  2740. #==============================================================================#
  2741. class YGG::Handlers::Engage
  2742.  
  2743.   #--------------------------------------------------------------------------#
  2744.   # * Public Instance Variable(s)
  2745.   #--------------------------------------------------------------------------#
  2746.   attr_accessor :parent
  2747.   attr_accessor :bar_opacity
  2748.  
  2749.   #--------------------------------------------------------------------------#
  2750.   # * new-method :initialize
  2751.   #--------------------------------------------------------------------------#
  2752.   def initialize( parent )
  2753.     @parent      = parent
  2754.     @cool_down   = 0
  2755.     @bar_opacity = 255
  2756.   end
  2757.  
  2758.   #--------------------------------------------------------------------------#
  2759.   # * new-method :engage
  2760.   #--------------------------------------------------------------------------#
  2761.   def engage( cool_down )
  2762.     @cool_down   = cool_down
  2763.     @bar_opacity = 255
  2764.   end
  2765.  
  2766.   #--------------------------------------------------------------------------#
  2767.   # * new-method :engaged?
  2768.   #--------------------------------------------------------------------------#
  2769.   def engaged? ; return @cool_down > 0 ; end
  2770.  
  2771.   #--------------------------------------------------------------------------#
  2772.   # * new-method :update
  2773.   #--------------------------------------------------------------------------#
  2774.   def update()
  2775.     update_cool_down()
  2776.     update_bar_opacity()
  2777.   end
  2778.  
  2779.   #--------------------------------------------------------------------------#
  2780.   # * new-method :update_cool_down
  2781.   #--------------------------------------------------------------------------#
  2782.   def update_cool_down()
  2783.     @cool_down = [@cool_down-1, 0].max
  2784.   end
  2785.  
  2786.   #--------------------------------------------------------------------------#
  2787.   # * new-method :update_bar_opacity
  2788.   #--------------------------------------------------------------------------#
  2789.   def update_bar_opacity()
  2790.     if engaged?()
  2791.       @bar_opacity = [@bar_opacity+(255/60.0), 255].min
  2792.     else
  2793.       @bar_opacity = [@bar_opacity-(255/60.0), 0].max
  2794.     end  
  2795.   end
  2796.  
  2797. end
  2798.  
  2799. #==============================================================================#
  2800. # ** YGG::Handlers::Equip
  2801. #==============================================================================#
  2802. class YGG::Handlers::Equip < YGG::Pos
  2803.  
  2804.   #--------------------------------------------------------------------------#
  2805.   # * Public Instance Variable(s)
  2806.   #--------------------------------------------------------------------------#
  2807.   attr_accessor :parent
  2808.   attr_accessor :icon_index
  2809.   attr_accessor :eq_id
  2810.   attr_accessor :mirror
  2811.   attr_accessor :opacity, :visible
  2812.   attr_accessor :sox, :soy # // Sprite Offset
  2813.   attr_writer   :angle
  2814.  
  2815.   #--------------------------------------------------------------------------#
  2816.   # * new-method :angle_debug # // DEBUG
  2817.   #--------------------------------------------------------------------------#  
  2818.   def angle_debug()
  2819.     #@angle = (@angle + 1) % 360 if @eq_id == 0
  2820.     if Input.trigger?(Input::NUMBERS[1])
  2821.       @sox += 1
  2822.       puts @sox
  2823.     elsif Input.trigger?(Input::NUMBERS[2])
  2824.       @sox -= 1
  2825.       puts @sox
  2826.     elsif Input.trigger?(Input::NUMBERS[3])  
  2827.       @soy += 1
  2828.       puts @soy
  2829.     elsif Input.trigger?(Input::NUMBERS[4])  
  2830.       @soy -= 1
  2831.       puts @soy
  2832.     elsif Input.trigger?(Input::NUMBERS[5])  
  2833.       @sox = 0
  2834.       puts @sox  
  2835.     elsif Input.trigger?(Input::NUMBERS[6])  
  2836.       @soy = 0
  2837.       puts @soy
  2838.     end if @parent.is_a?(Game_Player) if @eq_id == 0
  2839.   end
  2840.  
  2841.   #--------------------------------------------------------------------------#
  2842.   # * new-method :initialize
  2843.   #--------------------------------------------------------------------------#
  2844.   def initialize( parent, eq_id )
  2845.     super( 0, 0, 0 )
  2846.     @parent       = parent
  2847.     @eq_id        = eq_id
  2848.     @icon_index   = @parent.equip_icon( @eq_id )
  2849.     @list         = []
  2850.     @sox, @soy    = 20, 20
  2851.     @visible      = false
  2852.     @mirror       = false
  2853.     @angle_offset = 0
  2854.     @angle_mult   = 1
  2855.     @attack_action= ""
  2856.     @guard_action = ""
  2857.     reset()
  2858.   end
  2859.  
  2860.   #--------------------------------------------------------------------------#
  2861.   # * new-method :angle
  2862.   #--------------------------------------------------------------------------#
  2863.   def angle ; return (@angle*@angle_mult)+@angle_offset ; end
  2864.    
  2865.   #--------------------------------------------------------------------------#
  2866.   # * new-method :reset
  2867.   #--------------------------------------------------------------------------#
  2868.   def reset()
  2869.     @wait_count   = 0
  2870.     @opacity      = 255
  2871.     @ox, @oy, @oz = 0, 0, 0
  2872.     @angle        = 0
  2873.   end
  2874.  
  2875.   #--------------------------------------------------------------------------#
  2876.   # * new-method :ox
  2877.   #--------------------------------------------------------------------------#
  2878.   def ox ; return @x + @ox + @sox ; end
  2879.   #--------------------------------------------------------------------------#
  2880.   # * new-method :oy
  2881.   #--------------------------------------------------------------------------#
  2882.   def oy ; return @y + @oy + @soy ; end
  2883.   #--------------------------------------------------------------------------#
  2884.   # * new-method :oz
  2885.   #--------------------------------------------------------------------------#  
  2886.   def oz ; return @z + @oz ; end
  2887.  
  2888.   #--------------------------------------------------------------------------#
  2889.   # * new-method :update
  2890.   #--------------------------------------------------------------------------#  
  2891.   def update()
  2892.     update_list()
  2893.     update_position()
  2894.   end
  2895.  
  2896.   #--------------------------------------------------------------------------#
  2897.   # * new-method :do_action
  2898.   #--------------------------------------------------------------------------#  
  2899.   def do_action( name )
  2900.     @icon_index    = @parent.equip_icon( @eq_id )    
  2901.     @list = ACTIONS[name].clone
  2902.   end
  2903.  
  2904.   #--------------------------------------------------------------------------#
  2905.   # * new-method :do_attack
  2906.   #--------------------------------------------------------------------------#  
  2907.   def do_attack()
  2908.     @attack_action = @parent.equip_atk_act_name( @eq_id )
  2909.     do_action( @attack_action ) unless @attack_action == ""
  2910.   end
  2911.  
  2912.   #--------------------------------------------------------------------------#
  2913.   # * new-method :do_guard
  2914.   #--------------------------------------------------------------------------#  
  2915.   def do_guard()
  2916.     @guard_action  = @parent.equip_grd_act_name( @eq_id )
  2917.     do_action( @guard_action ) unless @guard_action == ""
  2918.   end
  2919.  
  2920.   #--------------------------------------------------------------------------#
  2921.   # * new-method :update_position
  2922.   #--------------------------------------------------------------------------#  
  2923.   def update_position()
  2924.     #self.angle_debug()
  2925.     case @eq_id
  2926.     when 0 # // Weapon
  2927.       oox, ooy = @ox, @oy
  2928.       case @parent.direction
  2929.       when 1 # // Down-Left
  2930.       when 2 # // Down
  2931.         @x, @y, @z = -28, -28, 20
  2932.         @sox, @soy    = 20, 20
  2933.         @ox, @oy = oox, ooy
  2934.         #@angle_offset = 0
  2935.         @angle_mult   = 1
  2936.         @mirror = false
  2937.       when 3 # // Down-Right  
  2938.       when 4 # // Left
  2939.         @x, @y, @z = -24, -28, -20
  2940.         @sox, @soy    = 20, 20
  2941.         @ox, @oy = -ooy, -oox
  2942.         #@angle_offset = 0
  2943.         @angle_mult   = 1
  2944.         @mirror = false
  2945.       when 6 # // Right
  2946.         @x, @y, @z = -4, -28, 20
  2947.         @sox, @soy    = 5, 20
  2948.         @ox, @oy = ooy, oox
  2949.         #@angle_offset = 0
  2950.         @angle_mult   = -1
  2951.         @mirror = true
  2952.       when 7 # // Up-Left  
  2953.       when 8 # // Up
  2954.         @x, @y, @z = 4, -28, -20
  2955.         @sox, @soy    = 5, 20
  2956.         @ox, @oy = -oox, ooy
  2957.         #@angle_offset = 0
  2958.         @angle_mult   = -1
  2959.         @mirror = true
  2960.       when 9 # // Up-Right
  2961.       end  
  2962.     when 1 # // Shield
  2963.       case @parent.direction
  2964.       when 1 # // Down-Left
  2965.       when 2 # // Down
  2966.         @x, @y, @z = 0, -24, 20
  2967.         @mirror = true
  2968.       when 3 # // Down-Right  
  2969.       when 4 # // Left
  2970.         @x, @y, @z = -16, -24, 20
  2971.         @mirror = false
  2972.       when 6 # // Right
  2973.         @x, @y, @z = -4, -28, -20
  2974.         @mirror = true
  2975.       when 7 # // Up-Left  
  2976.       when 8 # // Up
  2977.         @x, @y, @z = -24, -24, -20
  2978.         @mirror = false
  2979.       when 9 # // Up-Right
  2980.       end  
  2981.     end  
  2982.   end
  2983.  
  2984.   #--------------------------------------------------------------------------#
  2985.   # * new-method :update_list
  2986.   #--------------------------------------------------------------------------#  
  2987.   def update_list()
  2988.     @wait_count = [@wait_count - 1, 0].max
  2989.     return unless @wait_count == 0
  2990.     while !@list.empty?()
  2991.       ret_value = -1
  2992.       act = @list.shift()
  2993.       case act[0].upcase
  2994.       when "MOVE"
  2995.         case act[1].upcase
  2996.         when "X" ; @ox = act[2]
  2997.         when "Y" ; @oy = act[2]
  2998.         when "Z" ; @oz = act[2] # // For whatever reason
  2999.         end  
  3000.         ret_value = 0
  3001.       when "CHANGEANGLE", "CHANGE_ANGLE", "CHANGE ANGLE"
  3002.         @angle = act[1]
  3003.         ret_value = 0
  3004.       when "RESET"
  3005.         reset()
  3006.         ret_value = 0
  3007.       when "CHANGEOPACITY", "CHANGE_OPACITY", "CHANGE OPACITY"  
  3008.         @opacity = act[1]
  3009.         ret_value = 0
  3010.       when "SHOW"  
  3011.         @visible = true
  3012.         ret_value = 0
  3013.       when "HIDE"  
  3014.         @visible = false
  3015.         ret_value = 0
  3016.       when "WAIT"  
  3017.         @wait_count = act[1]
  3018.         ret_value = 1
  3019.       end  
  3020.       return if ret_value == 1
  3021.     end  
  3022.   end
  3023.  
  3024. end
  3025.  
  3026. #==============================================================================#
  3027. # ** YGG::Handlers::BattleObj
  3028. #==============================================================================#
  3029. class YGG::Handlers::BattleObj
  3030.  
  3031.   #--------------------------------------------------------------------------#
  3032.   # * Public Instance Variable(s)
  3033.   #--------------------------------------------------------------------------#  
  3034.   attr_accessor :obj_id
  3035.   attr_accessor :type
  3036.  
  3037.   #--------------------------------------------------------------------------#
  3038.   # * new-method :initialize
  3039.   #--------------------------------------------------------------------------#  
  3040.   def initialize( id, type )
  3041.     @obj_id, @type = id, type ; @charge_time = 0 ;
  3042.     @dummy_obj = RPG::BaseItem.new() ; @dummy_obj.yggdrasil_1x6_cache()
  3043.   end
  3044.  
  3045.   #--------------------------------------------------------------------------#
  3046.   # * new-method :skill
  3047.   #--------------------------------------------------------------------------#  
  3048.   def skill()
  3049.     return @type == :skill ? $data_skills[@obj_id] : nil
  3050.   end
  3051.  
  3052.   #--------------------------------------------------------------------------#
  3053.   # * new-method :item
  3054.   #--------------------------------------------------------------------------#
  3055.   def item()
  3056.     return @type == :item ? $data_items[@obj_id] : nil
  3057.   end
  3058.  
  3059.   #--------------------------------------------------------------------------#
  3060.   # * new-method :obj
  3061.   #--------------------------------------------------------------------------#  
  3062.   def obj()
  3063.     return item() || skill() || @dummy_obj
  3064.   end
  3065.  
  3066.   #--------------------------------------------------------------------------#
  3067.   # * new-method :reset_time
  3068.   #--------------------------------------------------------------------------#  
  3069.   def reset_time()
  3070.     @charge_time = cap
  3071.   end
  3072.  
  3073.   #--------------------------------------------------------------------------#
  3074.   # * new-method :time
  3075.   #--------------------------------------------------------------------------#  
  3076.   def time()
  3077.     return @charge_time
  3078.   end
  3079.  
  3080.   #--------------------------------------------------------------------------#
  3081.   # * new-method :cap
  3082.   #--------------------------------------------------------------------------#  
  3083.   def cap()
  3084.     return obj.charge_cap
  3085.   end
  3086.  
  3087.   #--------------------------------------------------------------------------#
  3088.   # * new-method :can_use?
  3089.   #--------------------------------------------------------------------------#  
  3090.   def can_use?() ; return @charge_time == 0 ; end
  3091.  
  3092.   #--------------------------------------------------------------------------#
  3093.   # * new-method :update
  3094.   #--------------------------------------------------------------------------#  
  3095.   def update()
  3096.     @charge_time = [@charge_time - 1, 0].max
  3097.   end
  3098.  
  3099. end
  3100.  
  3101. #==============================================================================#
  3102. # ** YGG::System (Battle Edits)
  3103. #==============================================================================#
  3104. class YGG::System
  3105.  
  3106.   #--------------------------------------------------------------------------#
  3107.   # * new-method :action_attack
  3108.   #--------------------------------------------------------------------------#  
  3109.   def action_attack( user_ev, targets_ev )
  3110.     user = user_ev.ygg_battler
  3111.     targets_ev.each { |target|
  3112.       next if target.ygg_invincible
  3113.       bat = target.ygg_battler
  3114.       next if bat.nil?()
  3115.       bat.attack_effect( user )
  3116.       target.ygg_engage.engage( 180 )
  3117.       YGG::PopText.create_pop( { :character => target, :type => :attack_damage } ) if target.pop_enabled?() if YGG::USE_TEXT_POP        
  3118.       action_gain_exp( user, bat, user_ev, YGG::POP_EXP ) unless bat.actor?() if user.actor?()
  3119.     }
  3120.   end
  3121.  
  3122.   #--------------------------------------------------------------------------#
  3123.   # * new-method :action_skill
  3124.   #--------------------------------------------------------------------------#  
  3125.   def action_skill( user_ev, targets_ev, obj )
  3126.     targets = targets_ev.inject([]) { |r, e| r << e.ygg_battler }
  3127.     targets.compact!() ; user = user_ev.ygg_battler
  3128.     targets_ev.each { |target|
  3129.       next if target.ygg_invincible
  3130.       bat = target.ygg_battler
  3131.       next if bat.nil?()
  3132.       bat.skill_effect( user, obj )
  3133.       target.ygg_engage.engage( 180 )
  3134.       YGG::PopText.create_pop( { :character => target, :type => :skill_damage } ) if target.pop_enabled?() if YGG::USE_TEXT_POP              
  3135.       action_gain_exp( user, bat, user_ev, YGG::POP_EXP ) unless bat.actor?() if user.actor?()
  3136.     }
  3137.   end
  3138.  
  3139.   #--------------------------------------------------------------------------#
  3140.   # * new-method :action_item
  3141.   #--------------------------------------------------------------------------#  
  3142.   def action_item( user_ev, targets_ev, obj )
  3143.     targets = targets_ev.inject([]) { |r, e| r << e.ygg_battler }
  3144.     targets.compact!() ; user = user_ev.ygg_battler
  3145.     targets_ev.each { |target|
  3146.       next if target.ygg_invincible
  3147.       bat = target.ygg_battler
  3148.       next if bat.nil?()
  3149.       bat.item_effect( user, obj )
  3150.       target.ygg_engage.engage( 180 )
  3151.       YGG::PopText.create_pop( { :character => target, :type => :item_damage } ) if target.pop_enabled?() if YGG::USE_TEXT_POP              
  3152.       action_gain_exp( user, bat, user_ev, YGG::POP_EXP ) unless bat.actor?() if user.actor?()
  3153.     }
  3154.   end
  3155.  
  3156.   #--------------------------------------------------------------------------#
  3157.   # * new-method :action_gain_exp
  3158.   #--------------------------------------------------------------------------#  
  3159.   def action_gain_exp( receivee, bat, event=nil, show=true )
  3160.     case YGG::EXP_GAINING_METHOD
  3161.     when 0 # // Dead
  3162.       return unless bat.dead?()
  3163.       exp = bat.exp
  3164.     when 1 # // Per Hit
  3165.       exp = YGG::EXP_PER_HIT_FORMULA.call(
  3166.         bat.hp_damage+receivee.mp_damage, receivee, bat )
  3167.     end  
  3168.     old_level = receivee.level
  3169.     case YGG::EXP_SAHRE_METHOD
  3170.     when 0 # Active Member Only
  3171.       receivee.gain_exp( exp, false )
  3172.     when 1 # All Members Equal
  3173.       ($game_party.members-[receivee]).each { |mem| mem.gain_exp( exp, false ) }
  3174.       receivee.gain_exp( exp, false )
  3175.     when 2 # All Members Split
  3176.       mems = ($game_party.members-[receivee])
  3177.       exp /= mems.size+1
  3178.       mems.each { |mem| mem.gain_exp( exp, false ) }
  3179.       receivee.gain_exp( exp, false )
  3180.     end          
  3181.     action_level_up( receivee, old_level, event, YGG::POP_LEVEL_UP ) if old_level != receivee.level
  3182.     unless event.nil?()
  3183.       ::YGG::PopText.create_pop(
  3184.         { :character => event, :type => :gain_exp, :parameters => [exp] }
  3185.       ) if YGG::USE_TEXT_POP                
  3186.     end if show
  3187.   end
  3188.  
  3189.   #--------------------------------------------------------------------------#
  3190.   # * new-method :action_level_up
  3191.   #--------------------------------------------------------------------------#
  3192.   def action_level_up( receivee, old_level, event=nil, show=true )
  3193.     $scene.level_up_window.show_level_up( receivee, old_level ) if YGG::USE_LEVEL_UP_WINDOW > 0
  3194.     unless event.nil?()
  3195.       if ::YGG::LEVEL_UP_ALERT
  3196.         event.ygg_anims << ::YGG::ANIM_ON_LEVEL unless ::YGG::ANIM_ON_LEVEL == 0
  3197.       end  
  3198.       ::YGG::PopText.create_pop(
  3199.         { :character => event, :type => :level_up, :parameters => [old_level] }
  3200.       ) if show if YGG::USE_TEXT_POP              
  3201.     end
  3202.   end
  3203.  
  3204. end
  3205.  
  3206. #==============================================================================#
  3207. # ** YGG::Handlers::Action
  3208. #==============================================================================#
  3209. class YGG::Handlers::Action
  3210.  
  3211.   #--------------------------------------------------------------------------#
  3212.   # * Public Instance Variable(s)
  3213.   #--------------------------------------------------------------------------#  
  3214.   attr_accessor :list
  3215.   attr_accessor :list_stack
  3216.   attr_accessor :skill_id, :item_id
  3217.   attr_accessor :user_event
  3218.   attr_accessor :target_events
  3219.   attr_accessor :parent_event
  3220.  
  3221.   #--------------------------------------------------------------------------#
  3222.   # * new-method :initialize
  3223.   #--------------------------------------------------------------------------#  
  3224.   def initialize( parent, list=[] )
  3225.     @parent_event = parent
  3226.     @interpreter = ::Game_Interpreter.new()
  3227.     @list_stack = [] ; setup( list ) ; execute( nil, [], { :skip_first_update=>true } )
  3228.   end
  3229.  
  3230.   #--------------------------------------------------------------------------#
  3231.   # * new-method :setup
  3232.   #--------------------------------------------------------------------------#  
  3233.   def setup( list=[] )
  3234.     @list        = list.clone
  3235.     @active_list = @list.clone
  3236.   end
  3237.  
  3238.   #--------------------------------------------------------------------------#
  3239.   # * new-method :busy?
  3240.   #--------------------------------------------------------------------------#  
  3241.   def busy?()
  3242.     return @list_index < @active_list.size || @interpreter.running?()
  3243.   end
  3244.  
  3245.   #--------------------------------------------------------------------------#
  3246.   # * new-method :execute
  3247.   #--------------------------------------------------------------------------#  
  3248.   def execute( user_event, starting_targets=[], start_values={} )
  3249.     @active_list    = @list.clone
  3250.     @wait_count     = start_values[:wait_count] || 0
  3251.     @skill_id       = start_values[:skill_id] || 0
  3252.     @item_id        = start_values[:item_id] || 0
  3253.     @range          = start_values[:range] || []
  3254.     @target_events  = starting_targets
  3255.     @user_event     = user_event
  3256.     @wait_for_comev = false
  3257.     @list_index     = 0
  3258.     update() unless start_values[:skip_first_update]
  3259.   end
  3260.  
  3261.   #--------------------------------------------------------------------------#
  3262.   # * new-method :update
  3263.   #--------------------------------------------------------------------------#  
  3264.   def update()
  3265.     @interpreter.update()
  3266.     return if @interpreter.running?() && @wait_for_comev
  3267.     @wait_count = [@wait_count-1, 0].max
  3268.     update_action() if @wait_count == 0
  3269.   end
  3270.  
  3271.   #--------------------------------------------------------------------------#
  3272.   # * new-method :update_action
  3273.   #--------------------------------------------------------------------------#  
  3274.   def update_action()
  3275.     unless @list_stack.empty?()
  3276.       setup( @list_stack.shift() )
  3277.       execute( @user_event, @target_events,
  3278.        {
  3279.         :skill_id => @skill_id,
  3280.         :item_id  => @item_id,
  3281.         :range    => @range
  3282.        }
  3283.       )
  3284.     end if @active_list.empty?()
  3285.     while @list_index < @active_list.size
  3286.       act_set = @active_list[@list_index]
  3287.       #break if act_set.nil?()
  3288.       @action     = act_set[0]
  3289.       @parameters = act_set[1]#.clone
  3290.       for i in 0...@parameters.size() ; @parameters[i] = @parameters[i].to_s() ; end
  3291.       act_result = -1
  3292.       case @action.upcase()
  3293.       # // action: action_name
  3294.       when "ACTION", "ACTIONLIST", "ACTION LIST", "ACTION_LIST"
  3295.         act_result = action_actionlist( @action, @parameters )
  3296.       when "ANIMATION"
  3297.         act_result = action_animation( @action, @parameters )
  3298.       when "COMMONEVENT", "COMMON_EVENT", "COMMON EVENT"  
  3299.         act_result = action_common_event( @action, @parameters )
  3300.       when "ATTACKEFFECT", "ATTACK_EFFECT", "ATTACK EFFECT"
  3301.         act_result = action_effect( @action, @parameters )
  3302.       when "SKILLEFFECT", "SKILL_EFFECT", "SKILL EFFECT"
  3303.         act_result = action_effect( @action, @parameters )
  3304.       when "ITEMEFFECT", "ITEM_EFFECT", "ITEM EFFECT"  
  3305.         act_result = action_effect( @action, @parameters )
  3306.       when "OBJEFFECT", "OBJ_EFFECT", "OBJ EFFECT"    
  3307.         eff = @skill_id > 0 ? "SKILL_EFFECT" : nil
  3308.         eff = @item_id > 0 ? "ITEM_EFFECT" : "" if eff.nil?()
  3309.         act_result = action_effect( eff, @parameters+["PRESET"] )
  3310.       when "CHARGE", "COOLDOWN"  
  3311.         act_result = action_charge( @action, @parameters )
  3312.       when "RANGE"  
  3313.         act_result = action_range( @action, @parameters )
  3314.       when "TARGET"  
  3315.         action_target( @action, @parameters )
  3316.         act_result = 0
  3317.       when "SUBTARGET"
  3318.         act_result = action_subtargets( @action, @parameters )  
  3319.       when "TARGET_SELECT", "TARGET SELECT", "TARGETSELECT"
  3320.         act_result = action_target_select( @action, @parameters )
  3321.       when "SET_ORIGIN", "SET ORIGIN", "SETORIGIN"
  3322.         act_result = action_origin( @action, @parameters )
  3323.       when "MOVE"  
  3324.         act_result = action_move( @action, @parameters )
  3325.       when "JUMP"  
  3326.         act_result = action_jump( @action, @parameters )  
  3327.       when "SETITEM", "SET_ITEM", "SET ITEM"  
  3328.         act_result = action_set_item( @action, @parameters )
  3329.       when "SETSKILL", "SET_SKILL", "SET SKILL"  
  3330.         act_result = action_set_skill( @action, @parameters )
  3331.       when "PROJECTILE"  
  3332.         act_result = action_projectile( @action, @parameters )
  3333.       when "SCRIPT"  
  3334.         act_result = action_script( @action, @parameters )
  3335.       when "THROUGH"  
  3336.         act_result = action_through( @action, @parameters )
  3337.       when "PARENTWAIT", "PARENT_WAIT", "PARENT WAIT"  
  3338.         act_result = action_parent_wait( @action, @parameters )
  3339.       when "WAIT", "WAIT_FOR_EVENT", "WAIT FOR ANIMATION"
  3340.         act_result = action_wait( @action, @parameters )
  3341.       else
  3342.         act_result = extended_actions( @action, @parameters )
  3343.       end
  3344.       if act_result == -1
  3345.         puts "ERROR: -1 returned for action #{self}"
  3346.       else
  3347.         puts "BING: #{act_result} returned for action #{self}"
  3348.       end if YGG.debug_mode?
  3349.       @list_index += 1
  3350.       break if act_result == 1
  3351.     end
  3352.   end
  3353.  
  3354.   #--------------------------------------------------------------------------#
  3355.   # * new-method :extended_actions
  3356.   #--------------------------------------------------------------------------#  
  3357.   def extended_actions( action, parameters )
  3358.   end
  3359.  
  3360.   #--------------------------------------------------------------------------#
  3361.   # * new-method :action_set_skill
  3362.   #--------------------------------------------------------------------------#  
  3363.   def action_set_skill( action, parameters )
  3364.     @skill_id = parameters[0].to_i
  3365.     return 0
  3366.   end  
  3367.  
  3368.   #--------------------------------------------------------------------------#
  3369.   # * new-method :action_set_item
  3370.   #--------------------------------------------------------------------------#  
  3371.   def action_set_item( action, parameters )
  3372.     @item_id = parameters[0].to_i
  3373.     return 0
  3374.   end  
  3375.  
  3376.   #--------------------------------------------------------------------------#
  3377.   # * new-method :action_actionlist
  3378.   #--------------------------------------------------------------------------#  
  3379.   def action_actionlist( action, parameters )
  3380.     @active_list = @active_list.slice(0, @list_index) +
  3381.       ::YGG.get_action_list( parameters[0] ) +
  3382.       @active_list.slice( @list_index, @active_list.size )
  3383.     return 0
  3384.   end  
  3385.  
  3386.   #--------------------------------------------------------------------------#
  3387.   # * new-method :action_animation
  3388.   #--------------------------------------------------------------------------#              
  3389.   def action_animation( action, parameters )
  3390.     p0 = parameters[0].upcase()
  3391.     p1 = parameters[1].upcase()
  3392.     p2 = parameters[2].upcase()
  3393.    
  3394.     id = 0
  3395.     case p0
  3396.     when "OBJ"
  3397.       id = $data_skills[@skill_id].animation_id if @skill_id > 0
  3398.       id = $data_items[@item_id].animation_id    if @item_id > 0
  3399.       id = @user_event.ygg_battler.atk_animation_id() if id == -1
  3400.     when "ATK", "ATTACK"  
  3401.       id = @user_event.ygg_battler.atk_animation_id()
  3402.     else
  3403.       id = p0.to_i
  3404.     end  
  3405.    
  3406.     case p1  
  3407.     when "POS"  
  3408.       event = @user_event
  3409.       x, y = *YGG.offset_xy(
  3410.        event.x, event.y,
  3411.        [parameters[3].to_i(), parameters[4].to_i()],
  3412.        event.direction )
  3413.       targets = action_target( "TARGET", ["MAP_XY", x, y], true )
  3414.       case p2
  3415.       when "NORMAL"
  3416.         targets.each { |t| t.animation_id = id }
  3417.       when "WILD"    
  3418.         $scene.push_ygg_anim( id, x, y, targets, false ) if $scene.is_a?( Scene_Map )
  3419.       end
  3420.     else
  3421.       action_target( "TARGET", [p1] ).each { |t|
  3422.         case p2
  3423.         when "NORMAL" ; t.animation_id = id
  3424.         when "WILD"   ; t.ygg_anims << id
  3425.         end
  3426.       }  
  3427.     end
  3428.     return 0
  3429.   end
  3430.  
  3431.   #--------------------------------------------------------------------------#
  3432.   # * new-method :action_origin
  3433.   #--------------------------------------------------------------------------#  
  3434.   def action_origin( action, parameters )
  3435.     action_target( "TARGET", parameters, true ).each { |character|
  3436.       character.set_orgin() }
  3437.   end  
  3438.    
  3439.   #--------------------------------------------------------------------------#
  3440.   # * new-method :action_move
  3441.   #--------------------------------------------------------------------------#    
  3442.   def action_move( action, parameters )
  3443.     targets = action_target( "TARGET", [parameters[0]], true )
  3444.     targets.each { |character|
  3445.       case parameters[1].upcase
  3446.       when "FORWARD"
  3447.         character.move_forward()
  3448.       when "BACKWARD"
  3449.         character.move_backward()  
  3450.       when "UP"
  3451.         character.move_up()
  3452.       when "DOWN"
  3453.         character.move_down()
  3454.       when "LEFT"
  3455.         character.move_left()
  3456.       when "RIGHT"
  3457.         character.move_right()
  3458.       when "TO"  
  3459.         case parameters[2]
  3460.         when "ORIGIN"
  3461.           character.moveto( character.origin.x, character.origin.y )
  3462.         else
  3463.           prms = parameters.slice( 2, parameters.size )
  3464.           action_targets( "TARGET", prms, true ).each { |target|
  3465.             character.moveto( target.x, target.y )
  3466.           }
  3467.         end  
  3468.       when "TOXY", "TO_XY", "TO XY"  
  3469.         dist, sway = parameters[2], parameters[3]
  3470.         case character.direction
  3471.         when 2 # // Down
  3472.           x, y = character.x+sway, character.y+dist
  3473.         when 4 # // Left
  3474.           x, y = character.x-dist, character.y+sway
  3475.         when 6 # // Right
  3476.           x, y = character.x+dist, character.y-sway
  3477.         when 8 # // Up
  3478.           x, y = character.x-sway, character.y-dist
  3479.         end
  3480.         character.moveto( x, y )
  3481.       when "TOMAPXY", "TO_MAP_XY", "TO MAP XY"  
  3482.         character.moveto( parameters[2].to_i, parameters[3].to_i )
  3483.       when "TURNUP", "TURN_UP", "TURN UP"
  3484.         character.turn_up()
  3485.       when "TURNDOWN", "TURN_DOWN", "TURN DOWN"
  3486.         character.turn_down()
  3487.       when "TURNLEFT", "TURN_LEFT", "TURN LEFT"
  3488.         character.turn_left()
  3489.       when "TURNRIGHT", "TURN_RIGHT", "TURN RIGHT"
  3490.         character.turn_right()
  3491.       when "TURNRIGHT90", "TURN_RIGHT_90", "TURN RIGHT 90"
  3492.         character.turn_right_90()
  3493.       when "TURNLEFT90", "TURN_LEFT_90", "TURN LEFT 90"
  3494.         character.turn_left_90()  
  3495.       when "TURN180", "TURN_180", "TURN 180"
  3496.         character.turn_180()
  3497.       when "TURNTO", "TURN_TO", "TURN TO"
  3498.         prms = parameters.slice( 2, parameters.size )
  3499.         action_targets( "TARGET", prms, true ).each { |target|
  3500.           character.turn_to_coord( target.x, target.y ) }
  3501.       end
  3502.     }  
  3503.     return 0
  3504.   end
  3505.  
  3506.   #--------------------------------------------------------------------------#
  3507.   # * new-method :action_jump
  3508.   #--------------------------------------------------------------------------#    
  3509.   def action_jump( action, parameters )  
  3510.     users = action_target( "TARGET", parameters[0], true )
  3511.     users.each { |character|
  3512.       case parameters[1].upcase
  3513.       when "XY"
  3514.         character.jump( parameters[2].to_i, parameters[3].to_i )
  3515.       else
  3516.         action_target( "TARGET", parameters[1], true ).each { |t|
  3517.           character.jump_to_char( t )
  3518.         }
  3519.       end  
  3520.     }
  3521.     return 0
  3522.   end
  3523.  
  3524.   #--------------------------------------------------------------------------#
  3525.   # * new-method :action_charge
  3526.   #--------------------------------------------------------------------------#    
  3527.   def action_charge( action, parameters )
  3528.     targets = action_target( "TARGET", parameters[0], true )
  3529.     value = parameters[2].upcase == "MAX" ? t.ygg_battler.cooldown_max : parameters[2].to_i
  3530.     case parameters[1].upcase
  3531.     when "ADD"
  3532.       targets.each { |t| t.ygg_battler.cooldown += value }
  3533.     when "SUB"  
  3534.       targets.each { |t| t.ygg_battler.cooldown -= value }
  3535.     when "SET"  
  3536.       targets.each { |t| t.ygg_battler.cooldown  = value }
  3537.     end  
  3538.     return 0
  3539.   end
  3540.  
  3541.   #--------------------------------------------------------------------------#
  3542.   # * new-method :action_common_event
  3543.   #--------------------------------------------------------------------------#  
  3544.   def action_common_event( action, parameters )
  3545.     case parameters[0].upcase
  3546.     when "SKILL"
  3547.       common_event_id = $data_skills[parameters[1].to_i].common_event_id
  3548.     when "ITEM"  
  3549.       common_event_id = $data_items[parameters[1].to_i].common_event_id
  3550.     when "OBJ"  
  3551.       if @skill_id > 0
  3552.         action_common_event( "COMMON_EVENT", ["SKILL", @skill_id, parameters[2]] )
  3553.       elsif @item_id > 0
  3554.         action_common_event( "COMMON_EVENT", ["ITEM", @item_id, parameters[2]] )
  3555.       end  
  3556.       return
  3557.     when "ID"  
  3558.       common_event_id = parameters[1].to_i
  3559.     end  
  3560.     @interpreter.setup( $data_common_events[common_event_id].list )
  3561.     @wait_for_comev = parameters[2].to_s.upcase == "WAIT"
  3562.     return @wait_for_comev ? 1 : 0
  3563.   end
  3564.  
  3565.   #--------------------------------------------------------------------------#
  3566.   # * new-method :action_range
  3567.   #--------------------------------------------------------------------------#      
  3568.   def action_range( action, parameters )
  3569.     case parameters[0].upcase
  3570.     when "ADD"
  3571.       @range << [ parameters[1].to_i, parameters[2].to_i ]
  3572.     when "SUB"  
  3573.       @range -= [[ parameters[1].to_i, parameters[2].to_i ]]
  3574.     when "CLEAR"  
  3575.       @range.clear()
  3576.     when "CREATE"  
  3577.       rng, minrng, type = parameters[1].to_i, parameters[2].to_i, parameters[3].to_i
  3578.       target = action_target( "TARGET", [parameters[4]], true )[0]
  3579.       direction = target.nil?() ? parameters[4].to_i : target.direction
  3580.       @range = YGG.create_range_data( rng, minrng, type, direction )
  3581.     end  
  3582.     return 0
  3583.   end  
  3584.  
  3585.   #--------------------------------------------------------------------------#
  3586.   # * new-method :action_target
  3587.   #--------------------------------------------------------------------------#          
  3588.   def action_target( action, parameters, return_only=false )
  3589.     raise "Parameter is not an array" unless parameters.is_a?( Array )
  3590.     targets = []
  3591.     case parameters[0].upcase()
  3592.     when "PARENT"
  3593.       targets = [ @parent_event ]
  3594.     when "USER"
  3595.       targets = [ @user_event ]
  3596.     when "TARGET"  
  3597.       targets = [ @target_events[0] ]
  3598.     when "TARGETS"  
  3599.       targets = @target_events
  3600.     when "ALLIES"  
  3601.       targets = @target_events.inject([]) { |r, e| r << e if @user_event.ally_character?( e ) ; r }
  3602.     when "ENEMIES"  
  3603.       targets = @target_events.inject([]) { |r, e| r << e if @user_event.enemy_character?( e ) ; r }
  3604.     when "RANDTARGET"  
  3605.       targets = action_target( "TARGET", ["TARGETS"], true )
  3606.       targets = [targets[rand(targets.size)]]
  3607.     when "RANDALLY"  
  3608.       targets = action_target( "TARGET", ["ALLIES"], true )
  3609.       targets = [targets[rand(targets.size)]]  
  3610.     when "RANDENEMY"  
  3611.       targets = action_target( "TARGET", ["ENEMIES"], true )
  3612.       targets = [targets[rand(targets.size)]]    
  3613.     when "SCREEN", "ONSCREEN", "ON_SCREEN"  
  3614.       $game_yggdrasil.battlers.each { |ev|
  3615.         targets << ev if ev.limitedOnScreen?()
  3616.       }
  3617.     when "OFFSCREEN", "OFF_SCREEN"  
  3618.       $game_yggdrasil.battlers.each { |ev|
  3619.         targets << ev if !ev.limitedOnScreen?()
  3620.       }
  3621.     when "MAP_XY"
  3622.       xy_list = [ [parameters[1].to_i, parameters[2].to_i] ]
  3623.       targets = @user_event.get_target_events( xy_list )
  3624.     when "XY"  
  3625.       xy_list = [ [parameters[1].to_i, parameters[2].to_i] ]
  3626.       xy_list = YGG::offset_xy_list( @user_event.x, @user_event.y, xy_list, @user_event.direction )
  3627.       targets = @user_event.get_target_events( xy_list )
  3628.     when "RANGE"  
  3629.       xy_list = @range
  3630.       xy_list = YGG::offset_xy_list( @user_event.x, @user_event.y, xy_list, @user_event.direction )
  3631.       targets = @user_event.get_target_events( xy_list )
  3632.     end
  3633.     targets = targets.compact.uniq
  3634.     @target_events = targets unless return_only
  3635.     return targets
  3636.   end
  3637.  
  3638.   #--------------------------------------------------------------------------#
  3639.   # * new-method :action_subtargets
  3640.   #--------------------------------------------------------------------------#  
  3641.   def action_subtargets( action, parameters )
  3642.     @target_events -= action_target( "TARGET", parameters, true )
  3643.     return 0
  3644.   end
  3645.  
  3646.   #--------------------------------------------------------------------------#
  3647.   # * new-method :action_target_select
  3648.   #--------------------------------------------------------------------------#  
  3649.   def action_target_select( action, parameters )
  3650.     if @parent_event.ai_operated?()
  3651.       targs = action_target( "TARGET", parameters.slice( 1, parameters.size ) ).sort_by { rand }
  3652.       result = [] ; for i in 0...parameters[0].to_i ; result << targs[i] ; end
  3653.       @target_events = result.compact.uniq
  3654.     else  
  3655.       @target_events = $game_yggdrasil.start_target_selection( parameters[0].to_i,
  3656.         action_target( "TARGET", parameters.slice( 1, parameters.size ), true ) )
  3657.     end    
  3658.     return 0
  3659.   end
  3660.  
  3661.   #--------------------------------------------------------------------------#
  3662.   # * new-method :action_effect
  3663.   #--------------------------------------------------------------------------#            
  3664.   def action_effect( action, parameters )
  3665.     users   = action_target( "TARGET", [parameters[0]], true )
  3666.     targets = action_target( "TARGET", [parameters[1]], true )
  3667.     case action.upcase()
  3668.     when "ATTACKEFFECT", "ATTACK_EFFECT", "ATTACK EFFECT"
  3669.       users.each { |user|
  3670.         user.equip_handle( 0 ).do_attack()
  3671.         $game_yggdrasil.action_attack( user, targets )
  3672.       }  
  3673.     when "SKILLEFFECT", "SKILL_EFFECT", "SKILL EFFECT"  
  3674.       users.each { |user|
  3675.         case parameters[2].upcase()
  3676.         when "PRESET", "OBJ"
  3677.           sid = @skill_id
  3678.         else ; sid = parameters[2].to_i
  3679.         end  
  3680.         $game_yggdrasil.action_skill( user, targets, $data_skills[sid] )
  3681.       }  
  3682.     when "ITEMEFFECT", "ITEM_EFFECT", "ITEM EFFECT"  
  3683.       users.each { |user|
  3684.         case parameters[2].upcase()
  3685.         when "PRESET", "OBJ"
  3686.           iid = @item_id
  3687.         else ; iid = parameters[2].to_i
  3688.         end  
  3689.         $game_yggdrasil.action_item( user, targets, $data_items[iid] )
  3690.       }  
  3691.     end  
  3692.     return 0
  3693.   end
  3694.  
  3695.   #--------------------------------------------------------------------------#
  3696.   # * new-method :action_projectile
  3697.   #--------------------------------------------------------------------------#                  
  3698.   def action_projectile( action, parameters )
  3699.     users = action_target( "TARGET", [parameters[0]], true )
  3700.     case parameters[1].upcase
  3701.     when "PARENT"
  3702.       direction = action_target( "TARGET", ["PARENT"], true )[0].direction
  3703.     when "USER"
  3704.       direction = action_target( "TARGET", ["USER"], true )[0].direction
  3705.     when "TARGET"  
  3706.       direction = action_target( "TARGET", ["TARGET"], true )[0].direction
  3707.     else  
  3708.       direction = parameters[1].to_i
  3709.     end  
  3710.     projectile = ::YGG::PROJECTILE_MAP[parameters[2].to_s]
  3711.     setup_code = ::YGG::PROJETILE_SETUP[parameters[3].to_s]
  3712.     users.each { |user|
  3713.       pro = projectile.new( user, setup_code )
  3714.       pro.moveto( user.x, user.y ) ; pro.set_direction( direction )
  3715.       $game_yggdrasil.add_projectile( pro )
  3716.     }  
  3717.     return 0
  3718.   end
  3719.  
  3720.   #--------------------------------------------------------------------------#
  3721.   # * new-method :action_script
  3722.   #--------------------------------------------------------------------------#                  
  3723.   def action_script( action, parameters )
  3724.     user    = action_target( "TARGET", ["USER"] )
  3725.     target  = action_target( "TARGET", ["TARGET"] )
  3726.     targets = action_target( "TARGET", ["TARGETS"] )
  3727.     eval( parameters.to_s )
  3728.     return 0
  3729.   end
  3730.  
  3731.   #--------------------------------------------------------------------------#
  3732.   # * new-method :action_through
  3733.   #--------------------------------------------------------------------------#                  
  3734.   def action_through( action, parameters )
  3735.     targets = action_target( "TARGET", [parameters[0]] )
  3736.     case parameters[1].upcase
  3737.     when "TRUE", "ON", "YES"
  3738.       targets.each { |t| t.set_through( true ) }
  3739.     when "FALSE", "OFF", "NO"
  3740.       targets.each { |t| t.set_through( false ) }
  3741.     end
  3742.     return 0
  3743.   end
  3744.  
  3745.   #--------------------------------------------------------------------------#
  3746.   # * new-method :action_parent_wait
  3747.   #--------------------------------------------------------------------------#                  
  3748.   def action_parent_wait( action, parameters )
  3749.     @user_event.wait_count = parameters[0].to_i
  3750.   end
  3751.  
  3752.   #--------------------------------------------------------------------------#
  3753.   # * new-method :action_wait
  3754.   #--------------------------------------------------------------------------#                  
  3755.   def action_wait( action, parameters )
  3756.     case action.upcase
  3757.     when "WAIT FOR ANIMATION"
  3758.       @wait_count = $data_animations[parameters[0].to_i].frame_max * ::Sprite_Base::RATE
  3759.     when "WAIT"
  3760.       @wait_count = parameters[0].to_i
  3761.     end  
  3762.     return 1
  3763.   end
  3764.  
  3765. end  
  3766.  
  3767. # // (YGG_MC) - Mix Code
  3768. #==============================================================================#
  3769. # // RMVX Mixins
  3770. #==============================================================================#
  3771. # ** RPG::Animation
  3772. #==============================================================================#
  3773. class RPG::Animation
  3774.  
  3775.   #----------------------------------------------------------------------------#
  3776.   # * new-method :cell_count
  3777.   #----------------------------------------------------------------------------#
  3778.   def cell_count() ; end unless method_defined? :cell_count
  3779.    
  3780. end  
  3781.  
  3782. #==============================================================================#
  3783. # ** RPG::BaseItem
  3784. #==============================================================================#
  3785. class RPG::BaseItem
  3786.  
  3787.   include YGG::Caches1x6
  3788.  
  3789.   #----------------------------------------------------------------------------#
  3790.   # * Public Instance Variable(s)
  3791.   #----------------------------------------------------------------------------#
  3792.   attr_accessor :pickup_sfx
  3793.  
  3794.   #----------------------------------------------------------------------------#
  3795.   # * new-method :pickup_sfx
  3796.   #----------------------------------------------------------------------------#
  3797.   def pickup_sfx()
  3798.     @pickup_sfx ||= self.note =~ YGG::REGEXP::BASE_ITEM::PICKUP_SFX ?
  3799.       RPG::SE.new( $1, $2.to_i, $3.to_i ) : ::YGG::SOUND_ITEM
  3800.     return @pickup_sfx
  3801.   end
  3802.  
  3803.   #----------------------------------------------------------------------------#
  3804.   # * new-method :drops_attraction?
  3805.   #----------------------------------------------------------------------------#
  3806.   def drops_attraction?() ; return @drops_attraction ; end
  3807.  
  3808. end
  3809.  
  3810. #==============================================================================#
  3811. # ** RPG::UsableItem
  3812. #==============================================================================#
  3813. class RPG::UsableItem
  3814.  
  3815.   #----------------------------------------------------------------------------#
  3816.   # * super-method :yggdrasil_1x6_cache_start
  3817.   #----------------------------------------------------------------------------#
  3818.   def yggdrasil_1x6_cache_start()
  3819.     super()
  3820.     @__use_target_select = false
  3821.   end
  3822.  
  3823.   #----------------------------------------------------------------------------#
  3824.   # * super-method :yggdrasil_1x6_cache_check
  3825.   #----------------------------------------------------------------------------#  
  3826.   def yggdrasil_1x6_cache_check( line )
  3827.     super( line )
  3828.     case line
  3829.     when ::YGG::REGEXP::SKILL::UTARGET_SELECT
  3830.       @__use_target_select = true
  3831.     end  
  3832.   end
  3833.  
  3834.   #----------------------------------------------------------------------------#
  3835.   # * super-method :yggdrasil_1x6_cache_end
  3836.   #----------------------------------------------------------------------------#  
  3837.   def yggdrasil_1x6_cache_end()
  3838.     super()
  3839.     case @scope
  3840.     when 0     # // None
  3841.       @ygg_actions[0] ||= ::YGG.get_action_list( "NORMAL_OBJ0" ).clone
  3842.     when 11    # // User
  3843.       @ygg_actions[0] ||= ::YGG.get_action_list( "NORMAL_OBJ1" ).clone
  3844.     when 1     # // 1 Enemy
  3845.       @ygg_actions[0] ||= @__use_target_select ?
  3846.         ::YGG.get_action_list( "NORMAL_OBJ2_T1" ).clone :
  3847.         ::YGG.get_action_list( "NORMAL_OBJ2_1" ).clone
  3848.     when 3     # // 1 Enemy Dual
  3849.       @ygg_actions[0] ||= @__use_target_select ?
  3850.         ::YGG.get_action_list( "NORMAL_OBJ2_T2" ).clone :
  3851.         ::YGG.get_action_list( "NORMAL_OBJ2_2" ).clone
  3852.     when 4     # // 1 Random Enemy
  3853.       @ygg_actions[0] ||= ::YGG.get_action_list( "NORMAL_OBJ2_R1" ).clone
  3854.     when 5     # // 2 Random Enemies
  3855.       @ygg_actions[0] ||= ::YGG.get_action_list( "NORMAL_OBJ2_R2" ).clone
  3856.     when 6     # // 3 Random Enemies
  3857.       @ygg_actions[0] ||= ::YGG.get_action_list( "NORMAL_OBJ2_R3" ).clone  
  3858.     when 7, 9  # // 1 Ally
  3859.       @ygg_actions[0] ||= @__use_target_select ?
  3860.         ::YGG.get_action_list( "NORMAL_OBJ3_T1" ).clone :
  3861.         ::YGG.get_action_list( "NORMAL_OBJ3_1" ).clone
  3862.     when 2     # // All Enemies
  3863.       @ygg_actions[0] ||= ::YGG.get_action_list( "NORMAL_OBJ4" ).clone  
  3864.     when 8, 10 # // All Allies
  3865.       @ygg_actions[0] ||= ::YGG.get_action_list( "NORMAL_OBJ5" ).clone  
  3866.     end  
  3867.   end
  3868.  
  3869. end
  3870.  
  3871. #==============================================================================#
  3872. # ** RPG::Enemy
  3873. #==============================================================================#
  3874. class RPG::Enemy
  3875.  
  3876.   include YGG::Caches1x6
  3877.  
  3878.   #----------------------------------------------------------------------------#
  3879.   # * Public Instance Variable(s)
  3880.   #----------------------------------------------------------------------------#  
  3881.   attr_accessor :atk_animation_id
  3882.   attr_accessor :atk_animation_id2
  3883.   attr_accessor :drop_items
  3884.  
  3885.   #----------------------------------------------------------------------------#
  3886.   # * super-method :yggdrasil_1x6_cache_check
  3887.   #----------------------------------------------------------------------------#  
  3888.   def yggdrasil_1x6_cache_start()
  3889.     super()
  3890.     @drop_items ||= [] ; @__drop_id = -1
  3891.     @__drop = nil ; @__drop_reading = false
  3892.   end
  3893.  
  3894.   #----------------------------------------------------------------------------#
  3895.   # * super-method :yggdrasil_1x6_cache_check
  3896.   #----------------------------------------------------------------------------#  
  3897.   def yggdrasil_1x6_cache_check( line )
  3898.     super( line )
  3899.     case line
  3900.     when YGG::REGEXP::ENEMY::ATK_ANIMATION_ID
  3901.       @atk_animation_id = $1.to_i
  3902.     when YGG::REGEXP::ENEMY::DROP_ITEM2
  3903.       @drop_items[@__drop_id] = @__drop if @__drop_id > -1
  3904.       @__drop_id = -1 ; @__drop = nil ; @__drop_reading = false  
  3905.     when YGG::REGEXP::ENEMY::DROP_ITEM1
  3906.       @__drop_id = $1.to_i ; @__drop = DropItem.new() ; @__drop_reading = true    
  3907.     when YGG::REGEXP::ENEMY::DROP_CLEAR  
  3908.       @drop_items.clear()
  3909.     else
  3910.       if @__drop_reading
  3911.         case line
  3912.         # // Type of the drop item (0: none, 1: item, 2: weapon, 3: armor)
  3913.         when /kind:[ ](\d+)/i
  3914.           @__drop.kind = $1.to_i
  3915.         when /(?:item_id|item id|itemid):[ ](\d+)/i  
  3916.           @__drop.kind = 1 ; @__drop.item_id = $1.to_i
  3917.         when /(?:weapon_id|weapon id|weaponid):[ ](\d+)/i  
  3918.           @__drop.kind = 2 ; @__drop.weapon_id = $1.to_i
  3919.         when /(?:armor_id|armor id|armorid):[ ](\d+)/i    
  3920.           @__drop.kind = 3 ; @__drop.armor_id = $1.to_i
  3921.         when /(?:denom|denominator|prob|probability):[ ](\d+)/i  
  3922.           @__drop.denominator = $1.to_i
  3923.         end
  3924.       end  
  3925.     end  
  3926.   end
  3927.  
  3928.   #----------------------------------------------------------------------------#
  3929.   # * super-method :yggdrasil_1x6_cache_end
  3930.   #----------------------------------------------------------------------------#  
  3931.   def yggdrasil_1x6_cache_end()
  3932.     super()
  3933.     @atk_animation_id  ||= 1
  3934.     @atk_animation_id2 ||= 0
  3935.     @ygg_actions[0]    ||= ::YGG.get_action_list( "NORMAL_ATTACK_EN" ) # // Attack Action
  3936.     @ygg_actions[1]    ||= ::YGG.get_action_list( "GUARD_ACTION_EN" )  # // Guard Action
  3937.     @ygg_actions[2]    ||= ::YGG.get_action_list( "ESCAPE_ACTION_EN" ) # // Escape Action
  3938.     @ygg_actions[3]    ||= ::YGG.get_action_list( "WAIT_ACTION_EN" )   # // Wait Action
  3939.     @drop_items[1]     ||= @drop_item1
  3940.     @drop_items[2]     ||= @drop_item2
  3941.     # // Match Drop Items D: We dont want mismatch and chaos >:
  3942.     @drop_item1 = @drop_items[1]
  3943.     @drop_item2 = @drop_items[2]
  3944.   end
  3945.  
  3946. end  
  3947.  
  3948. #==============================================================================#
  3949. # ** RPG::State
  3950. #==============================================================================#
  3951. class RPG::State
  3952.  
  3953.   #--------------------------------------------------------------------------#
  3954.   # * Public Instance Variable(s)
  3955.   #--------------------------------------------------------------------------#  
  3956.   attr_accessor :hold_ticks
  3957.   attr_accessor :effect_tone
  3958.   attr_accessor :tone_effect
  3959.   attr_accessor :move_mod
  3960.  
  3961.   #----------------------------------------------------------------------------#
  3962.   # * new-method :yggdrasil_1x6_cache
  3963.   #----------------------------------------------------------------------------#  
  3964.   def yggdrasil_1x6_cache()
  3965.     yggdrasil_1x6_cache_start()
  3966.     self.note.split(/[\r\n]+/).each { |line| yggdrasil_1x6_cache_check( line ) }
  3967.     yggdrasil_1x6_cache_end()
  3968.   end
  3969.  
  3970.   #----------------------------------------------------------------------------#
  3971.   # * new-method :yggdrasil_1x6_cache_start
  3972.   #----------------------------------------------------------------------------#  
  3973.   def yggdrasil_1x6_cache_start()
  3974.     @hold_ticks  = self.hold_turn * ::YGG::STATE_TURN_COUNTER
  3975.     @move_mod    = 0
  3976.     @effect_tone = Tone.new( 0, 0, 0, 0 )
  3977.     @tone_effect = false
  3978.     @slip_freq   = ::YGG::SLIP_DAMAGE_FREQUENCY
  3979.   end
  3980.  
  3981.   #----------------------------------------------------------------------------#
  3982.   # * new-method :yggdrasil_1x6_cache_check
  3983.   #----------------------------------------------------------------------------#  
  3984.   def yggdrasil_1x6_cache_check( line )
  3985.     case line
  3986.     when ::YGG::REGEXP::STATE::HOLD_TICKS
  3987.       @hold_ticks = $1.to_i
  3988.     when ::YGG::REGEXP::STATE::TONE  
  3989.       @effect_tone = ::Tone.new( $1.to_i, $2.to_i, $3.to_i, $4.to_i )
  3990.       @tone_effect = true
  3991.     when ::YGG::REGEXP::STATE::MOVE_MOD  
  3992.       @move_mod = $1.to_i
  3993.     when ::YGG::REGEXP::STATE::SLIP_FREQ  
  3994.       @slip_freq = $1.to_i
  3995.     end  
  3996.   end
  3997.  
  3998.   #----------------------------------------------------------------------------#
  3999.   # * new-method :yggdrasil_1x6_cache_end
  4000.   #----------------------------------------------------------------------------#  
  4001.   def yggdrasil_1x6_cache_end()
  4002.   end
  4003.  
  4004.   #----------------------------------------------------------------------------#
  4005.   # * new-method :slip_freq
  4006.   #----------------------------------------------------------------------------#
  4007.   def slip_freq()
  4008.     return self.slip_damage ? @slip_freq : 0
  4009.   end
  4010.  
  4011. end
  4012.  
  4013. #==============================================================================#
  4014. # ** YGG::System ($game_yggdrasil)
  4015. #==============================================================================#
  4016. class YGG::System
  4017.  
  4018.   #--------------------------------------------------------------------------#
  4019.   # * Constants
  4020.   #--------------------------------------------------------------------------#
  4021.   ITEMS_MAPID = ::YGG::ITEM_MAP
  4022.  
  4023.   #--------------------------------------------------------------------------#
  4024.   # * Public Instance Variable(s)
  4025.   #--------------------------------------------------------------------------#
  4026.   attr_reader :projectiles
  4027.   attr_reader :new_projectiles
  4028.  
  4029.   attr_reader :new_poptexts
  4030.  
  4031.   attr_reader :active_ranges
  4032.   attr_reader :battlers
  4033.  
  4034.   #--------------------------------------------------------------------------#
  4035.   # * new-method :initialize
  4036.   #--------------------------------------------------------------------------#
  4037.   def initialize()
  4038.     setup_map( -1 )
  4039.   end
  4040.  
  4041.   #--------------------------------------------------------------------------#
  4042.   # * new-method :add_pop
  4043.   #--------------------------------------------------------------------------#
  4044.   def add_pop( poptext, x, y, z=1 )
  4045.     return unless ::YGG::USE_TEXT_POP
  4046.     pop = ::YGG::PopHandler.new( poptext, x, y, z )
  4047.     @pop_texts << pop
  4048.     @new_poptexts  << pop
  4049.     return pop
  4050.   end
  4051.  
  4052.   #--------------------------------------------------------------------------#
  4053.   # * new-method :remove_pop
  4054.   #--------------------------------------------------------------------------#  
  4055.   def remove_pop( pop_handler )
  4056.     pop_handler.force_complete!()
  4057.     @pop_texts.delete( pop_handler )
  4058.     @new_poptexts.delete( pop_handler )
  4059.     return pophandler
  4060.   end
  4061.  
  4062.   #--------------------------------------------------------------------------#
  4063.   # * new-method :add_projectile
  4064.   #--------------------------------------------------------------------------#  
  4065.   def add_projectile( projectile )
  4066.     @projectiles << projectile
  4067.     @new_projectiles << projectile
  4068.     projectile.registered = true
  4069.     return projectile
  4070.   end
  4071.  
  4072.   #--------------------------------------------------------------------------#
  4073.   # * new-method :remove_projectile
  4074.   #--------------------------------------------------------------------------#  
  4075.   def remove_projectile( projectile )
  4076.     @projectiles.delete( projectile )
  4077.     @new_projectiles.delete( projectile )
  4078.     projectile.registered = false
  4079.     projectile.force_terminate()
  4080.     return projectile
  4081.   end
  4082.  
  4083.   #--------------------------------------------------------------------------#
  4084.   # * new-method :add_battler
  4085.   #--------------------------------------------------------------------------#
  4086.   def add_battler( b ) ; @battlers |= [b] ; end
  4087.  
  4088.   #--------------------------------------------------------------------------#
  4089.   # * new-method :remove_battler
  4090.   #--------------------------------------------------------------------------#
  4091.   def remove_battler( b ) ; @battlers -= [b] ; end
  4092.    
  4093.   #--------------------------------------------------------------------------#
  4094.   # * new-method :update
  4095.   #--------------------------------------------------------------------------#
  4096.   def update()
  4097.     update_poptexts()
  4098.     update_drops()
  4099.     update_roam_events()
  4100.     update_projectiles()
  4101.   end
  4102.  
  4103.   #--------------------------------------------------------------------------#
  4104.   # * new-method :update_roam_events
  4105.   #--------------------------------------------------------------------------#
  4106.   def update_roam_events()
  4107.     @roam_events.each { |ev| ev.update() }
  4108.   end
  4109.  
  4110.   #--------------------------------------------------------------------------#
  4111.   # * new-method :update_projectiles
  4112.   #--------------------------------------------------------------------------#
  4113.   def update_projectiles()
  4114.     @projectiles = @projectiles.inject([]) { |result, pro|
  4115.       unless pro.terminated?() ; pro.update() ; result << pro  
  4116.       else ; @new_projectiles.delete( pro ) ; pro.registered = false ; end
  4117.       result
  4118.     } unless @projectiles.empty?()
  4119.   end
  4120.  
  4121.   #--------------------------------------------------------------------------#
  4122.   # * new-method :pop_texts
  4123.   #--------------------------------------------------------------------------#
  4124.   def update_poptexts()
  4125.     @pop_texts = @pop_texts.inject([]) { |result, pop|
  4126.       pop.update() ; result << pop unless pop.complete?() ; result
  4127.     } unless @pop_texts.empty?()
  4128.   end
  4129.  
  4130.   #--------------------------------------------------------------------------#
  4131.   # * new-method :pop_texts
  4132.   #--------------------------------------------------------------------------#
  4133.   def pop_texts() ; return @pop_texts ; end
  4134.  
  4135.   #--------------------------------------------------------------------------#
  4136.   # * new-method :battlers_xy
  4137.   #--------------------------------------------------------------------------#
  4138.   def battlers_xy( x, y )
  4139.     return @battlers.inject([]) { |result, b| result << b if b.pos?( x, y ) ; result }
  4140.   end
  4141.  
  4142.   #--------------------------------------------------------------------------#
  4143.   # * new-method :battlers_range
  4144.   #--------------------------------------------------------------------------#  
  4145.   def battlers_range( x1, y1, x2, y2 )
  4146.     return @battlers.inject([]) { |result, b|
  4147.       result << b if b.x.between?( x1, x2 ) && b.y.between?( y1, y2 ) ; result }
  4148.   end
  4149.  
  4150.   #--------------------------------------------------------------------------#
  4151.   # * new-method :on?
  4152.   #--------------------------------------------------------------------------#  
  4153.   if ::YGG::ABS_SYSTEM_SWITCH.nil?()
  4154.     def on?() ; return true ; end
  4155.   else
  4156.     def on?() ; return $game_switches[::YGG::ABS_SYSTEM_SWITCH] ; end  
  4157.   end  
  4158.  
  4159.   #--------------------------------------------------------------------------#
  4160.   # * new-method :setup_map
  4161.   #--------------------------------------------------------------------------#
  4162.   def setup_map( map_id )
  4163.     @map_id          = map_id
  4164.     @pop_texts     ||= [] ; @pop_texts.clear()
  4165.     @new_poptexts  ||= [] ; @new_poptexts.clear()
  4166.     @battlers      ||= [] ; @battlers.each { |b| b.ygg_unregister() } ; @battlers.clear()  
  4167.     @active_drops  ||= [] ; @active_drops.clear()
  4168.     @active_ranges ||= [] ; @active_ranges.clear()
  4169.     @projectiles   ||= [] ; @projectiles.clear()  
  4170.     @new_projectiles||=[] ; @new_projectiles.clear()
  4171.     @roam_events   ||= [] ; @roam_events.clear()
  4172.   end  
  4173.  
  4174.   #--------------------------------------------------------------------------#
  4175.   # * new-method :get_map
  4176.   #--------------------------------------------------------------------------#  
  4177.   def get_map( map_id )
  4178.     $game_map.get_map( map_id )
  4179.   end
  4180.  
  4181.   #--------------------------------------------------------------------------#
  4182.   # * new-method :setup_itemmap
  4183.   #--------------------------------------------------------------------------#
  4184.   def setup_itemmap()
  4185.     if $items_map.nil?()
  4186.       $items_map = get_map( ITEMS_MAPID )
  4187.       $items_map.events.values.each { |ev| ev.pages.each { |pg|
  4188.         pg.list = YGG.parse_event_list( pg.list ) } }
  4189.     end  
  4190.   end
  4191.  
  4192.   #--------------------------------------------------------------------------#
  4193.   # * new-method :create_drops
  4194.   #--------------------------------------------------------------------------#
  4195.   def create_drops( x, y, dropee )
  4196.     place_drops( x, y, dropee.items, dropee.gold )
  4197.   end  
  4198.  
  4199.   #--------------------------------------------------------------------------#
  4200.   # * new-method :place_drops
  4201.   #--------------------------------------------------------------------------#
  4202.   def place_drops( x, y, item_set, gold = nil )
  4203.     drops = []  
  4204.     for dr in item_set.compact
  4205.       cc = YGG::Drop_Character.new( dr, YGG::ITEM_FADE_TIME )
  4206.       fail_count = 0
  4207.       dx, dy = x, y
  4208.       loop do
  4209.         x_r = rand(YGG::DROP_SCATTER_DISTANCE)
  4210.         y_r = rand(YGG::DROP_SCATTER_DISTANCE)
  4211.         x_r = -x_r if rand(2) == 0
  4212.         y_r = -y_r if rand(2) == 0
  4213.         dx = x + x_r
  4214.         dy = y + y_r
  4215.         if fail_count > 20 ; break dx, dy = x, y ; end
  4216.         break if $game_map.passable?( dx, dy )
  4217.         fail_count += 1
  4218.       end  
  4219.       cc.moveto( dx, dy )
  4220.       drops.push( cc )
  4221.     end
  4222.     unless gold.nil?() || gold.eql?( 0 )
  4223.       cc = YGG::Drop_Character.new( YGG::Containers::GoldItem.new( gold ), YGG::GOLD_FADE_TIME )
  4224.       cc.moveto( x, y )
  4225.       drops.push( cc )
  4226.     end
  4227.     drops.each { |char|
  4228.       @active_drops.push( char ) ;
  4229.       $scene.spriteset.add_drop_sprite( char ) if $scene.is_a?( Scene_Map )
  4230.     }
  4231.     return drops
  4232.   end
  4233.  
  4234.   #--------------------------------------------------------------------------#
  4235.   # * new-method :items_map
  4236.   #--------------------------------------------------------------------------#
  4237.   def items_map() ; return $items_map ; end
  4238.  
  4239.   #--------------------------------------------------------------------------#
  4240.   # * alias-method :update_drops
  4241.   #--------------------------------------------------------------------------#
  4242.   def update_drops()
  4243.     @active_drops = @active_drops.inject([]) { |result, dr| dr.update()
  4244.       result.push( dr ) unless dr.timeout?() ; result } unless @active_drops.empty?()
  4245.   end
  4246.  
  4247.   #--------------------------------------------------------------------------#
  4248.   # * new-method :active_drops
  4249.   #--------------------------------------------------------------------------#
  4250.   def active_drops() ; return @active_drops ; end
  4251.  
  4252.   #--------------------------------------------------------------------------#
  4253.   # * new-method :drops_xy
  4254.   #--------------------------------------------------------------------------#  
  4255.   def drops_xy( x, y )
  4256.     return self.active_drops.inject([]) { |result, dr|
  4257.       result.push(dr) if dr.pos?(x, y) ; result }
  4258.   end
  4259.  
  4260. end
  4261.  
  4262. #==============================================================================#
  4263. # // Start Yggdrasil MixIn Code  
  4264. #==============================================================================#
  4265. YGG::Containers::Drops = Struct.new( :items, :gold )
  4266. #==============================================================================#
  4267. # ** YGG::MixIns::Actor
  4268. #==============================================================================#
  4269. module YGG::MixIns::Actor
  4270.  
  4271.   #--------------------------------------------------------------------------#
  4272.   # * new-method :create_drops_object
  4273.   #--------------------------------------------------------------------------#  
  4274.   def create_drops_object()
  4275.     return ::YGG::Containers::Drops.new( [], 0 )
  4276.   end
  4277.  
  4278. end
  4279.  
  4280. #==============================================================================#
  4281. # ** YGG::MixIns::Enemy
  4282. #==============================================================================#
  4283. module YGG::MixIns::Enemy
  4284.  
  4285.   #--------------------------------------------------------------------------#
  4286.   # * new-method :create_drops_object
  4287.   #--------------------------------------------------------------------------#  
  4288.   def create_drops_object()
  4289.     return ::YGG::Containers::Drops.new( self.all_drops, self.gold )
  4290.   end
  4291.  
  4292. end
  4293.  
  4294. #==============================================================================#
  4295. # ** YGG::MixIns::Movement
  4296. #==============================================================================#
  4297. module YGG::MixIns::Movement
  4298.  
  4299.   #--------------------------------------------------------------------------#
  4300.   # * new-method :distance_from
  4301.   #--------------------------------------------------------------------------#
  4302.   def distance_from( obj )
  4303.     return (obj.x - self.x).abs + (obj.y - self.y).abs
  4304.   end
  4305.  
  4306.   #--------------------------------------------------------------------------#
  4307.   # * Jump to XY
  4308.   #--------------------------------------------------------------------------#  
  4309.   def jump_to_xy( tx, ty )
  4310.     jump( tx-self.x, ty-self.y )
  4311.   end
  4312.  
  4313.   #--------------------------------------------------------------------------#
  4314.   # * Jump to Character
  4315.   #--------------------------------------------------------------------------#  
  4316.   def jump_to_char( char )
  4317.     jump_to_xy( char.x, char.y )
  4318.   end
  4319.  
  4320.   #--------------------------------------------------------------------------#
  4321.   # * Jump to Event
  4322.   #--------------------------------------------------------------------------#  
  4323.   def jump_to_event( event_id )
  4324.     jump_to_char( $game_map.events[event_id] )
  4325.   end
  4326.  
  4327.   #--------------------------------------------------------------------------#
  4328.   # * new-method :jump_forward
  4329.   #--------------------------------------------------------------------------#
  4330.   def jump_forward( amount, offset )
  4331.     case direction
  4332.     when 2
  4333.       jump( offset, amount )
  4334.     when 4
  4335.       jump( -amount, offset )
  4336.     when 6
  4337.       jump( amount, -offset )
  4338.     when 8
  4339.       jump( -offset, -amount )
  4340.     end  
  4341.   end
  4342.  
  4343.   #--------------------------------------------------------------------------#
  4344.   # * new-method :jump_backward
  4345.   #--------------------------------------------------------------------------#
  4346.   def jump_backward( amount, offset )
  4347.     jump_forward( -amount, -offset )
  4348.   end
  4349.  
  4350.   #--------------------------------------------------------------------------#
  4351.   # * new-method :distance_x_from_tx
  4352.   #--------------------------------------------------------------------------#
  4353.   def distance_x_from_tx( tx )
  4354.     sx = @x - tx
  4355.     if $game_map.loop_horizontal?         # When looping horizontally
  4356.       if sx.abs > $game_map.width / 2     # Larger than half the map width?
  4357.         sx -= $game_map.width             # Subtract map width
  4358.       end
  4359.     end
  4360.     return sx
  4361.   end
  4362.  
  4363.   #--------------------------------------------------------------------------#
  4364.   # * new-method :distance_y_from_ty
  4365.   #--------------------------------------------------------------------------#
  4366.   def distance_y_from_ty( ty )
  4367.     sy = @y - ty
  4368.     if $game_map.loop_vertical?           # When looping vertically
  4369.       if sy.abs > $game_map.height / 2    # Larger than half the map height?
  4370.         sy -= $game_map.height            # Subtract map height
  4371.       end
  4372.     end
  4373.     return sy
  4374.   end
  4375.  
  4376.   #--------------------------------------------------------------------------#
  4377.   # * new-method :move_toward_xy
  4378.   #--------------------------------------------------------------------------#
  4379.   def move_toward_xy( x, y )
  4380.     move_8d = false
  4381.     sx = distance_x_from_tx(x)
  4382.     sy = distance_y_from_ty(y)
  4383.     if move_8d
  4384.       # // Need to work on it
  4385.     else  
  4386.       if sx != 0 or sy != 0
  4387.         if sx.abs > sy.abs                  # Horizontal distance is longer
  4388.           sx > 0 ? move_left : move_right   # Prioritize left-right
  4389.           if @move_failed and sy != 0
  4390.             sy > 0 ? move_up : move_down
  4391.           end
  4392.         else                                # Vertical distance is longer
  4393.           sy > 0 ? move_up : move_down      # Prioritize up-down
  4394.           if @move_failed and sx != 0
  4395.             sx > 0 ? move_left : move_right
  4396.           end
  4397.         end
  4398.       end
  4399.     end  
  4400.   end
  4401.  
  4402.   #--------------------------------------------------------------------------#
  4403.   # * new-method :move_away_from_xy
  4404.   #--------------------------------------------------------------------------#
  4405.   def move_away_from_xy( x, y )
  4406.     move_8d = false
  4407.     sx = distance_x_from_tx(x)
  4408.     sy = distance_y_from_ty(y)
  4409.     if move_8d
  4410.       # // Need to work on it
  4411.     else  
  4412.       if sx != 0 or sy != 0
  4413.         if sx.abs > sy.abs                  # Horizontal distance is longer
  4414.           sx > 0 ? move_right : move_left   # Prioritize left-right
  4415.           if @move_failed and sy != 0
  4416.             sy > 0 ? move_down : move_up
  4417.           end
  4418.         else                                # Vertical distance is longer
  4419.           sy > 0 ? move_down : move_up      # Prioritize up-down
  4420.           if @move_failed and sx != 0
  4421.             sx > 0 ? move_right : move_left
  4422.           end
  4423.         end
  4424.       end
  4425.     end  
  4426.   end
  4427.  
  4428.   #--------------------------------------------------------------------------#
  4429.   # * new-method :move_toward_char
  4430.   #--------------------------------------------------------------------------#
  4431.   def move_toward_char( char )
  4432.     move_toward_xy( char.x, char.y )
  4433.   end
  4434.  
  4435.   #--------------------------------------------------------------------------#
  4436.   # * new-method :move_away_from_xy
  4437.   #--------------------------------------------------------------------------#
  4438.   def move_away_from_char( char )
  4439.     move_away_from_xy( char.x, char.y )
  4440.   end
  4441.  
  4442.   #--------------------------------------------------------------------------#
  4443.   # * new-method :move_toward_event
  4444.   #--------------------------------------------------------------------------#
  4445.   def move_toward_event( event_id )
  4446.     move_toward_char( $game_map.events[event_id] )
  4447.   end  
  4448.  
  4449.   #--------------------------------------------------------------------------#
  4450.   # * new-method :move_away_from_event
  4451.   #--------------------------------------------------------------------------#
  4452.   def move_away_from_event( event_id )
  4453.     move_away_from_char( $game_map.events[event_id] )
  4454.   end
  4455.  
  4456.   #--------------------------------------------------------------------------#
  4457.   # * new-method :thrust_wait
  4458.   #--------------------------------------------------------------------------#
  4459.   def thrust_wait( t=30 ) ; @wait_count = t ; end
  4460.  
  4461.   #--------------------------------------------------------------------------#
  4462.   # * new-method :half_down
  4463.   #--------------------------------------------------------------------------#
  4464.   def half_down( turn_ok=true )
  4465.     turn_down if turn_ok
  4466.     @y = $game_map.round_y(@y + 0.5)
  4467.     @real_y = ((@y - 0.5)*256)
  4468.     @move_failed = false
  4469.   end
  4470.  
  4471.   #--------------------------------------------------------------------------#
  4472.   # * new-method :half_left
  4473.   #--------------------------------------------------------------------------#
  4474.   def half_left( turn_ok=true )
  4475.     turn_left if turn_ok
  4476.     @x = $game_map.round_x(@x-0.5)
  4477.     @real_x = ((@x+0.5)*256)
  4478.     @move_failed = false
  4479.   end
  4480.  
  4481.   #--------------------------------------------------------------------------#
  4482.   # * new-method :half_right
  4483.   #--------------------------------------------------------------------------#
  4484.   def half_right( turn_ok=true )
  4485.     turn_right if turn_ok
  4486.     @x = $game_map.round_x(@x+0.5)
  4487.     @real_x = ((@x-0.5)*256)
  4488.     @move_failed = false
  4489.   end
  4490.  
  4491.   #--------------------------------------------------------------------------#
  4492.   # * new-method :half_up
  4493.   #--------------------------------------------------------------------------#
  4494.   def half_up( turn_ok=true )
  4495.     turn_up if turn_ok
  4496.     @y = $game_map.round_y(@y-0.5)
  4497.     @real_y = ((@y+0.5)*256)
  4498.     @move_failed = false
  4499.   end
  4500.  
  4501.   #--------------------------------------------------------------------------#
  4502.   # * new-method :half_forward
  4503.   #--------------------------------------------------------------------------#
  4504.   def half_forward()
  4505.     case @direction
  4506.     when 2 ; half_down
  4507.     when 4 ; half_left
  4508.     when 6 ; half_right
  4509.     when 8 ; half_up
  4510.     end
  4511.   end
  4512.  
  4513.   #--------------------------------------------------------------------------#
  4514.   # * new-method :half_backward
  4515.   #--------------------------------------------------------------------------#
  4516.   def half_backward()
  4517.     last_direction_fix = @direction_fix
  4518.     @direction_fix = true
  4519.     case @direction
  4520.     when 2;  half_up
  4521.     when 4;  half_right
  4522.     when 6;  half_left
  4523.     when 8;  half_down
  4524.     end
  4525.     @direction_fix = last_direction_fix
  4526.   end
  4527.  
  4528.   #--------------------------------------------------------------------------#
  4529.   # * new-method :free_move_toward_target
  4530.   #--------------------------------------------------------------------------#
  4531.   def free_move_toward_target( t_x, t_y )
  4532.     sx = fr_distance_x_from(t_x)
  4533.     sy = fr_distance_y_from(t_y)
  4534.     if sx != 0 or sy != 0
  4535.       if sx.abs > sy.abs                  # Horizontal distance is longer
  4536.         sx > 0 ? free_left : free_right   # Prioritize left-right
  4537.         if @move_failed and sy != 0
  4538.           sy > 0 ? free_up : free_down
  4539.         end
  4540.       else                                # Vertical distance is longer
  4541.         sy > 0 ? free_up : free_down      # Prioritize up-down
  4542.         if @move_failed and sx != 0
  4543.           sx > 0 ? free_left : free_right
  4544.         end
  4545.       end
  4546.     end
  4547.   end
  4548.  
  4549.   #--------------------------------------------------------------------------#
  4550.   # * new-method :fr_distance_x_from
  4551.   #--------------------------------------------------------------------------#
  4552.   def fr_distance_x_from( targ_x )
  4553.     sx = self.x - targ_x
  4554.     if $game_map.loop_horizontal?         # When looping horizontally
  4555.       if sx.abs > $game_map.width / 2     # Larger than half the map width?
  4556.         sx -= $game_map.width             # Subtract map width
  4557.       end
  4558.     end
  4559.     return sx
  4560.   end
  4561.  
  4562.   #--------------------------------------------------------------------------#
  4563.   # * new-method :fr_distance_y_from
  4564.   #--------------------------------------------------------------------------#
  4565.   def fr_distance_y_from( targ_y )
  4566.     sy = self.y - targ_y
  4567.     if $game_map.loop_vertical?           # When looping vertically
  4568.       if sy.abs > $game_map.height / 2    # Larger than half the map height?
  4569.         sy -= $game_map.height            # Subtract map height
  4570.       end
  4571.     end
  4572.     return sy
  4573.   end
  4574.  
  4575.   #--------------------------------------------------------------------------#
  4576.   # * new-method :limited_down
  4577.   #--------------------------------------------------------------------------#
  4578.   def limited_down( orx, ory, limit, dist=1 )
  4579.     dist_x = fr_distance_x_from(orx)
  4580.     dist_y = fr_distance_y_from(ory) + dist
  4581.     move_down() if (dist_x.abs + dist_y.abs) < limit  
  4582.     return (dist_x.abs + dist_y.abs)
  4583.   end  
  4584.  
  4585.   #--------------------------------------------------------------------------#
  4586.   # * new-method :limited_up
  4587.   #--------------------------------------------------------------------------#  
  4588.   def limited_up( orx, ory, limit, dist=1 )
  4589.     dist_x = fr_distance_x_from(orx)
  4590.     dist_y = fr_distance_y_from(ory) - dist
  4591.     move_up() if (dist_x.abs + dist_y.abs) < limit
  4592.     return (dist_x.abs + dist_y.abs)
  4593.   end
  4594.  
  4595.   #--------------------------------------------------------------------------#
  4596.   # * new-method :limited_left
  4597.   #--------------------------------------------------------------------------#  
  4598.   def limited_left( orx, ory, limit, dist=1 )
  4599.     dist_x = fr_distance_x_from(orx) - dist
  4600.     dist_y = fr_distance_y_from(ory)
  4601.     move_left() if (dist_x.abs + dist_y.abs) < limit
  4602.     return (dist_x.abs + dist_y.abs)
  4603.   end
  4604.  
  4605.   #--------------------------------------------------------------------------#
  4606.   # * new-method :limited_right
  4607.   #--------------------------------------------------------------------------#  
  4608.   def limited_right( orx, ory, limit, dist=1 )
  4609.     dist_x = fr_distance_x_from(orx) + dist
  4610.     dist_y = fr_distance_y_from(ory)
  4611.     move_right() if (dist_x.abs + dist_y.abs) < limit
  4612.     return (dist_x.abs + dist_y.abs)
  4613.   end  
  4614.  
  4615.   #--------------------------------------------------------------------------#
  4616.   # * new-method :thrust_down
  4617.   #--------------------------------------------------------------------------#
  4618.   def thrust_down()
  4619.     dudspeed = @move_speed
  4620.     @move_speed = 6
  4621.     half_down()
  4622.     thrust_wait()
  4623.     half_up( false )
  4624.     @move_speed = dudspeed
  4625.   end
  4626.  
  4627.   #--------------------------------------------------------------------------#
  4628.   # * new-method :thrust_up
  4629.   #--------------------------------------------------------------------------#
  4630.   def thrust_up()
  4631.     dudspeed = @move_speed
  4632.     @move_speed = 6
  4633.     half_up()
  4634.     thrust_wait()
  4635.     half_down( false )
  4636.     @move_speed = dudspeed
  4637.   end
  4638.  
  4639.   #--------------------------------------------------------------------------#
  4640.   # * new-method :thrust_left
  4641.   #--------------------------------------------------------------------------#  
  4642.   def thrust_left()
  4643.     dudspeed = @move_speed
  4644.     @move_speed = 6
  4645.     half_left()
  4646.     thrust_wait()
  4647.     half_right( false )
  4648.     @move_speed = dudspeed
  4649.   end
  4650.  
  4651.   #--------------------------------------------------------------------------#
  4652.   # * new-method :thrust_right
  4653.   #--------------------------------------------------------------------------#
  4654.   def thrust_right()
  4655.     dudspeed = @move_speed
  4656.     @move_speed = 6
  4657.     half_right()
  4658.     thrust_wait()
  4659.     half_left( false )
  4660.     @move_speed = dudspeed
  4661.   end
  4662.  
  4663.   #--------------------------------------------------------------------------#
  4664.   # * new-method :thrust_forward
  4665.   #--------------------------------------------------------------------------#
  4666.   def thrust_forward()
  4667.     case @direction
  4668.     when 2 ; thrust_down()
  4669.     when 4 ; thrust_left()
  4670.     when 6 ; thrust_right()
  4671.     when 8 ; thrust_up()
  4672.     end
  4673.   end
  4674.  
  4675.   #--------------------------------------------------------------------------#
  4676.   # * new-method :thrust_backward
  4677.   #--------------------------------------------------------------------------#
  4678.   def thrust_backward()
  4679.     last_direction_fix = @direction_fix
  4680.     @direction_fix = true
  4681.     case @direction
  4682.     when 2 ; thrust_up
  4683.     when 4 ; thrust_right
  4684.     when 6 ; thrust_left
  4685.     when 8 ; thrust_down
  4686.     end
  4687.     @direction_fix = last_direction_fix
  4688.   end
  4689.  
  4690.   #--------------------------------------------------------------------------#
  4691.   # * new-method :ygg_dodge
  4692.   #--------------------------------------------------------------------------#
  4693.   def ygg_dodge()
  4694.     last_direction_fix = @direction_fix
  4695.     @direction_fix = true
  4696.     dodge_val = rand(2)
  4697.     case @direction
  4698.     when 2, 8; dodge_val == 0 ? thrust_left() : thrust_right()
  4699.     when 4, 6; dodge_val == 0 ? thrust_up() : thrust_down()
  4700.     end
  4701.     @direction_fix = last_direction_fix
  4702.   end
  4703.  
  4704.   #--------------------------------------------------------------------------#
  4705.   # * new-method :free_down
  4706.   #--------------------------------------------------------------------------#
  4707.   def free_down( turn_ok=true )
  4708.     if passable?(@x, @y.round.to_i+0.1)                  # Passable
  4709.       turn_down
  4710.       @y = $game_map.round_y(@y+0.1)
  4711.       @real_y = (@y-0.1)*256
  4712.       increase_steps
  4713.       @move_failed = false
  4714.     else                                    # Impassable
  4715.       turn_down if turn_ok
  4716.       check_event_trigger_touch(@x, @y.round+1)   # Touch event is triggered?
  4717.       @move_failed = true
  4718.     end
  4719.   end
  4720.  
  4721.   #--------------------------------------------------------------------------#
  4722.   # * new-method :free_left
  4723.   #--------------------------------------------------------------------------#
  4724.   def free_left( turn_ok=true )
  4725.     if passable?(@x.round.to_i-1, @y)                  # Passable
  4726.       turn_left
  4727.       @x = $game_map.round_x(@x-0.1)
  4728.       @real_x = (@x+0.1)*256
  4729.       increase_steps
  4730.       @move_failed = false
  4731.     else                                    # Impassable
  4732.       turn_left if turn_ok
  4733.       check_event_trigger_touch(@x.round-1, @y)   # Touch event is triggered?
  4734.       @move_failed = true
  4735.     end
  4736.   end
  4737.  
  4738.   #--------------------------------------------------------------------------#
  4739.   # * new-method :free_right
  4740.   #--------------------------------------------------------------------------#
  4741.   def free_right( turn_ok=true )
  4742.     if passable?(@x.round.to_i+1, @y)                  # Passable
  4743.       turn_right
  4744.       @x = $game_map.round_x(@x+0.1)
  4745.       @real_x = (@x-0.1)*256
  4746.       increase_steps
  4747.       @move_failed = false
  4748.     else                                    # Impassable
  4749.       turn_right if turn_ok
  4750.       check_event_trigger_touch(@x.round+1, @y)   # Touch event is triggered?
  4751.       @move_failed = true
  4752.     end
  4753.   end
  4754.  
  4755.   #--------------------------------------------------------------------------#
  4756.   # * new-method :free_up
  4757.   #--------------------------------------------------------------------------#
  4758.   def free_up( turn_ok=true )
  4759.     if passable?(@x, @y.truncate-1)                  # Passable
  4760.       turn_up
  4761.       @y = $game_map.round_y(@y-0.1)
  4762.       @real_y = (@y+0.1)*256
  4763.       increase_steps
  4764.       @move_failed = false
  4765.     else                                    # Impassable
  4766.       turn_up if turn_ok
  4767.       check_event_trigger_touch(@x, @y.truncate-1)   # Touch event is triggered?
  4768.       @move_failed = true
  4769.     end
  4770.   end
  4771.  
  4772.   #--------------------------------------------------------------------------#
  4773.   # * new-method :hit_away
  4774.   #--------------------------------------------------------------------------#
  4775.   def hit_away( atk_direction )
  4776.     def_speed = @move_speed
  4777.     @move_speed = 6
  4778.     case atk_direction
  4779.     when 2
  4780.       turn_up
  4781.       move_backward
  4782.     when 4
  4783.       turn_right
  4784.       move_backward
  4785.     when 6
  4786.       turn_left
  4787.       move_backward
  4788.     when 8
  4789.       turn_down
  4790.       move_backward
  4791.     end
  4792.     @move_speed = def_speed
  4793.   end
  4794.  
  4795.   #--------------------------------------------------------------------------#
  4796.   # * new-method :turn_to_coord
  4797.   #--------------------------------------------------------------------------#
  4798.   def turn_to_coord( sx, sy )
  4799.     if sx > self.x and sy == self.y    ; turn_right()
  4800.     elsif sx < self.x and sy == self.y ; turn_left()
  4801.     elsif sx == self.x and sy > self.y ; turn_down()
  4802.     elsif sx == self.x and sy < self.y ; turn_up()
  4803.     end  
  4804.   end
  4805.  
  4806.   #--------------------------------------------------------------------------#
  4807.   # * new-method :set_origin
  4808.   #--------------------------------------------------------------------------#
  4809.   def set_origin()
  4810.     @origin ||= ::YGG::Pos.new( self.x, self.y ) ; @origin.set( self.x, self.y )
  4811.   end
  4812.    
  4813. end
  4814.  
  4815. #==============================================================================#
  4816. # ** YGG::MixIns::Battle
  4817. #==============================================================================#
  4818. module YGG::MixIns::Battle
  4819.  
  4820.   #--------------------------------------------------------------------------#
  4821.   # * Public Instance Variable(s)
  4822.   #--------------------------------------------------------------------------#
  4823.   attr_accessor :ygg_delay_max
  4824.  
  4825.   #--------------------------------------------------------------------------#
  4826.   # * new-method :ai_operated?
  4827.   #--------------------------------------------------------------------------#
  4828.   def ai_operated?()
  4829.     return @ai_operated
  4830.   end
  4831.  
  4832.   #--------------------------------------------------------------------------#
  4833.   # * new-method :hp_visible?
  4834.   #--------------------------------------------------------------------------#
  4835.   def hp_visible?()
  4836.     return $game_yggdrasil.on?() && @hp_visible
  4837.   end
  4838.    
  4839.   #--------------------------------------------------------------------------#
  4840.   # * new-method :mp_visible?
  4841.   #--------------------------------------------------------------------------#
  4842.   def mp_visible?()
  4843.     return $game_yggdrasil.on?() && @mp_visible
  4844.   end
  4845.    
  4846.   #--------------------------------------------------------------------------#
  4847.   # * new-method :ygg_can_move?
  4848.   #--------------------------------------------------------------------------#
  4849.   def ygg_can_move?() ; return true ; end
  4850.    
  4851.   #--------------------------------------------------------------------------#
  4852.   # * new-method :ygg_attacker | ygg_battler
  4853.   #--------------------------------------------------------------------------#
  4854.   def ygg_attacker() ; return nil ; end  
  4855.   def ygg_battler()  ; return ygg_attacker() ; end
  4856.    
  4857.   #--------------------------------------------------------------------------#
  4858.   # * new-method :wild_type?
  4859.   #--------------------------------------------------------------------------#
  4860.   def wild_type?() ; return false ; end  
  4861.    
  4862.   #--------------------------------------------------------------------------#
  4863.   # * new-method :ygg_enemy?
  4864.   #--------------------------------------------------------------------------#
  4865.   def ygg_enemy?() ; return false ; end  
  4866.    
  4867.   #--------------------------------------------------------------------------#
  4868.   # * new-method :ygg_ally?
  4869.   #--------------------------------------------------------------------------#
  4870.   def ygg_ally?() ; return false ; end  
  4871.    
  4872.   #--------------------------------------------------------------------------#
  4873.   # * new-method :ygg_death
  4874.   #--------------------------------------------------------------------------#
  4875.   def ygg_death() ; end  
  4876.    
  4877.   #--------------------------------------------------------------------------#
  4878.   # * new-method :ygg_boss?
  4879.   #--------------------------------------------------------------------------#
  4880.   def ygg_boss?() ; return false end  
  4881.    
  4882.   #--------------------------------------------------------------------------#
  4883.   # * new-method :process_extension_actions
  4884.   #--------------------------------------------------------------------------#
  4885.   def process_extension_actions() ; end
  4886.    
  4887.   #--------------------------------------------------------------------------#
  4888.   # * new-method :ygg_can_attack?
  4889.   #--------------------------------------------------------------------------#
  4890.   def ygg_can_attack?() ; return true ; end
  4891.  
  4892.   #--------------------------------------------------------------------------#
  4893.   # * new-method :targetable?
  4894.   #--------------------------------------------------------------------------#
  4895.   def targetable?( target )
  4896.     return false if self.ygg_battler.nil?()
  4897.     return true if target.upcase == "ALL"
  4898.     return true if self.ygg_ally?() && target == "ALLY"
  4899.     return true if self.ygg_enemy?() && target == "ENEMY"
  4900.     return false
  4901.   end  
  4902.  
  4903.   #--------------------------------------------------------------------------#
  4904.   # * new-method :ally_character?
  4905.   #--------------------------------------------------------------------------#  
  4906.   def ally_character?( char )
  4907.     return true if self.ygg_ally?() && char.ygg_ally?()
  4908.     return true if self.ygg_enemy?() && char.ygg_enemy?()
  4909.     return false
  4910.   end
  4911.  
  4912.   #--------------------------------------------------------------------------#
  4913.   # * new-method :enemy_character?
  4914.   #--------------------------------------------------------------------------#  
  4915.   def enemy_character?( char )
  4916.     return !ally_character?( char )
  4917.   end
  4918.  
  4919.   #--------------------------------------------------------------------------#
  4920.   # * new-method :ygg_correct_target
  4921.   #--------------------------------------------------------------------------#  
  4922.   def ygg_correct_target( target )
  4923.     return "ALLY" if self.ygg_enemy?() && target =~ /ENEMY/i
  4924.     return "ENEMY" if self.ygg_enemy?() && target =~ /ALLY/i
  4925.     return target
  4926.   end
  4927.  
  4928.   #--------------------------------------------------------------------------#
  4929.   # * new-method :ygg_abs_update
  4930.   #--------------------------------------------------------------------------#  
  4931.   def ygg_abs_update()
  4932.    
  4933.   end  
  4934. # ---------------------------------------------------------------------------- #    
  4935. # Calculations
  4936.  
  4937.   #--------------------------------------------------------------------------#
  4938.   # * new-method :Get Targets
  4939.   #--------------------------------------------------------------------------#
  4940.   # This is used to get all targets at a given location
  4941.   # l_x - x coordiante
  4942.   # l_y - y coordiante
  4943.   # target - "A", "E", "N", "W"
  4944.   # exclude_self - If the target that is encountered, happens to be the
  4945.   #                user, should they be ignored?
  4946.   #--------------------------------------------------------------------------#
  4947.   def ygg_get_targets( l_x=0, l_y=0, target="ALL", exclude_self = false )
  4948.     objects = $game_yggdrasil.battlers_xy( l_x, l_y ).inject([]) { |result, event|
  4949.       if event.targetable?( target )
  4950.         result.push( event )  
  4951.       end unless (exclude_self && event == self)
  4952.       result
  4953.     }
  4954.     if $game_player.pos?( l_x, l_y ) and $game_player.targetable?( target )
  4955.       objects.push( $game_player )  
  4956.     end unless (exclude_self && $game_player == self)
  4957.     return objects
  4958.   end
  4959.  
  4960. # ---------------------------------------------------------------------------- #    
  4961. # Processes
  4962.   #--------------------------------------------------------------------------#
  4963.   # * new-method :update_battler
  4964.   #--------------------------------------------------------------------------#
  4965.   def update_battler()
  4966.     update_states()
  4967.     self.ygg_battler.update_obj_handles()
  4968.     self.ygg_battler.update_cooldown()
  4969.   end
  4970.  
  4971.   #--------------------------------------------------------------------------#
  4972.   # * new-method :update_states
  4973.   #--------------------------------------------------------------------------#
  4974.   def update_states()
  4975.     self.ygg_battler.update_states
  4976.   end
  4977.    
  4978. # ---------------------------------------------------------------------------- #    
  4979. # Yggdrasil Battle Actions
  4980.  
  4981.   #--------------------------------------------------------------------------#
  4982.   # * new-method :get_targets_nearby
  4983.   #--------------------------------------------------------------------------#
  4984.   def get_targets_nearby( range=1, type ="ALL" )
  4985.     coords = []
  4986.     if YGG::FULL_FIELD_SCAN
  4987.       coords.concat( YGG.create_range_data( range ) )  
  4988.     else  
  4989.       case direction
  4990.       when 2
  4991.         for i in 0..range
  4992.           coords.push( [0, i] )
  4993.         end  
  4994.       when 4
  4995.         for i in 0..range
  4996.           coords.push( [-i, 0] )
  4997.         end  
  4998.       when 6
  4999.         for i in 0..range
  5000.           coords.push( [i, 0] )
  5001.         end  
  5002.       when 8
  5003.         for i in 0..range
  5004.           coords.push( [0, -i] )
  5005.         end  
  5006.       end  
  5007.     end  
  5008.     for coo in coords
  5009.       o = ygg_get_targets( coo[0]+self.x, coo[1]+self.y, type, true )
  5010.       return o unless o.empty?()
  5011.     end
  5012.     return []
  5013.   end
  5014.  
  5015. end
  5016.  
  5017. #==============================================================================#
  5018. # ** YGG::MixIns::AI
  5019. #==============================================================================#
  5020. module YGG::MixIns::AI
  5021.  
  5022.   #--------------------------------------------------------------------------#
  5023.   # * Public Instance Variables
  5024.   #--------------------------------------------------------------------------#  
  5025.   attr_accessor :ai_engine
  5026.  
  5027.   #--------------------------------------------------------------------------#
  5028.   # * new-method :setup_ai_engine
  5029.   #--------------------------------------------------------------------------#  
  5030.   def setup_ai_engine( engine, setup_data={} )
  5031.     @ai_engine = engine.new( self, setup_data )
  5032.   end
  5033.  
  5034.   #--------------------------------------------------------------------------#
  5035.   # * new-method :terminate_ai_engine
  5036.   #--------------------------------------------------------------------------#  
  5037.   def terminate_ai_engine()
  5038.     @ai_engine = nil
  5039.   end
  5040.  
  5041.   #--------------------------------------------------------------------------#
  5042.   # * new-method :ygg_update_ai
  5043.   #--------------------------------------------------------------------------#
  5044.   def ygg_update_ai()
  5045.     @ai_engine.update() unless @ai_engine.nil?()
  5046.   end
  5047.  
  5048. end
  5049.  
  5050. #==============================================================================#
  5051. # ** YGG::MixIns::Player
  5052. #==============================================================================#
  5053. module YGG::MixIns::Player
  5054.  
  5055.   #--------------------------------------------------------------------------#
  5056.   # * new-method :drop_attraction?
  5057.   #--------------------------------------------------------------------------#
  5058.   def drop_attraction?()
  5059.     return self.ygg_battler.drops_attraction? unless self.ygg_battler.nil?()
  5060.     return false
  5061.   end
  5062.  
  5063. end  
  5064. #==============================================================================#
  5065. # // Mix In
  5066. class Game_Actor     ; include YGG::MixIns::Actor    ; end
  5067. class Game_Enemy     ; include YGG::MixIns::Enemy    ; end
  5068. class Game_Character ; include YGG::MixIns::Movement ; end
  5069. class Game_Character ; include YGG::MixIns::Battle   ; end
  5070. class Game_Event     ; include YGG::MixIns::AI       ; end
  5071. class Game_Player    ; include YGG::MixIns::Player   ; end
  5072. #==============================================================================#  
  5073. #==============================================================================#
  5074. # ** Game_Character
  5075. #==============================================================================#
  5076. class Game_Character
  5077.  
  5078.   #--------------------------------------------------------------------------#
  5079.   # * Public Instance Variable(s)
  5080.   #--------------------------------------------------------------------------#
  5081.   attr_accessor :use_equipment
  5082.  
  5083.   attr_accessor :ygg_atk_delay
  5084.   attr_accessor :ygg_atk_delay_max
  5085.   attr_accessor :ygg_anims
  5086.  
  5087.   attr_accessor :move_speed_mod
  5088.   attr_accessor :tone
  5089.   attr_accessor :zoom_x, :zoom_y
  5090.   attr_accessor :wait_count
  5091.  
  5092.   attr_reader :action_handle
  5093.   attr_accessor :ygg_invincible
  5094.  
  5095.   #--------------------------------------------------------------------------#
  5096.   # * alias-method :initialize
  5097.   #--------------------------------------------------------------------------#
  5098.   alias :ygg_gmc_mixin_initialize :initialize unless $@
  5099.   def initialize( *args, &block )
  5100.     ygg_gmc_mixin_initialize( *args, &block )
  5101.     ygg_initialize()
  5102.   end
  5103.  
  5104.   #--------------------------------------------------------------------------#
  5105.   # * new-method :ygg_initialize
  5106.   #--------------------------------------------------------------------------#
  5107.   def ygg_initialize()
  5108.     @use_equipment     = false
  5109.     @equipment_handles = [::YGG::Handlers::Equip.new( self, 0 ),
  5110.                           ::YGG::Handlers::Equip.new( self, 1 )]
  5111.     @action_handle     = ::YGG::Handlers::Action.new( self, [] )
  5112.     @free_act_handles  = []
  5113.     @ygg_registered    = false
  5114.    
  5115.     @ygg_boss          = false
  5116.     @ygg_anims         = []
  5117.     @ygg_slip_counter  = 0
  5118.     @ygg_invincible    = false
  5119.    
  5120.     @move_speed_mod    = 0
  5121.    
  5122.     reset_tone()
  5123.    
  5124.     @zoom_x, @zoom_y   = 1.0, 1.0
  5125.    
  5126.     @ai_operated       = false
  5127.     @hp_visible        = true
  5128.     @mp_visible        = true
  5129.     ygg_register() if $game_system.yggdrasil_on?()  
  5130.   end
  5131.  
  5132.   #--------------------------------------------------------------------------#
  5133.   # * new-method :pop_enabled?
  5134.   #--------------------------------------------------------------------------#  
  5135.   def pop_enabled?() ; return true ; end
  5136.  
  5137.   #--------------------------------------------------------------------------#
  5138.   # * new-method :reset_tone
  5139.   #--------------------------------------------------------------------------#  
  5140.   def reset_tone()
  5141.     @tone              = Tone.new( 0, 0, 0, 0 )
  5142.     @target_tone       = Tone.new( 0, 0, 0, 0 )
  5143.     @tone_time         = 60.0
  5144.   end
  5145.  
  5146.   #--------------------------------------------------------------------------#
  5147.   # * new-method :screen_rect
  5148.   #--------------------------------------------------------------------------#  
  5149.   def screen_rect()
  5150.     @screen_rect ||= Rect.new( -32, -32, Graphics.width, Graphics.height )
  5151.     return @screen_rect
  5152.   end unless method_defined? :screen_rect
  5153.  
  5154.   #--------------------------------------------------------------------------#
  5155.   # * new-method :onScreen?
  5156.   #--------------------------------------------------------------------------#  
  5157.   def onScreen?()
  5158.     r = self.screen_rect
  5159.     return self.screen_x.between?( r.x, r.width ) && self.screen_y.between?( r.y, r.height )
  5160.   end
  5161.  
  5162.   #--------------------------------------------------------------------------#
  5163.   # * new-method :limitedOnScreen?
  5164.   #--------------------------------------------------------------------------#  
  5165.   def limitedOnScreen?()
  5166.     return false unless screen_x.between?( 0, Graphics.width ) && screen_y.between?( 0, Graphics.height )
  5167.     return true
  5168.   end
  5169.  
  5170.   #--------------------------------------------------------------------------#
  5171.   # * overwrite-method :collide_with_characters?
  5172.   #--------------------------------------------------------------------------#
  5173.   def collide_with_characters?( x, y )
  5174.     for event in $game_map.events_xy( x, y )          # Matches event position
  5175.       unless event.through                          # Passage OFF?
  5176.         return true if event.priority_type == 1     # Target is normal char
  5177.       end
  5178.     end
  5179.     if @priority_type == 1                          # Self is normal char
  5180.       return true if $game_player.pos_nt?(x, y)     # Matches player position
  5181.       return true if $game_map.boat.pos_nt?(x, y)   # Matches boat position
  5182.       return true if $game_map.ship.pos_nt?(x, y)   # Matches ship position
  5183.     end
  5184.     return false
  5185.   end
  5186.  
  5187.   #--------------------------------------------------------------------------#
  5188.   # * overwrite-method :update_move
  5189.   #--------------------------------------------------------------------------#  
  5190.   def update_move()
  5191.     distance = 2 ** self.move_speed   # Convert to movement distance
  5192.     distance *= 2 if dash?        # If dashing, double it
  5193.     @real_x = [@real_x - distance, @x * 256].max if @x * 256 < @real_x
  5194.     @real_x = [@real_x + distance, @x * 256].min if @x * 256 > @real_x
  5195.     @real_y = [@real_y - distance, @y * 256].max if @y * 256 < @real_y
  5196.     @real_y = [@real_y + distance, @y * 256].min if @y * 256 > @real_y
  5197.     update_bush_depth unless moving?
  5198.     if @walk_anime
  5199.       @anime_count += 1.5
  5200.     elsif @step_anime
  5201.       @anime_count += 1
  5202.     end
  5203.   end
  5204.  
  5205.   #--------------------------------------------------------------------------#
  5206.   # * overwrite-method :update_animation
  5207.   #--------------------------------------------------------------------------#  
  5208.   def update_animation()
  5209.     speed = self.move_speed + (dash? ? 1 : 0)
  5210.     if @anime_count > 18 - speed * 2
  5211.       if not @step_anime and @stop_count > 0
  5212.         @pattern = @original_pattern
  5213.       else
  5214.         @pattern = (@pattern + 1) % 4
  5215.       end
  5216.       @anime_count = 0
  5217.     end
  5218.   end
  5219.  
  5220.   #--------------------------------------------------------------------------#
  5221.   # * new-method :extra_speed_mod
  5222.   #--------------------------------------------------------------------------#  
  5223.   def extra_speed_mod()
  5224.     return self.ygg_battler.nil?() ? 0 : ygg_battler.move_mod  
  5225.   end
  5226.  
  5227.   #--------------------------------------------------------------------------#
  5228.   # * new-method :move_speed
  5229.   #--------------------------------------------------------------------------#  
  5230.   def move_speed()
  5231.     return @move_speed + @move_speed_mod + extra_speed_mod
  5232.   end
  5233.  
  5234.   #--------------------------------------------------------------------------#
  5235.   # * new-method :equip_handle
  5236.   #--------------------------------------------------------------------------#
  5237.   def equip_handle( eq_id ) ; @equipment_handles[eq_id] ; end
  5238.    
  5239.   #--------------------------------------------------------------------------#
  5240.   # * new-method :equip_icon
  5241.   #--------------------------------------------------------------------------#  
  5242.   def equip_icon( eq_id )
  5243.     return 0 if self.ygg_battler.nil?()
  5244.     return self.ygg_battler.equip_icon( eq_id )
  5245.   end
  5246.  
  5247.   #--------------------------------------------------------------------------#
  5248.   # * new-method :equip_atk_act_name
  5249.   #--------------------------------------------------------------------------#    
  5250.   def equip_atk_act_name( eq_id )
  5251.     return "" if self.ygg_battler.nil?()
  5252.     return self.ygg_battler.equip_atk_act_name( eq_id )
  5253.   end
  5254.  
  5255.   #--------------------------------------------------------------------------#
  5256.   # * new-method :equip_grd_act_name
  5257.   #--------------------------------------------------------------------------#    
  5258.   def equip_grd_act_name( eq_id )
  5259.     return "" if self.ygg_battler.nil?()
  5260.     return self.ygg_battler.equip_grd_act_name( eq_id )
  5261.   end
  5262.    
  5263.   #--------------------------------------------------------------------------#
  5264.   # * alias-method :update
  5265.   #--------------------------------------------------------------------------#
  5266.   alias :ygg_gmc_mixin_update :update unless $@
  5267.   def update( *args, &block )
  5268.     ygg_gmc_mixin_update( *args, &block )
  5269.     if self.ygg_battler.nil?()
  5270.       ygg_unregister() if @ygg_registered
  5271.     else
  5272.       abs_on = $game_system.yggdrasil_on?()  
  5273.       if abs_on
  5274.         @target_tone = self.ygg_battler.effect_tone
  5275.         if self.ygg_battler.character_need_refresh
  5276.           self.ygg_battler.character_need_refresh = false
  5277.         end  
  5278.         ygg_register() unless @ygg_registered
  5279.         @equipment_handles.each { |eq| eq.update() }
  5280.         self.ygg_engage.update() unless self.ygg_engage.nil?()
  5281.         @action_handle.update()
  5282.         @free_act_handles = @free_act_handles.inject([]) { |r, h|
  5283.           h.update() ; r << h if h.busy?() ; r
  5284.         } unless @free_act_handles.empty?()
  5285.       end  
  5286.     end  
  5287.     [:red, :green, :blue, :gray].each { |s|
  5288.       v1, v2 = @tone.send(s), @target_tone.send(s)
  5289.       if v1 > v2
  5290.         @tone.send( s.to_s+"=", [v1-(255.0/@tone_time), v2].max )
  5291.       elsif v1 < v2
  5292.         @tone.send( s.to_s+"=", [v1+(255.0/@tone_time), v2].min )
  5293.       end  
  5294.     }
  5295.   end
  5296.  
  5297.   #--------------------------------------------------------------------------#
  5298.   # * new-method :ygg_engage
  5299.   #--------------------------------------------------------------------------#
  5300.   def ygg_engage()
  5301.     return ygg_battler.ygg_engage
  5302.   end
  5303.  
  5304.   #--------------------------------------------------------------------------#
  5305.   # * new-method :ygg_register
  5306.   #--------------------------------------------------------------------------#
  5307.   def ygg_register()
  5308.     $game_yggdrasil.add_battler( self )
  5309.     @ygg_registered = true
  5310.   end  
  5311.  
  5312.   #--------------------------------------------------------------------------#
  5313.   # * new-method :ygg_unregister
  5314.   #--------------------------------------------------------------------------#
  5315.   def ygg_unregister()
  5316.     $game_yggdrasil.remove_battler( self )
  5317.     @ygg_registered = false
  5318.   end
  5319.  
  5320.   #--------------------------------------------------------------------------#
  5321.   # * new-method :get_target_events
  5322.   #--------------------------------------------------------------------------#
  5323.   def get_target_events( xy_list )
  5324.     return xy_list.inject([]) { |result, point|
  5325.       result + $game_yggdrasil.battlers_xy( *point )
  5326.     }
  5327.   end
  5328.    
  5329.   #--------------------------------------------------------------------------#
  5330.   # * new-method :set_through
  5331.   #--------------------------------------------------------------------------#  
  5332.   def set_through( bool ) ; @through = bool ; end
  5333.    
  5334. end
  5335.  
  5336. # // (YGG_VG)
  5337. #==============================================================================#
  5338. # // Start Yggdrasil Visual Code
  5339. #==============================================================================#
  5340. # ** YGG
  5341. #==============================================================================#
  5342. module YGG
  5343. #==============================================================================#
  5344. # ** YGG::Sprites::ValueBar_Base
  5345. #==============================================================================#  
  5346.   class Sprites::ValueBar_Base < ::Sprite
  5347.    
  5348.     BAR_DRAW_MODE = 0 # // 0 Use 2 sprites, 1 Draw onto base
  5349.    
  5350.     #--------------------------------------------------------------------------#
  5351.     # * super-method :initialize
  5352.     #--------------------------------------------------------------------------#        
  5353.     def initialize( parent, base_name, bar_name, value_proc, max_proc )
  5354.       super( parent.viewport )
  5355.       @parent       = parent
  5356.       @base_name    = base_name
  5357.       @bar_name     = bar_name
  5358.       case BAR_DRAW_MODE
  5359.       when 0
  5360.         self.bitmap   = Cache.system( base_name )
  5361.         @bar          = ::Sprite_Base.new( self.viewport )
  5362.         @bar.bitmap   = Cache.system( bar_name )
  5363.         @bar.x        = self.x       = @parent.x
  5364.         @bar.y        = self.y       = @parent.y
  5365.         @bar.visible  = self.visible = @parent.visible
  5366.       when 1
  5367.         base_ref      = Cache.system( base_name )
  5368.         self.bitmap   = Bitmap.new( base_ref.width, base_ref.height )
  5369.       end  
  5370.       @value_proc     = value_proc
  5371.       @max_proc       = max_proc
  5372.       @last_value     = -1
  5373.       @last_max       = -1
  5374.       @offsets        = ::YGG::Pos.new( 0, 0, 0 )
  5375.       @baroffsets     = ::YGG::Pos.new( 0, 0, 1 )
  5376.     end
  5377.    
  5378.     #--------------------------------------------------------------------------#
  5379.     # * super-method :dispose
  5380.     #--------------------------------------------------------------------------#    
  5381.     def dispose()
  5382.       case BAR_DRAW_MODE
  5383.       when 0
  5384.         @bar.dispose()
  5385.       when 1
  5386.         self.bitmap.dispose()
  5387.       end  
  5388.       super()
  5389.     end
  5390.    
  5391.   case BAR_DRAW_MODE
  5392.   when 0
  5393.    
  5394.     #--------------------------------------------------------------------------#
  5395.     # * super-method :update
  5396.     #--------------------------------------------------------------------------#    
  5397.     def update()
  5398.       super()
  5399.       val = @value_proc.call() #* 100
  5400.       max = @max_proc.call() #* 100
  5401.       if (val != @last_value || max != @last_max)
  5402.         if max.eql?( 0 )
  5403.           @bar.src_rect.width = 0
  5404.         else  
  5405.           bar_width = @bar.bitmap.width * val / max
  5406.           @bar.src_rect.width = bar_width
  5407.         end  
  5408.         @last_value = val
  5409.         @last_max   = max
  5410.       end
  5411.       pox = @parent.src_rect.width / 2 - (@parent.src_rect.width +
  5412.         self.bitmap.width) / 2
  5413.       @bar.x       = @baroffsets.x + self.x       = @parent.x + pox + @offsets.x
  5414.       @bar.y       = @baroffsets.y + self.y       = @parent.y + @offsets.y
  5415.       @bar.z       = @baroffsets.z + self.z       = @parent.z + @offsets.z
  5416.       @bar.visible = self.visible# = @parent.visible
  5417.       @bar.opacity = self.opacity
  5418.     end
  5419.    
  5420.   when 1  
  5421.    
  5422.     #--------------------------------------------------------------------------#
  5423.     # * super-method :update
  5424.     #--------------------------------------------------------------------------#    
  5425.     def update()
  5426.       super()
  5427.       val = @value_proc.call() #* 100
  5428.       max = @max_proc.call() #* 100
  5429.       if (val != @last_value || max != @last_max)
  5430.         self.bitmap.clear()
  5431.         base = Cache.system( @base_name )
  5432.         bar  = Cache.system( @bar_name )
  5433.         self.bitmap.blt( 0, 0, base, base.rect )
  5434.         unless max.eql?( 0 )
  5435.           bar_width = bar.width * val / max
  5436.           rect = bar.rect.clone()
  5437.           rect.width = bar_width
  5438.           self.bitmap.blt( @baroffsets.x, @baroffsets.y, bar, rect )
  5439.         end  
  5440.         @last_value = val
  5441.         @last_max   = max
  5442.       end
  5443.       pox = @parent.src_rect.width / 2 - (@parent.src_rect.width +
  5444.       self.bitmap.width) / 2
  5445.       self.x       = @parent.x + pox + @offsets.x
  5446.       self.y       = @parent.y + @offsets.y
  5447.       self.z       = @parent.z + @offsets.z
  5448.       #self.visible = @parent.visible
  5449.     end  
  5450.    
  5451.   end
  5452.    
  5453.   end
  5454. #==============================================================================#
  5455. # ** YGG::Sprites::HpBar
  5456. #==============================================================================#    
  5457.   class Sprites::HpBar < Sprites::ValueBar_Base
  5458.    
  5459.     #--------------------------------------------------------------------------#
  5460.     # * super-method :initialize
  5461.     #--------------------------------------------------------------------------#    
  5462.     def initialize( parent )
  5463.       val_proc = Proc.new { @parent.character.ygg_attacker.hp }
  5464.       max_proc = Proc.new { @parent.character.ygg_attacker.maxhp }
  5465.       base_name= "1x6Graphics/EventBarBase"
  5466.       if parent.character.ygg_attacker.actor?()
  5467.         bar_name = "1x6Graphics/EventBar2"
  5468.       else
  5469.         bar_name = "1x6Graphics/EventBar3"
  5470.       end  
  5471.       super( parent, base_name, bar_name, val_proc, max_proc )
  5472.       @offsets.set( 0, 0, 0 )
  5473.       @baroffsets.set( 1, 1, 0 )
  5474.     end
  5475.  
  5476.     #--------------------------------------------------------------------------#
  5477.     # * super-method :update
  5478.     #--------------------------------------------------------------------------#
  5479.     def update()
  5480.       self.opacity = @parent.character.ygg_engage.bar_opacity
  5481.       self.visible = @parent.character.hp_visible?()
  5482.       super()
  5483.     end
  5484.    
  5485.   end
  5486. #==============================================================================#
  5487. # ** YGG::Sprites::MpBar
  5488. #==============================================================================#  
  5489.   class Sprites::MpBar < Sprites::ValueBar_Base
  5490.    
  5491.     #--------------------------------------------------------------------------#
  5492.     # * super-method :initialize
  5493.     #--------------------------------------------------------------------------#    
  5494.     def initialize( parent )
  5495.       val_proc = Proc.new { @parent.character.ygg_attacker.mp }
  5496.       max_proc = Proc.new { @parent.character.ygg_attacker.maxmp }
  5497.       base_name= "1x6Graphics/EventBarBase"
  5498.       bar_name = "1x6Graphics/EventBar5"
  5499.       super( parent, base_name, bar_name, val_proc, max_proc )
  5500.       @offsets.set( 0, 6, 0 )
  5501.       @baroffsets.set( 1, 1, 1 )
  5502.     end
  5503.    
  5504.     #--------------------------------------------------------------------------#
  5505.     # * super-method :update
  5506.     #--------------------------------------------------------------------------#
  5507.     def update()
  5508.       #self.opacity = @parent.character.ygg_engage.bar_opacity
  5509.       self.visible = @parent.character.mp_visible?()
  5510.       super()
  5511.     end
  5512.    
  5513.   end
  5514.    
  5515. end  
  5516.  
  5517. #==============================================================================#
  5518. # ** Sprite_Character
  5519. #==============================================================================#
  5520. class Sprite_Character < Sprite_Base
  5521.  
  5522.   #--------------------------------------------------------------------------#
  5523.   # * alias-method :initialize
  5524.   #--------------------------------------------------------------------------#
  5525.   alias :ygg1x6_hpmp_spc_initialize :initialize unless $@
  5526.   def initialize( *args )
  5527.     ygg1x6_hpmp_spc_initialize( *args )
  5528.     create_bars()
  5529.     update_bars()
  5530.   end
  5531.  
  5532.   #--------------------------------------------------------------------------#
  5533.   # * new-method :create_bars
  5534.   #--------------------------------------------------------------------------#
  5535.   def create_bars()
  5536.     unless @character.ygg_battler.nil?()
  5537.       create_hp_bar() if @hp_bar.nil?() if ::YGG::USE_HPBAR
  5538.       create_mp_bar() if @mp_bar.nil?() if ::YGG::USE_MPBAR
  5539.     end
  5540.   end
  5541.  
  5542.   #--------------------------------------------------------------------------#
  5543.   # * new-method :create_hp_bar
  5544.   #--------------------------------------------------------------------------#
  5545.   def create_hp_bar()
  5546.     return if @character.ygg_battler.nil?()
  5547.     @hp_bar = ::YGG::Sprites::HpBar.new( self )
  5548.   end
  5549.  
  5550.   #--------------------------------------------------------------------------#
  5551.   # * new-method :create_mp_bar
  5552.   #--------------------------------------------------------------------------#  
  5553.   def create_mp_bar()
  5554.     return if @character.ygg_battler.nil?()
  5555.     @mp_bar = ::YGG::Sprites::MpBar.new( self )
  5556.   end
  5557.  
  5558.   #--------------------------------------------------------------------------#
  5559.   # * alias-method :dispose
  5560.   #--------------------------------------------------------------------------#
  5561.   alias :ygg1x6_hpmp_spc_dispose :dispose unless $@
  5562.   def dispose()
  5563.     dispose_bars()
  5564.     ygg1x6_hpmp_spc_dispose()
  5565.   end
  5566.  
  5567.   #--------------------------------------------------------------------------#
  5568.   # * new-method :dispose_bars
  5569.   #--------------------------------------------------------------------------#  
  5570.   def dispose_bars()
  5571.     dispose_hp_bar() unless @hp_bar.nil?()
  5572.     dispose_mp_bar() unless @mp_bar.nil?()
  5573.   end
  5574.  
  5575.   #--------------------------------------------------------------------------#
  5576.   # * new-method :dispose_hp_bar
  5577.   #--------------------------------------------------------------------------#  
  5578.   def dispose_hp_bar() ; @hp_bar.dispose() ; @hp_bar = nil ; end
  5579.  
  5580.   #--------------------------------------------------------------------------#
  5581.   # * new-method :dispose_mp_bar
  5582.   #--------------------------------------------------------------------------#  
  5583.   def dispose_mp_bar() ; @mp_bar.dispose() ; @mp_bar = nil ; end
  5584.  
  5585.   #--------------------------------------------------------------------------#
  5586.   # * alias-method :update
  5587.   #--------------------------------------------------------------------------#  
  5588.   alias :ygg1x6_hpmp_spc_update :update unless $@
  5589.   def update()
  5590.     ygg1x6_hpmp_spc_update()
  5591.     update_bars() unless @character.nil?()
  5592.   end
  5593.  
  5594.   #--------------------------------------------------------------------------#
  5595.   # * new-method :update_bars
  5596.   #--------------------------------------------------------------------------#  
  5597.   def update_bars()
  5598.     update_hp_bar() unless @hp_bar.nil?()
  5599.     update_mp_bar() unless @mp_bar.nil?()
  5600.   end
  5601.  
  5602.   #--------------------------------------------------------------------------#
  5603.   # * new-method :update_hp_bar
  5604.   #--------------------------------------------------------------------------#  
  5605.   def update_hp_bar()
  5606.     if @hp_bar.nil?() && !@character.ygg_attacker.nil?()
  5607.       create_hp_bar()
  5608.     elsif !@hp_bar.nil?() && @character.ygg_attacker.nil?()  
  5609.       dispose_hp_bar()
  5610.     end
  5611.     @hp_bar.update() unless @hp_bar.nil?()
  5612.   end
  5613.  
  5614.   #--------------------------------------------------------------------------#
  5615.   # * new-method :update_mp_bar
  5616.   #--------------------------------------------------------------------------#  
  5617.   def update_mp_bar()
  5618.     if @mp_bar.nil?() && !@character.ygg_attacker.nil?()
  5619.       create_mp_bar()
  5620.     elsif !@mp_bar.nil?() && @character.ygg_attacker.nil?()  
  5621.       dispose_mp_bar()
  5622.     end
  5623.     @mp_bar.update() unless @mp_bar.nil?()
  5624.   end
  5625.  
  5626. end if ::YGG::USE_STAT_BARS
  5627.  
  5628. #==============================================================================#
  5629. # ** YGG
  5630. #==============================================================================#
  5631. module YGG  
  5632. #==============================================================================#
  5633. # ** PopText
  5634. #==============================================================================#  
  5635.   PopText = Struct.new( :text, :font, :move_rule )
  5636. #==============================================================================#  
  5637.   class PopText
  5638.    
  5639.   #--------------------------------------------------------------------------#
  5640.   # * new-class-method :create_pop
  5641.   #--------------------------------------------------------------------------#  
  5642.     def self.create_pop( setup_data={} )
  5643.       character  = setup_data[:character]
  5644.       bat        = setup_data[:battler] || (character.nil?() ? nil : character.ygg_battler)
  5645.       type       = setup_data[:type] || :nil
  5646.       parameters = setup_data[:parameters] || []
  5647.       move_rule  = :default
  5648.       pop_stack  = []
  5649.       font_size_add = 0
  5650.       case type
  5651.       when :attack_damage, :skill_damage, :item_damage
  5652.         case type
  5653.         when :attack_damage
  5654.           move_rule = bat.critical ? :shatter : :attack_default
  5655.         when :skill_damage  
  5656.           move_rule = bat.critical ? :shatter : :skill_default
  5657.         when :item_damage
  5658.           move_rule = bat.critical ? :shatter : :item_default
  5659.         end
  5660.         font_size_add += ::YGG::CRITICAL_FONTSIZE_ADD if bat.critical
  5661.         if bat.hp_damage > 0
  5662.           rule = YGG::POPUP_RULES["HP_DMG"]
  5663.           text = sprintf( YGG::POPUP_SETTINGS[:hp_dmg], bat.hp_damage.abs )
  5664.         elsif bat.hp_damage < 0
  5665.           rule = YGG::POPUP_RULES["HP_HEAL"]
  5666.           text = sprintf( YGG::POPUP_SETTINGS[:hp_heal], bat.hp_damage.abs )
  5667.         elsif bat.missed    
  5668.           rule = YGG::POPUP_RULES["MISSED"]
  5669.           text = YGG::POPUP_SETTINGS[:missed]
  5670.         elsif bat.evaded    
  5671.           rule = YGG::POPUP_RULES["EVADED"]
  5672.           text = YGG::POPUP_SETTINGS[:evaded]
  5673.         elsif bat.skipped  
  5674.           rule = YGG::POPUP_RULES["NULLED"]
  5675.           text = YGG::POPUP_SETTINGS[:nulled]
  5676.         elsif bat.hp_damage == 0
  5677.           rule = YGG::POPUP_RULES["HP_NO_DMG"]
  5678.           text = sprintf( YGG::POPUP_SETTINGS[:hp_dmg], bat.hp_damage.abs )
  5679.         end
  5680.         pop_stack << [text, rule, move_rule]  
  5681.         pop_stack << [POPUP_SETTINGS[:critical],
  5682.                       YGG::POPUP_RULES["CRITICAL"],
  5683.                       :crit_default] if bat.critical if SHOW_CRITICAL
  5684.         if type == :skill_damage || type == :item_damage          
  5685.           skip_stack = false
  5686.           if bat.mp_damage > 0
  5687.             rule = YGG::POPUP_RULES["MP_DMG"]
  5688.             text = sprintf( YGG::POPUP_SETTINGS[:mp_dmg], bat.mp_damage.abs )
  5689.           elsif bat.mp_damage < 0
  5690.             rule = YGG::POPUP_RULES["MP_HEAL"]
  5691.             text = sprintf( YGG::POPUP_SETTINGS[:mp_heal], bat.mp_damage.abs )
  5692.           elsif bat.missed  
  5693.             skip_stack = true
  5694.             #rule = YGG::POPUP_RULES["MISSED"]
  5695.             #text = YGG::POPUP_SETTINGS[:missed]
  5696.           elsif bat.evaded    
  5697.             skip_stack = true
  5698.             #rule = YGG::POPUP_RULES["EVADED"]
  5699.             #text = YGG::POPUP_SETTINGS[:evaded]
  5700.           elsif bat.skipped  
  5701.             skip_stack = true
  5702.             #rule = YGG::POPUP_RULES["NULLED"]
  5703.             #text = YGG::POPUP_SETTINGS[:nulled]
  5704.           elsif bat.mp_damage == 0
  5705.             skip_stack = true
  5706.           #  rule = YGG::POPUP_RULES["MP_NO_DMG"]
  5707.           #  text = sprintf( YGG::POPUP_SETTINGS[:mp_dmg], bat.mp_damage.abs )
  5708.           end
  5709.           pop_stack << [text, rule, move_rule] unless skip_stack
  5710.         end
  5711.       when :gain_exp
  5712.         rule = YGG::POPUP_RULES["EXP_POP"]
  5713.         text = sprintf( YGG::POPUP_SETTINGS[:exp_pop], parameters[0] )
  5714.         move_rule = :exp_default
  5715.         pop_stack << [text, rule, move_rule]
  5716.       when :level_up  
  5717.         rule = YGG::POPUP_RULES["LVL_POP"]
  5718.         text = sprintf( YGG::POPUP_SETTINGS[:lvl_pop], parameters[0] )
  5719.         move_rule = :lvl_default
  5720.         pop_stack << [text, rule, move_rule]
  5721.       when :custom
  5722.         rule = [
  5723.           setup_data[:font_size] || font.size,
  5724.           setup_data[:font_color] || Font.default_color,
  5725.           [(setup_data[:font_bold] || Font.default_bold) ? "BOLD" : "NO BOLD",
  5726.            (setup_data[:font_italic] || Font.default_italic) ? "ITALIC" : "NO ITALIC",
  5727.            (setup_data[:font_shadow] || Font.default_shadow) ? "SHADOW" : "NO SHADOW"
  5728.           ],
  5729.           setup_data[:font_name]
  5730.         ]
  5731.         pop_stack << [setup_data[:text] || "", rule, setup_data[:move_rule] || :default]
  5732.       end
  5733.       pop_stack.each { |pop|
  5734.         text, rule, move_rule = *pop
  5735.         font        = Font.new()
  5736.         proprule    = rule[2].inject([]) { |r, s| s.upcase }
  5737.         colors      = rule[1].kind_of?( Array ) ? rule[1] : [rule[1], rule[1]]
  5738.         font.name   = rule[3].empty? ? Font.default_name : rule[3]
  5739.         font.size   = (rule[0] || Font.default_size) + font_size_add
  5740.         font.bold   = proprule.include?("BOLD")
  5741.         font.italic = proprule.include?("ITALIC")
  5742.         font.shadow = proprule.include?("SHADOW")
  5743.         font.bold   = false if proprule.include?("NO BOLD")
  5744.         font.italic = false if proprule.include?("NO ITALIC")
  5745.         font.shadow = false if proprule.include?("NO SHADOW")
  5746.         font.color  = bat.nil?() ? colors[1] : (bat.actor?() ? colors[1] : colors[0])
  5747.         $game_yggdrasil.add_pop( self.new( text, font, move_rule ), character.x, character.y )
  5748.       }
  5749.     end
  5750.    
  5751.   end  
  5752.  
  5753. #==============================================================================#
  5754. # ** PopHandler
  5755. #==============================================================================#  
  5756.   class PopHandler < ::YGG::Handlers::Screen
  5757.    
  5758.     class BounceHandle
  5759.    
  5760.     #--------------------------------------------------------------------------#
  5761.     # * Public Instance Variable(s)
  5762.     #--------------------------------------------------------------------------#    
  5763.       attr_accessor :x, :y
  5764.       attr_accessor :ox, :oy
  5765.      
  5766.       attr_accessor :x_velocity, :y_velocity
  5767.       attr_accessor :x_boost, :y_boost
  5768.       attr_accessor :x_add, :y_add
  5769.    
  5770.       attr_accessor :cap_duration
  5771.       attr_accessor :finished
  5772.       attr_accessor :pause_update
  5773.       attr_accessor :gravity
  5774.       attr_accessor :floor_val
  5775.      
  5776.     #--------------------------------------------------------------------------#
  5777.     # * Constant(s)
  5778.     #--------------------------------------------------------------------------#      
  5779.       GRAVITY = 0.58
  5780.       TRANSEPARENT_START = 0
  5781.       TRANSEPARENT_X_SLIDE = 0    
  5782.      
  5783.     #--------------------------------------------------------------------------#
  5784.     # * new-method :initialize
  5785.     #--------------------------------------------------------------------------#
  5786.       def initialize( setup_data={} )
  5787.         @start_settings = [setup_data[:x] || 0, setup_data[:y] || 0, 0, 0]
  5788.         @cap_duration = setup_data[:cap_duration] || 80
  5789.         @x_velocity = setup_data[:x_velocity] || 0.4
  5790.         @y_velocity = setup_data[:y_velocity] || 1.5
  5791.         @x_boost    = setup_data[:x_boost] || 8
  5792.         @y_boost    = setup_data[:y_boost] || 4
  5793.         @x_add      = setup_data[:x_add] || 0
  5794.         @y_add      = setup_data[:y_add] || 4
  5795.         @gravity    = setup_data[:gravity] || GRAVITY
  5796.         @floor_val  = setup_data[:floor_val] || 0
  5797.         reset()
  5798.       end
  5799.      
  5800.     #--------------------------------------------------------------------------#
  5801.     # * new-method :reset
  5802.     #--------------------------------------------------------------------------#
  5803.       def reset()
  5804.         @x, @y, @ox, @oy = *@start_settings
  5805.         @finished = false
  5806.         @pause_update = false
  5807.         prep_pop()
  5808.       end
  5809.      
  5810.     #--------------------------------------------------------------------------#
  5811.     # * new-method :x_init_velocity
  5812.     #--------------------------------------------------------------------------#
  5813.       def x_init_velocity()
  5814.         return @x_velocity * ( rand(@x_boost) + @x_add )
  5815.       end
  5816.      
  5817.     #--------------------------------------------------------------------------#
  5818.     # * new-method :y_init_velocity
  5819.     #--------------------------------------------------------------------------#
  5820.       def y_init_velocity()
  5821.         return @y_velocity * ( rand(@y_boost) + @y_add )  
  5822.       end
  5823.      
  5824.     #--------------------------------------------------------------------------#
  5825.     # * new-method :prep_pop
  5826.     #--------------------------------------------------------------------------#
  5827.       def prep_pop()
  5828.         @now_x_speed = x_init_velocity
  5829.         @now_y_speed = y_init_velocity
  5830.         @potential_x_energy = 0.0
  5831.         @potential_y_energy = 0.0
  5832.         @speed_off_x = rand(2)
  5833.         @pop_duration = @cap_duration
  5834.       end
  5835.      
  5836.     #--------------------------------------------------------------------------#
  5837.     # * new-method :update
  5838.     #--------------------------------------------------------------------------#
  5839.       def update()
  5840.         return if @finished or @pause_update
  5841.         if @pop_duration <= TRANSEPARENT_START
  5842.           @x += TRANSEPARENT_X_SLIDE if @speed_off_x == 0
  5843.           @x -= TRANSEPARENT_X_SLIDE if @speed_off_x == 1
  5844.         end
  5845.         n = @oy + @now_y_speed
  5846.         if n <= @floor_val #0
  5847.           @now_y_speed *= -1
  5848.           @now_y_speed /=  2
  5849.           @now_x_speed /=  2
  5850.         end      
  5851.         @oy = [n, @floor_val].max
  5852.         @potential_y_energy += @gravity
  5853.         speed                = @potential_y_energy.floor
  5854.         @now_y_speed        -= speed
  5855.         @potential_y_energy -= speed
  5856.         @potential_x_energy += @now_x_speed
  5857.         speed                = @potential_x_energy.floor
  5858.         @ox                 += speed if @speed_off_x == 0
  5859.         @ox                 -= speed if @speed_off_x == 1
  5860.         @potential_x_energy -= speed
  5861.         @pop_duration       -= 1
  5862.         if @pop_duration == 0
  5863.           @finished = true
  5864.         end
  5865.       end
  5866.    
  5867.     end
  5868.  
  5869.   #--------------------------------------------------------------------------#
  5870.   # * Public Instance Variable(s)
  5871.   #--------------------------------------------------------------------------#    
  5872.     attr_accessor :ox, :oy, :oz
  5873.     attr_accessor :width, :height
  5874.     attr_accessor :zoom_x, :zoom_y
  5875.     attr_accessor :opacity
  5876.    
  5877.     attr_accessor :poptext
  5878.     attr_accessor :completed
  5879.    
  5880.   #--------------------------------------------------------------------------#
  5881.   # * new-method :initialize
  5882.   #--------------------------------------------------------------------------#                      
  5883.     def initialize( poptext, x, y, z )
  5884.       super( x, y, z )
  5885.       @frame     = 0
  5886.       @poptext   = poptext
  5887.       @ox        = 0
  5888.       @oy        = 0
  5889.       @oz        = 0
  5890.       @width     = 128
  5891.       @height    = 32
  5892.       @opacity   = 255
  5893.       @zoom_x    = 1.0
  5894.       @zoom_y    = 1.0
  5895.       @completed = false
  5896.       @bounce_handle = BounceHandle.new( { :x => 0, :y => 0 } )
  5897.     end
  5898.    
  5899.   #--------------------------------------------------------------------------#
  5900.   # * new-method :complete?()
  5901.   #--------------------------------------------------------------------------#                    
  5902.     def complete?() ; return @completed ; end
  5903.      
  5904.   #--------------------------------------------------------------------------#
  5905.   # * new-method :update
  5906.   #--------------------------------------------------------------------------#                  
  5907.     def update()
  5908.       case @poptext.move_rule
  5909.       when :default
  5910.         case @frame
  5911.         when 0..10
  5912.           @ox += 2
  5913.         when 11..20
  5914.           @ox -= 2
  5915.         when 21..40
  5916.           @oy -= 2
  5917.         when 41..60
  5918.           @oy -= 4
  5919.           @opacity -= 255 / 20
  5920.         when 61
  5921.           @completed = true
  5922.         end
  5923.       when :attack_default, :skill_default, :item_default  
  5924.         @bounce_handle.update()
  5925.         @ox, @oy = @bounce_handle.ox, -@bounce_handle.oy
  5926.         @completed = @bounce_handle.finished
  5927.       when :exp_default
  5928.         case @frame
  5929.         when 0...1
  5930.           @oy -= 16
  5931.         when 1..32
  5932.           @oy += 1
  5933.         when 33..64
  5934.           @opacity -= 255 / 32
  5935.         when 65
  5936.           @completed = true
  5937.         end
  5938.       when :lvl_default
  5939.         case @frame
  5940.         when 0..64
  5941.           @ox -= 1
  5942.         when 65..96  
  5943.           @opacity -= 255 / 32
  5944.         when 97
  5945.           @completed = true
  5946.         end  
  5947.       when :crit_default
  5948.         case @frame
  5949.         when 0...1
  5950.           @oy -= 16
  5951.         when 1..32
  5952.           @oy -= 2
  5953.           @zoom_x += 1.0 / 32
  5954.           @zoom_y = @zoom_x
  5955.         when 33..64
  5956.           @opacity -= 255 / 32
  5957.           @zoom_x -= 1.0 / 32
  5958.           @zoom_y = @zoom_x
  5959.         when 65
  5960.           @completed = true
  5961.         end
  5962.       when :shatter
  5963.         case @frame
  5964.         when 0..5
  5965.           @ox += 3
  5966.         when 6..10
  5967.           @ox -= 3
  5968.         when 11..30
  5969.           @ox += 3
  5970.           @oy -= 1
  5971.           @opacity -= 255 / 80
  5972.         when 31..50
  5973.           @ox -= 3
  5974.           @oy -= 1
  5975.           @opacity -= 255 / 80
  5976.         when 51..60  
  5977.           @opacity -= 255 / 40
  5978.         when 61
  5979.           @completed = true
  5980.         end
  5981.       end
  5982.       @frame += 1
  5983.     end  
  5984.    
  5985.   #--------------------------------------------------------------------------#
  5986.   # * new-method :screen_|x/y/z
  5987.   #--------------------------------------------------------------------------#                
  5988.     def screen_x() ; return super() + @ox      ; end    
  5989.     def screen_y() ; return super() + @oy + 32 ; end    
  5990.     def screen_z() ; return super() + @oz      ; end
  5991.    
  5992.   end
  5993.    
  5994. #==============================================================================#
  5995. # ** PopSprite
  5996. #==============================================================================#  
  5997.   class PopSprite < ::Sprite
  5998.    
  5999.   #--------------------------------------------------------------------------#
  6000.   # * Public Instance Variable(s)
  6001.   #--------------------------------------------------------------------------#        
  6002.     attr_accessor :pophandler
  6003.     attr_accessor :completed
  6004.    
  6005.   #--------------------------------------------------------------------------#
  6006.   # * new-method :initialize
  6007.   #--------------------------------------------------------------------------#              
  6008.     def initialize( viewport, pophandler )
  6009.       super( viewport )
  6010.       @pophandler = pophandler
  6011.       self.bitmap = Bitmap.new( @pophandler.width, @pophandler.height )
  6012.       self.ox = @pophandler.width / 2
  6013.       self.bitmap.font = @pophandler.poptext.font
  6014.       self.bitmap.draw_text( 0, 0, @pophandler.width, 24, @pophandler.poptext.text, 1 )
  6015.     end
  6016.    
  6017.   #--------------------------------------------------------------------------#
  6018.   # * new-method :update
  6019.   #--------------------------------------------------------------------------#            
  6020.     def update()
  6021.       super()
  6022.       self.x = @pophandler.screen_x
  6023.       self.y = @pophandler.screen_y
  6024.       self.z = @pophandler.screen_z
  6025.       self.zoom_x = @pophandler.zoom_x
  6026.       self.zoom_y = @pophandler.zoom_y
  6027.       self.opacity = @pophandler.opacity
  6028.       @completed   = @pophandler.completed
  6029.     end
  6030.    
  6031.   end
  6032. #==============================================================================#
  6033. # ** PopSpriteset
  6034. #==============================================================================#
  6035.   class PopSpriteset
  6036.    
  6037.   #--------------------------------------------------------------------------#
  6038.   # * new-method :initialize
  6039.   #--------------------------------------------------------------------------#        
  6040.     def initialize( viewport )
  6041.       @viewport = viewport
  6042.       @pop_sprites = []
  6043.       create_pops()
  6044.     end
  6045.    
  6046.   #--------------------------------------------------------------------------#
  6047.   # * new-method :create_pops
  6048.   #--------------------------------------------------------------------------#    
  6049.     def create_pops()
  6050.       $game_yggdrasil.new_poptexts.clear()
  6051.       $game_yggdrasil.pop_texts.each { |hnd| add_pop( hnd ) }
  6052.     end
  6053.    
  6054.   #--------------------------------------------------------------------------#
  6055.   # * new-method :dispose
  6056.   #--------------------------------------------------------------------------#
  6057.     def dispose()
  6058.       @pop_sprites.each { |sp| sp.dispose() }
  6059.       @pop_sprites.clear()
  6060.     end
  6061.  
  6062.   #--------------------------------------------------------------------------#
  6063.   # * new-method :update
  6064.   #--------------------------------------------------------------------------#
  6065.     def update()
  6066.       unless $game_yggdrasil.new_poptexts.empty?()
  6067.         $game_yggdrasil.new_poptexts.each { |hnd| add_pop( hnd ) }
  6068.         $game_yggdrasil.new_poptexts.clear()
  6069.       end  
  6070.       @pop_sprites = @pop_sprites.inject([]) { |result, sprite|
  6071.         sprite.update() ; sprite.dispose() if sprite.completed
  6072.         result << sprite unless sprite.disposed?() ; result
  6073.       } unless @pop_sprites.empty?()
  6074.     end
  6075.    
  6076.   #--------------------------------------------------------------------------#
  6077.   # * new-method :add_pop
  6078.   #--------------------------------------------------------------------------#
  6079.     def add_pop( pophandler )
  6080.       @pop_sprites << PopSprite.new( @viewport, pophandler )
  6081.     end
  6082.    
  6083.   end
  6084.  
  6085. end
  6086.  
  6087. #==============================================================================#
  6088. # ** Spriteset_Map
  6089. #==============================================================================#
  6090. class Spriteset_Map
  6091.  
  6092.   #--------------------------------------------------------------------------#
  6093.   # * Public Instance Variable(s)
  6094.   #--------------------------------------------------------------------------#      
  6095.   attr_accessor :poptext_spriteset
  6096.  
  6097.   #--------------------------------------------------------------------------#
  6098.   # * new-method :initialize
  6099.   #--------------------------------------------------------------------------#  
  6100.   alias :ygg_spm_ptxt_initialize :initialize unless $@  
  6101.   def initialize( *args, &block )
  6102.     ygg_spm_ptxt_initialize( *args, &block )
  6103.     create_poptext_spriteset()
  6104.   end
  6105.  
  6106.   #--------------------------------------------------------------------------#
  6107.   # * new-method :create_poptext_spriteset
  6108.   #--------------------------------------------------------------------------#  
  6109.   def create_poptext_spriteset()
  6110.     @poptext_spriteset = YGG::PopSpriteset.new( @viewport2 )
  6111.   end
  6112.  
  6113.   #--------------------------------------------------------------------------#
  6114.   # * alias-method :dispose
  6115.   #--------------------------------------------------------------------------#
  6116.   alias :ygg_spm_ptxt_dispose :dispose unless $@  
  6117.   def dispose( *args, &block )
  6118.     @poptext_spriteset.dispose() unless @poptext_spriteset.nil?()
  6119.     ygg_spm_ptxt_dispose( *args, &block )
  6120.   end
  6121.  
  6122.   #--------------------------------------------------------------------------#
  6123.   # * alias-method :update
  6124.   #--------------------------------------------------------------------------#  
  6125.   alias :ygg_spm_ptxt_update :update unless $@
  6126.   def update( *args, &block )
  6127.     ygg_spm_ptxt_update( *args, &block )
  6128.     @poptext_spriteset.update() unless @poptext_spriteset.nil?()
  6129.   end
  6130.  
  6131. end if ::YGG::USE_TEXT_POP
  6132.  
  6133. # // (YGG_DropsWindow)
  6134. #==============================================================================#
  6135. # ** YGG::Drops_Window
  6136. #==============================================================================#
  6137. class YGG::Drops_Window < ::Sprite
  6138.  
  6139.   #--------------------------------------------------------------------------#
  6140.   # * Constant(s)
  6141.   #--------------------------------------------------------------------------#      
  6142.   CHANGE_MAX  = 90  # 120
  6143.   FADE_LIMIT  = 30  # 30
  6144.   FADE_SPEED  = 40  # 60
  6145.   WLH         = 24
  6146.   BORDER_SIZE = 2
  6147.  
  6148.   #--------------------------------------------------------------------------#
  6149.   # * Public Instance Variable(s)
  6150.   #--------------------------------------------------------------------------#      
  6151.   attr_accessor :cleared
  6152.  
  6153.   #--------------------------------------------------------------------------#
  6154.   # * super-method :initialize
  6155.   #--------------------------------------------------------------------------#
  6156.   def initialize( setup_data={}, viewport=nil )
  6157.     super( viewport )
  6158.     width = setup_data[:width] || 128
  6159.     @background = Sprite.new( self.viewport )
  6160.     @background.bitmap = Bitmap.new( width, WLH )
  6161.     @background.bitmap.fill_rect( BORDER_SIZE, BORDER_SIZE,
  6162.       width-(BORDER_SIZE*2), WLH-(BORDER_SIZE*2),
  6163.       Color.new( 0, 0, 0 ) )
  6164.     @background.bitmap.blur() ; @background.bitmap.blur()
  6165.     @background.opacity = 198
  6166.     self.bitmap = Bitmap.new( width, WLH )
  6167.     self.src_rect.set( 0, 0, width, WLH )
  6168.     @change_time = 0
  6169.     @cleared = false
  6170.     self.x, self.y, self.z = setup_data[:x] || 0, setup_data[:y] || 0, setup_data[:z] || 200
  6171.   end
  6172.  
  6173.   #--------------------------------------------------------------------------#
  6174.   # * super-method :dispose
  6175.   #--------------------------------------------------------------------------#
  6176.   def dispose()
  6177.     unless @background.nil?()
  6178.       @background.bitmap.dispose() ; @background.dispose()
  6179.     end
  6180.     self.bitmap.dispose()
  6181.     super()
  6182.   end
  6183.  
  6184.   #--------------------------------------------------------------------------#
  6185.   # * super-method :x=
  6186.   #--------------------------------------------------------------------------#
  6187.   def x=( new_x )
  6188.     super( new_x )
  6189.     @background.x = self.x
  6190.   end
  6191.  
  6192.   #--------------------------------------------------------------------------#
  6193.   # * super-method :y=
  6194.   #--------------------------------------------------------------------------#
  6195.   def y=( new_y )
  6196.     super( new_y )
  6197.     @background.y = self.y
  6198.   end
  6199.  
  6200.   #--------------------------------------------------------------------------#
  6201.   # * super-method :z=
  6202.   #--------------------------------------------------------------------------#
  6203.   def z=( new_z )
  6204.     super( new_z+1 )
  6205.     @background.z = new_z
  6206.   end
  6207.  
  6208.   #--------------------------------------------------------------------------#
  6209.   # * super-method :viewport=
  6210.   #--------------------------------------------------------------------------#
  6211.   def viewport=( new_viewport )
  6212.     super( new_viewport )
  6213.     @background.viewport = self.viewport
  6214.   end
  6215.  
  6216.   #--------------------------------------------------------------------------#
  6217.   # * super-method :visible=
  6218.   #--------------------------------------------------------------------------#
  6219.   def visible=( new_visible )
  6220.     super( new_visible )
  6221.     @background.visible = self.visible
  6222.   end
  6223.  
  6224.   #--------------------------------------------------------------------------#
  6225.   # * new-method :draw_icon
  6226.   #--------------------------------------------------------------------------#
  6227.   def draw_icon( icon_index, x, y, enabled = true )
  6228.     bitmap = Cache.system( "Iconset" )
  6229.     rect = Rect.new( icon_index % 16 * 24, icon_index / 16 * 24, 24, 24 )
  6230.     self.bitmap.blt( x, y, bitmap, rect, enabled ? 255 : 128 )
  6231.   end unless method_defined? :draw_icon
  6232.  
  6233.   #--------------------------------------------------------------------------#
  6234.   # * new-method :draw_currency_value
  6235.   #--------------------------------------------------------------------------#
  6236.   def draw_currency_value( value, x, y, width )
  6237.     cx = self.bitmap.text_size( Vocab::gold ).width
  6238.     self.bitmap.font.color = Color.new( 255, 255, 255 )
  6239.     self.bitmap.draw_text( x, y, width-cx-2, WLH, value, 2 )
  6240.     self.bitmap.font.color = Color.new( 255, 255, 176 )
  6241.     self.bitmap.draw_text( x, y, width, WLH, Vocab::gold, 2 )
  6242.   end unless method_defined? :draw_currency_value
  6243.  
  6244.   #--------------------------------------------------------------------------#
  6245.   # * super-method :update
  6246.   #--------------------------------------------------------------------------#
  6247.   def update()
  6248.     super()
  6249.     @change_time -= 1 unless @change_time == 0
  6250.     if @change_time <= FADE_LIMIT
  6251.       self.opacity -= 255.0 / FADE_SPEED
  6252.     else
  6253.       self.opacity += 255.0 / FADE_SPEED
  6254.     end  
  6255.     if @change_time <= 0
  6256.       unless @cleared
  6257.         self.bitmap.clear()
  6258.         @cleared = true
  6259.       end  
  6260.       unless $game_player.ygg_gained_items.empty?
  6261.         obj = $game_player.ygg_gained_items.shift
  6262.         draw_icon( obj.icon_index, 4, 0 )
  6263.         self.bitmap.font.color = Color.new( 255, 255, 255 )
  6264.         self.bitmap.font.size  = 18
  6265.         self.bitmap.draw_text( 28, 0, self.width + 32, WLH, obj.name )
  6266.         if obj.is_a?( ::YGG::Containers::GoldItem )
  6267.           cc = obj.gold_amount
  6268.           draw_currency_value( cc, 0, 0, self.width - 4 )
  6269.         end  
  6270.         @cleared = false
  6271.         @change_time = CHANGE_MAX
  6272.       end
  6273.     end  
  6274.   end
  6275.  
  6276. end
  6277.  
  6278. #==============================================================================#
  6279. # ** YGG::Sprites::Animation
  6280. #==============================================================================#  
  6281. class YGG::Sprites::Animation < ::YGG::Handlers::Screen
  6282.  
  6283.   #--------------------------------------------------------------------------#
  6284.   # * Constants
  6285.   #--------------------------------------------------------------------------#
  6286.   RATE = 3 # // RMVX Default is 4
  6287.   RATE = ::Sprite_Base::RATE if $imported["IEO-BugFixesUpgrades"] || $imported["CoreFixesUpgradesMelody"]
  6288.  
  6289.   #--------------------------------------------------------------------------#
  6290.   # * Class Variable(s)
  6291.   #--------------------------------------------------------------------------#
  6292.   @@animations = []
  6293.   @@_reference_count = {}
  6294.  
  6295.   #--------------------------------------------------------------------------#
  6296.   # * Public Instance Variable(s)
  6297.   #--------------------------------------------------------------------------#
  6298.   attr_accessor :completed
  6299.   attr_accessor :looped_anim
  6300.   attr_accessor :started_anim
  6301.   attr_accessor :viewport
  6302.   attr_accessor :ox, :oy
  6303.   attr_accessor :opacity
  6304.  
  6305.   #--------------------------------------------------------------------------#
  6306.   # * new-method :initialize
  6307.   #--------------------------------------------------------------------------#
  6308.   def initialize( viewport=nil )
  6309.     super( 0, 0, 0 )
  6310.     @viewport           = viewport
  6311.     @animation          = nil
  6312.     @animation_bitmap1  = nil
  6313.     @animation_bitmap2  = nil
  6314.     @animation_duration = 0     # Remaining animation time
  6315.     @started_anim       = false
  6316.     @looped_anim        = false
  6317.     @completed          = true
  6318.     @targets            = []
  6319.     @ox, @oy            = -16, -32
  6320.     @opacity            = 255
  6321.   end
  6322.  
  6323.   #--------------------------------------------------------------------------#
  6324.   # * new-method :animation?
  6325.   #--------------------------------------------------------------------------#
  6326.   def animation? ; return !@animation.nil?() ; end
  6327.    
  6328.   #--------------------------------------------------------------------------#
  6329.   # * new-method :width
  6330.   #--------------------------------------------------------------------------#  
  6331.   def width ; return 32 ; end
  6332.    
  6333.   #--------------------------------------------------------------------------#
  6334.   # * new-method :height
  6335.   #--------------------------------------------------------------------------#    
  6336.   def height ; return 32 ; end
  6337.    
  6338.   #--------------------------------------------------------------------------#
  6339.   # * new-method :cell_limit
  6340.   #--------------------------------------------------------------------------#    
  6341.   def cell_limit ; 4 ; end  
  6342.  
  6343.   #--------------------------------------------------------------------------#
  6344.   # * new-method :flash
  6345.   #--------------------------------------------------------------------------#  
  6346.   def flash( color, duration )
  6347.     @targets.each { |sp| sp.flash( color, duration ) unless sp.disposed?() }
  6348.   end
  6349.  
  6350.   #--------------------------------------------------------------------------#
  6351.   # * new-method :screen_rect
  6352.   #--------------------------------------------------------------------------#  
  6353.   def screen_rect()
  6354.     @screen_rect ||= Rect.new( -32, -32, Graphics.width, Graphics.height )
  6355.     return @screen_rect
  6356.   end
  6357.  
  6358.   #--------------------------------------------------------------------------#
  6359.   # * new-method :onScreen?
  6360.   #--------------------------------------------------------------------------#  
  6361.   def onScreen?()
  6362.     r = self.screen_rect
  6363.     return self.screen_x.between?( r.x, r.width ) && self.screen_y.between?( r.y, r.height )
  6364.   end
  6365.  
  6366.   #--------------------------------------------------------------------------#
  6367.   # * new-method :limitedOnScreen?
  6368.   #--------------------------------------------------------------------------#  
  6369.   def limitedOnScreen?()
  6370.     return false unless screen_x.between?( 0, Graphics.width ) && screen_y.between?( 0, Graphics.height )
  6371.     return true
  6372.   end
  6373.  
  6374.   #--------------------------------------------------------------------------#
  6375.   # * new-method :play_anim
  6376.   #--------------------------------------------------------------------------#
  6377.   def play_anim( anim_id, targets=[] )
  6378.     set_targets( targets ) ; animation = $data_animations[anim_id]
  6379.     raise "Animation #{anim_id} does not exist" if ::YGG.debug_mode?() && animation.nil?()
  6380.     animation = RPG::Animation.new if animation.nil?() if ::YGG.silent_error?()
  6381.     start_animation( animation )
  6382.   end
  6383.  
  6384.   #--------------------------------------------------------------------------#
  6385.   # * new-method :setup_pos
  6386.   #--------------------------------------------------------------------------#
  6387.   def setup_pos( x, y, looped = false )
  6388.     self.moveto( x, y )
  6389.     @looped_anim = looped
  6390.   end
  6391.  
  6392.   #--------------------------------------------------------------------------#
  6393.   # * new-method :set_targets
  6394.   #--------------------------------------------------------------------------#
  6395.   def set_targets( new_targets )
  6396.     @targets.clear() ; @targets += new_targets
  6397.     @targets = @targets.flatten.uniq.compact
  6398.   end
  6399.  
  6400.   #--------------------------------------------------------------------------#
  6401.   # * new-method :load_animation_bitmap
  6402.   #--------------------------------------------------------------------------#  
  6403.   def load_animation_bitmap()
  6404.     animation1_name    = @animation.animation1_name
  6405.     animation1_hue     = @animation.animation1_hue
  6406.     animation2_name    = @animation.animation2_name
  6407.     animation2_hue     = @animation.animation2_hue
  6408.     @animation_bitmap1 = Cache.animation(animation1_name, animation1_hue)
  6409.     @animation_bitmap2 = Cache.animation(animation2_name, animation2_hue)
  6410.     if @@_reference_count.include?(@animation_bitmap1)
  6411.       @@_reference_count[@animation_bitmap1] += 1
  6412.     else
  6413.       @@_reference_count[@animation_bitmap1] = 1
  6414.     end
  6415.     if @@_reference_count.include?(@animation_bitmap2)
  6416.       @@_reference_count[@animation_bitmap2] += 1
  6417.     else
  6418.       @@_reference_count[@animation_bitmap2] = 1
  6419.     end
  6420.     Graphics.frame_reset()
  6421.   end
  6422.  
  6423.   #--------------------------------------------------------------------------#
  6424.   # * overwrite-method :start_animation
  6425.   #--------------------------------------------------------------------------#
  6426.   def start_animation( animation, mirror = false )
  6427.     dispose_animation()
  6428.     @animation = animation
  6429.     return if @animation.nil?()
  6430.     @animation_mirror = mirror
  6431.     @animation_duration = @animation.frame_max * RATE + 1
  6432.     load_animation_bitmap()
  6433.     @animation_sprites = []
  6434.     @cell_count = [animation.cell_count, self.cell_limit].min
  6435.     if @animation.position != 3 or not @@animations.include?( animation )
  6436.       for i in 0...@cell_count
  6437.         sprite = ::Sprite.new( viewport )
  6438.         sprite.visible = false
  6439.         @animation_sprites.push( sprite )
  6440.       end
  6441.       unless @@animations.include?( animation )
  6442.         @@animations.push( animation )
  6443.       end
  6444.     end
  6445.     update_animation_position()
  6446.     @started_anim = true
  6447.   end
  6448.  
  6449.   #--------------------------------------------------------------------------#
  6450.   # * new-method :dispose
  6451.   #--------------------------------------------------------------------------#
  6452.   def dispose() ; dispose_animation() ; end
  6453.  
  6454.   #--------------------------------------------------------------------------#
  6455.   # * new-method :dispose_animation
  6456.   #--------------------------------------------------------------------------#
  6457.   def dispose_animation()
  6458.     if @animation_bitmap1 != nil
  6459.       @@_reference_count[@animation_bitmap1] -= 1
  6460.       if @@_reference_count[@animation_bitmap1] == 0
  6461.         @animation_bitmap1.dispose
  6462.       end
  6463.     end
  6464.     if @animation_bitmap2 != nil
  6465.       @@_reference_count[@animation_bitmap2] -= 1
  6466.       if @@_reference_count[@animation_bitmap2] == 0
  6467.         @animation_bitmap2.dispose()
  6468.       end
  6469.     end
  6470.     @animation_sprites.each { |sprite| sprite.dispose } unless @animation_sprites.nil?()
  6471.     @animation_sprites = nil
  6472.     @animation = nil
  6473.     @animation_bitmap1 = nil
  6474.     @animation_bitmap2 = nil
  6475.   end
  6476.  
  6477.   #--------------------------------------------------------------------------#
  6478.   # * new-method: update
  6479.   #--------------------------------------------------------------------------#
  6480.   def update()
  6481.     update_animation() if @animation != nil
  6482.     @@animations.clear
  6483.   end
  6484.  
  6485.   #--------------------------------------------------------------------------#
  6486.   # * new-method: update_animation
  6487.   #--------------------------------------------------------------------------#
  6488.   def update_animation()
  6489.     @animation_duration -= 1
  6490.     update_animation_position() if @animation_duration > 0
  6491.     return unless @animation_duration % RATE == 0
  6492.     if @animation_duration > 0
  6493.       frame_index = @animation.frame_max - ((@animation_duration+RATE-1)/RATE)
  6494.       animation_set_sprites( @animation.frames[frame_index] )
  6495.       for timing in @animation.timings
  6496.         next unless timing.frame == frame_index
  6497.         animation_process_timing( timing )
  6498.       end
  6499.       return
  6500.     end
  6501.     return start_animation( @animation ) if @looped_anim
  6502.     dispose_animation()
  6503.   end
  6504.  
  6505.   #--------------------------------------------------------------------------#
  6506.   # * new-method :animation_set_sprites
  6507.   #--------------------------------------------------------------------------#
  6508.   def animation_set_sprites( frame )
  6509.     cell_data = frame.cell_data
  6510.     for i in 0...@cell_count
  6511.       sprite = @animation_sprites[i]
  6512.       next if sprite.nil?()
  6513.       pattern = cell_data[i, 0]
  6514.       if pattern == nil or pattern == -1
  6515.         sprite.visible = false
  6516.         next
  6517.       end  
  6518.       unless self.onScreen?()
  6519.         sprite.visible = false
  6520.         next
  6521.       end  
  6522.       if pattern < 100
  6523.         sprite.bitmap = @animation_bitmap1
  6524.       else
  6525.         sprite.bitmap = @animation_bitmap2
  6526.       end
  6527.       sprite.visible = true
  6528.       sprite.src_rect.set( pattern % 5 * 192,
  6529.         pattern % 100 / 5 * 192, 192, 192 )
  6530.       if @animation_mirror
  6531.         sprite.x = @animation_ox - cell_data[i, 1]
  6532.         sprite.y = @animation_oy + cell_data[i, 2]
  6533.         sprite.angle = (360 - cell_data[i, 4])
  6534.         sprite.mirror = (cell_data[i, 5] == 0)
  6535.       else
  6536.         sprite.x = @animation_ox + cell_data[i, 1]
  6537.         sprite.y = @animation_oy + cell_data[i, 2]
  6538.         sprite.angle = cell_data[i, 4]
  6539.         sprite.mirror = (cell_data[i, 5] == 1)
  6540.       end
  6541.       sprite.z = self.screen_z + 300 + i
  6542.       sprite.ox = 96
  6543.       sprite.oy = 96
  6544.       sprite.zoom_x = cell_data[i, 3] / 100.0
  6545.       sprite.zoom_y = cell_data[i, 3] / 100.0
  6546.       sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  6547.       sprite.blend_type = cell_data[i, 7]
  6548.     end
  6549.   end
  6550.  
  6551.   #--------------------------------------------------------------------------#
  6552.   # * new-method: animation_process_timing
  6553.   #--------------------------------------------------------------------------#
  6554.   def animation_process_timing( timing )
  6555.     timing.se.play()
  6556.     case timing.flash_scope
  6557.     when 1
  6558.       self.flash( timing.flash_color, timing.flash_duration * RATE )
  6559.     when 2
  6560.       self.viewport.flash( timing.flash_color, timing.flash_duration * RATE ) unless self.viewport.nil?()
  6561.     when 3
  6562.       self.flash( nil, timing.flash_duration * RATE )
  6563.     end
  6564.   end
  6565.  
  6566.   #--------------------------------------------------------------------------#
  6567.   # * new-method :update_animation_position
  6568.   #--------------------------------------------------------------------------#  
  6569.   def update_animation_position()
  6570.     unless self.onScreen?()
  6571.       @animation_ox = -Graphics.width
  6572.       @animation_oy = -Graphics.height
  6573.       return
  6574.     end
  6575.     if @animation.position == 3
  6576.       if self.viewport.nil?()
  6577.         @animation_ox = Integer(Graphics.width) / 2
  6578.         @animation_oy = Integer(Graphics.height) / 2
  6579.       else
  6580.         @animation_ox = self.viewport.rect.width / 2
  6581.         @animation_oy = self.viewport.rect.height / 2
  6582.       end
  6583.     else
  6584.       @animation_ox = self.screen_x + self.ox + self.width / 2
  6585.       @animation_oy = self.screen_y + self.oy + self.height / 2
  6586.       if @animation.position == 0
  6587.         @animation_oy -= self.height / 2
  6588.       elsif @animation.position == 2
  6589.         @animation_oy += self.height / 2
  6590.       end
  6591.     end
  6592.   end
  6593.  
  6594. end
  6595.  
  6596. #==============================================================================#
  6597. # ** YGG::Sprites::Pos
  6598. #==============================================================================#
  6599. class YGG::Sprites::Pos < ::Sprite
  6600.  
  6601. # // Customize Start  
  6602.   #--------------------------------------------------------------------------#
  6603.   # * Constant(s)
  6604.   #--------------------------------------------------------------------------#
  6605.   COLOR1    = Color.new( 128, 128, 255 ) # Main Color
  6606.   COLOR2    = Color.new( 255, 178, 178 ) # Flash Color
  6607.   FLASHTIME = 60
  6608. # // Customize End  
  6609.   #--------------------------------------------------------------------------#
  6610.   # * Public Instance Variable(s)
  6611.   #--------------------------------------------------------------------------#
  6612.   attr_accessor :completed
  6613.   attr_accessor :pos_data
  6614.  
  6615.   #--------------------------------------------------------------------------#
  6616.   # * super-method :initialize
  6617.   #--------------------------------------------------------------------------#
  6618.   def initialize( pos_data, viewport = nil )
  6619.     @completed    = false
  6620.     super( viewport )
  6621.     @use_sprite = true
  6622.     @pos_data = pos_data
  6623.     self.x = @pos_data.screen_x ; self.y = @pos_data.screen_y
  6624.     self.z = 1
  6625.     self.bitmap = Bitmap.new( 32, 32 )
  6626.     rect = Rect.new(1, 1, 30, 30)
  6627.     self.bitmap.fill_rect( rect, COLOR1 )
  6628.     self.ox = 16 ; self.oy = 32
  6629.   end
  6630.  
  6631.   #--------------------------------------------------------------------------#
  6632.   # * super-method :update
  6633.   #--------------------------------------------------------------------------#
  6634.   def update()
  6635.     return if @completed
  6636.     self.x = @pos_data.screen_x()
  6637.     self.y = @pos_data.screen_y()
  6638.     self.z = @pos_data.screen_z()
  6639.     case @pos_data.fader_type
  6640.     when 0
  6641.       self.opacity -= 255 / @pos_data.fade_max
  6642.       @pos_data.fade_amount -= 1 unless @pos_data.fade_amount == 0
  6643.       @completed = true if @pos_data.fade_amount == 0
  6644.     end  
  6645.     super()
  6646.   end
  6647.  
  6648. end
  6649.  
  6650. #==============================================================================#
  6651. # ** YGG::Sprites::Icon
  6652. #==============================================================================#
  6653. class YGG::Sprites::Icon < ::Sprite
  6654.  
  6655.   #--------------------------------------------------------------------------#
  6656.   # * Public Instance Variable(s)
  6657.   #--------------------------------------------------------------------------#  
  6658.   ICON_WIDTH  = 24
  6659.   ICON_HEIGHT = 24
  6660.  
  6661.   #--------------------------------------------------------------------------#
  6662.   # * Public Instance Variable(s)
  6663.   #--------------------------------------------------------------------------#  
  6664.   attr_accessor :ref_object
  6665.  
  6666.   #--------------------------------------------------------------------------#
  6667.   # * super-method :initialize
  6668.   #--------------------------------------------------------------------------#  
  6669.   def initialize( viewport, ref_object )
  6670.     super( viewport )
  6671.     @ref_object = ref_object
  6672.     self.bitmap = Cache.system( "Iconset" )
  6673.     @icon_index = -1
  6674.     update_bitmap()
  6675.   end
  6676.  
  6677.   #--------------------------------------------------------------------------#
  6678.   # * super-method :update
  6679.   #--------------------------------------------------------------------------#
  6680.   def update()
  6681.     super() ; update_bitmap() ; update_position()
  6682.   end
  6683.  
  6684.   #--------------------------------------------------------------------------#
  6685.   # * new-method :update_position
  6686.   #--------------------------------------------------------------------------#
  6687.   def update_position()
  6688.     self.x = @ref_object.screen_x
  6689.     self.y = @ref_object.screen_y
  6690.     self.z = @ref_object.screen_z
  6691.   end
  6692.  
  6693.   #--------------------------------------------------------------------------#
  6694.   # * new-method :update_bitmap
  6695.   #--------------------------------------------------------------------------#
  6696.   def update_bitmap()
  6697.     if @ref_object.icon_index != @icon_index
  6698.       @icon_index = @ref_object.icon_index
  6699.       self.src_rect.set(
  6700.        @icon_index % 16 * ICON_WIDTH ,
  6701.        @icon_index / 16 * ICON_HEIGHT,
  6702.        ICON_WIDTH, ICON_HEIGHT )
  6703.     end
  6704.   end
  6705.  
  6706. end  
  6707.  
  6708. #==============================================================================#
  6709. # ** YGG::Sprites::EquipIcon
  6710. #==============================================================================#
  6711. class YGG::Sprites::EquipIcon < ::YGG::Sprites::Icon
  6712.  
  6713.   #--------------------------------------------------------------------------#
  6714.   # * super-method :initialize
  6715.   #--------------------------------------------------------------------------#
  6716.   def initialize( viewport, character, eqhnd_id )
  6717.     @eqhnd_id = eqhnd_id
  6718.     @parent   = character
  6719.     super( viewport, equip_handle() )
  6720.   end
  6721.  
  6722.   #--------------------------------------------------------------------------#
  6723.   # * overwrite-method :equip_handle
  6724.   #--------------------------------------------------------------------------#
  6725.   def equip_handle() ; return @parent.character.equip_handle( @eqhnd_id ) ; end
  6726.    
  6727.   #--------------------------------------------------------------------------#
  6728.   # * overwrite-method :update_position
  6729.   #--------------------------------------------------------------------------#
  6730.   def update_position()
  6731.     self.ox, self.oy = @ref_object.sox, @ref_object.soy
  6732.     self.x = @parent.x + @ref_object.ox
  6733.     self.y = @parent.y + @ref_object.oy
  6734.     self.z = @parent.z + @ref_object.oz
  6735.   end
  6736.  
  6737.   #--------------------------------------------------------------------------#
  6738.   # * new-method :update_angle
  6739.   #--------------------------------------------------------------------------#
  6740.   def update_angle()
  6741.     self.angle  = @ref_object.angle
  6742.     self.mirror = @ref_object.mirror
  6743.   end
  6744.  
  6745.   #--------------------------------------------------------------------------#
  6746.   # * new-method :update_visible
  6747.   #--------------------------------------------------------------------------#
  6748.   def update_visible()
  6749.     self.visible = @ref_object.visible
  6750.     self.opacity = @ref_object.opacity
  6751.   end
  6752.  
  6753.   #--------------------------------------------------------------------------#
  6754.   # * super-method :update
  6755.   #--------------------------------------------------------------------------#
  6756.   def update()
  6757.     @ref_object = equip_handle()
  6758.     super()
  6759.     update_angle()
  6760.     update_visible()
  6761.   end
  6762.  
  6763. end
  6764.  
  6765. #==============================================================================#
  6766. # ** YGG::Sprites::CharacterIcon
  6767. #==============================================================================#
  6768. class YGG::Sprites::CharacterIcon < ::YGG::Sprites::Icon
  6769.  
  6770.   #--------------------------------------------------------------------------#
  6771.   # * Public Instance Variable(s)
  6772.   #--------------------------------------------------------------------------#
  6773.   attr_accessor :self_timeout
  6774.  
  6775.   #--------------------------------------------------------------------------#
  6776.   # * super-method :initialize
  6777.   #--------------------------------------------------------------------------#
  6778.   def initialize( viewport, character = nil )
  6779.     super( viewport, character )
  6780.     @icon_index = 0
  6781.     self.ox = 12
  6782.     self.oy = 24
  6783.     @ready_to_remove = false
  6784.     @self_timeout = 120
  6785.     update
  6786.   end
  6787.  
  6788.   #--------------------------------------------------------------------------#
  6789.   # * new-method :ready_to_remove?
  6790.   #--------------------------------------------------------------------------#
  6791.   def ready_to_remove?() ; return @ready_to_remove ; end
  6792.  
  6793.   #--------------------------------------------------------------------------#
  6794.   # * super-method :update
  6795.   #--------------------------------------------------------------------------#
  6796.   def update()
  6797.     super()
  6798.     @self_timeout    = @ref_object.icon_time_out
  6799.     @ready_to_remove = true if @self_timeout == 0
  6800.     self.visible     = @ref_object.visible
  6801.     self.opacity     = @ref_object.opacity
  6802.   end
  6803.  
  6804. end
  6805.  
  6806. #==============================================================================#
  6807. # ** Sprite_Character
  6808. #==============================================================================#
  6809. class Sprite_Character < Sprite_Base
  6810.  
  6811.   #--------------------------------------------------------------------------#
  6812.   # * alias-method :initialize
  6813.   #--------------------------------------------------------------------------#
  6814.   alias :ygg_spc_initialize :initialize unless $@
  6815.   def initialize( *args, &block )
  6816.     ygg_spc_initialize( *args, &block )
  6817.     create_equipment()
  6818.   end
  6819.  
  6820.   #--------------------------------------------------------------------------#
  6821.   # * alias-method :dispose
  6822.   #--------------------------------------------------------------------------#
  6823.   alias :ygg_spc_dispose :dispose unless $@
  6824.   def dispose( *args, &block )
  6825.     ygg_spc_dispose( *args, &block )
  6826.     dispose_equipment()
  6827.   end
  6828.  
  6829.   #--------------------------------------------------------------------------#
  6830.   # * alias-method :update
  6831.   #--------------------------------------------------------------------------#
  6832.   alias :ygg_spc_update :update unless $@
  6833.   def update( *args, &block )
  6834.     ygg_spc_update( *args, &block )
  6835.     unless @equipment.nil?()
  6836.       if @character.use_equipment && @equipment.empty?() ; create_equipment()
  6837.       elsif !@character.use_equipment && !@equipment.empty?() ; dispose_equipment()
  6838.       end
  6839.       update_equipment()
  6840.     end  
  6841.     if $scene.is_a?( Scene_Map )
  6842.       @character.ygg_anims.each { |aid| $scene.push_ygg_anim( aid, @character.x, @character.y ) }
  6843.       @character.ygg_anims.clear()
  6844.     end  
  6845.     self.tone = @character.tone
  6846.     self.zoom_x = @character.zoom_x
  6847.     self.zoom_y = @character.zoom_y
  6848.   end
  6849.  
  6850.   #--------------------------------------------------------------------------#
  6851.   # * new-method :create_equipment
  6852.   #--------------------------------------------------------------------------#
  6853.   def create_equipment()
  6854.     @equipment = []
  6855.     if @character.use_equipment
  6856.       @equipment[0] = YGG::Sprites::EquipIcon.new( self.viewport, self, 0 ) # Weap
  6857.       @equipment[1] = YGG::Sprites::EquipIcon.new( self.viewport, self, 1 ) # Shld
  6858.     end  
  6859.   end
  6860.  
  6861.   #--------------------------------------------------------------------------#
  6862.   # * new-method :dispose_equipment
  6863.   #--------------------------------------------------------------------------#
  6864.   def dispose_equipment()
  6865.     @equipment.each { |e| e.dispose() } ; @equipment.clear()
  6866.   end
  6867.  
  6868.   #--------------------------------------------------------------------------#
  6869.   # * new-method :update_equipment
  6870.   #--------------------------------------------------------------------------#
  6871.   def update_equipment() ; @equipment.each { |e| e.update() } ; end
  6872.  
  6873. end
  6874.  
  6875. #==============================================================================#
  6876. # ** YGG::Sprites::Projectile
  6877. #==============================================================================#
  6878. class ::YGG::Sprites::Projectile < Sprite_Character
  6879.  
  6880.   #--------------------------------------------------------------------------#
  6881.   # * overwrite-method :create_bars
  6882.   #--------------------------------------------------------------------------#  
  6883.   def create_bars()  ; end
  6884.    
  6885.   #--------------------------------------------------------------------------#
  6886.   # * overwrite-method :dispose_bars
  6887.   #--------------------------------------------------------------------------#    
  6888.   def dispose_bars() ; end
  6889.  
  6890.   #--------------------------------------------------------------------------#
  6891.   # * overwrite-method :update_bars
  6892.   #--------------------------------------------------------------------------#    
  6893.   def update_bars()  ; end
  6894.    
  6895. end
  6896.  
  6897. #==============================================================================#
  6898. # ** Spriteset_Map
  6899. #==============================================================================#
  6900. class Spriteset_Map
  6901.  
  6902.   #--------------------------------------------------------------------------#
  6903.   # * Public Instance Variable(s)
  6904.   #--------------------------------------------------------------------------#
  6905.   attr_accessor :anim_viewport # Viewport used by Ygg Anims
  6906.   attr_accessor :character_sprites
  6907.   attr_accessor :projectile_sprites
  6908.   attr_accessor :range_sprites
  6909.   attr_accessor :drop_sprites
  6910.   attr_accessor :ygg_anims
  6911.   attr_accessor :viewport1, :viewport2, :viewport3
  6912.  
  6913.   #--------------------------------------------------------------------------#
  6914.   # * alias-method :initialize
  6915.   #--------------------------------------------------------------------------#
  6916.   alias :ygg_anim_ssm_initialize :initialize unless $@
  6917.   def initialize( *args, &block )
  6918.     ygg_anim_ssm_initialize( *args, &block )
  6919.     @disposed = false
  6920.     create_projectiles()
  6921.     create_anims()
  6922.     create_ranges()
  6923.     create_drops()
  6924.   end
  6925.  
  6926.   #--------------------------------------------------------------------------#
  6927.   # * new-method :get_character
  6928.   #--------------------------------------------------------------------------#
  6929.   def get_character( ev )
  6930.     @character_sprites.each { |s| return s if s.character == ev }
  6931.   end  
  6932.  
  6933.   #--------------------------------------------------------------------------#
  6934.   # * new-method :disposed?
  6935.   #--------------------------------------------------------------------------#
  6936.   def disposed?() ; return @disposed ; end
  6937.    
  6938.   #--------------------------------------------------------------------------#
  6939.   # * alias-method :dispose
  6940.   #--------------------------------------------------------------------------#
  6941.   alias :ygg_anim_ssm_dispose :dispose unless $@
  6942.   def dispose( *args, &block )
  6943.     ygg_anim_ssm_dispose( *args, &block )
  6944.     @projectile_sprites.each { |spr| ; spr.dispose() } unless @projectile_sprites.nil?()
  6945.     @ygg_anims.each { |anim| ; anim.dispose()        } unless @ygg_anims.nil?()
  6946.     @range_sprites.each { |rng| ; rng.dispose()      } unless @range_sprites.nil?()
  6947.     @drop_sprites.each { |dr| ; dr.dispose()         } unless @drop_sprites.nil?()
  6948.     @projectile_sprites = nil ; @ygg_anims          = nil
  6949.     @range_sprites      = nil ; @drop_sprites       = nil
  6950.     @disposed = true
  6951.   end
  6952.  
  6953.   #--------------------------------------------------------------------------#
  6954.   # * new-method :create_drops
  6955.   #--------------------------------------------------------------------------#
  6956.   def create_drops()
  6957.     drops = $game_map.active_drops
  6958.     @drop_sprites = drops.inject([]) { |result, char|
  6959.       spr = YGG::Sprites::CharacterIcon.new( @viewport1, char )
  6960.       spr.self_timeout = char.icon_time_out
  6961.       result.push( spr )
  6962.     }
  6963.   end  
  6964.  
  6965.   #--------------------------------------------------------------------------#
  6966.   # * new-method :create_ranges
  6967.   #--------------------------------------------------------------------------#
  6968.   def create_ranges()
  6969.     @range_sprites = $game_map.active_ranges.inject([]) { |result, range|
  6970.       result.push( YGG::Sprites::Pos.new( range, @viewport1 ) )
  6971.     }
  6972.   end  
  6973.  
  6974.   #--------------------------------------------------------------------------#
  6975.   # * new-method :create_projectiles
  6976.   #--------------------------------------------------------------------------#
  6977.   def create_projectiles()
  6978.     @projectile_sprites = []
  6979.     $game_yggdrasil.new_projectiles.clear()
  6980.     $game_yggdrasil.projectiles.each { |pro| add_projectile_sprite( pro ) }
  6981.   end
  6982.  
  6983.   #--------------------------------------------------------------------------#
  6984.   # * new-method :create_anims
  6985.   #--------------------------------------------------------------------------#
  6986.   def create_anims()
  6987.     @ygg_anims = []
  6988.     for i in 0...YGG::TOTAL_WILD_ANIMS
  6989.       anim = ::YGG::Sprites::Animation.new( @anim_viewport )
  6990.       @ygg_anims.push( anim )
  6991.     end
  6992.   end
  6993.  
  6994.   #--------------------------------------------------------------------------#
  6995.   # * new-method :push_anim
  6996.   #--------------------------------------------------------------------------#
  6997.   def push_anim( anim_id, x, y, targets=[], looped=false )
  6998.     return if @disposed
  6999.     for anim in @ygg_anims#.compact()
  7000.       unless anim.animation?
  7001.         anim.setup_pos( x, y, looped )  
  7002.         anim.play_anim( anim_id,
  7003.           targets.inject([]) { |r, e| r << get_character( e ) } )  
  7004.         return anim
  7005.       end  
  7006.     end
  7007.   end
  7008.  
  7009.   #--------------------------------------------------------------------------#
  7010.   # * new-method :add_projectile_sprite
  7011.   #--------------------------------------------------------------------------#
  7012.   def add_projectile_sprite( projectile )
  7013.     return if @disposed
  7014.     return nil if projectile.nil?()
  7015.     spr = ::YGG::Sprites::Projectile.new( @viewport1, projectile )
  7016.     @projectile_sprites.push( spr )
  7017.     return spr
  7018.   end
  7019.  
  7020.   #--------------------------------------------------------------------------#
  7021.   # * new-method :range
  7022.   #--------------------------------------------------------------------------#
  7023.   def add_range_sprite( range )
  7024.     return if @disposed
  7025.     return nil if range.nil?()
  7026.     sprite = ::YGG::Sprites::Pos.new( range, @viewport1 )
  7027.     @range_sprites.push( sprite )
  7028.     return spr
  7029.   end  
  7030.  
  7031.   #--------------------------------------------------------------------------#
  7032.   # * new-method :add_drop_sprite
  7033.   #--------------------------------------------------------------------------#
  7034.   def add_drop_sprite( char )
  7035.     return if @disposed
  7036.     return nil if char.nil?()
  7037.     spr = YGG::Sprites::CharacterIcon.new( @viewport1, char )
  7038.     spr.self_timeout = char.icon_time_out
  7039.     @drop_sprites.push( spr )
  7040.     return spr
  7041.   end
  7042.  
  7043.   #--------------------------------------------------------------------------#
  7044.   # * alias-method :create_viewports
  7045.   #--------------------------------------------------------------------------#
  7046.   alias :ygg_anim_ssm_create_viewports :create_viewports unless $@
  7047.   def create_viewports( *args, &block )
  7048.     ygg_anim_ssm_create_viewports( *args, &block )
  7049.     @anim_viewport = Viewport.new( 0, 0, Graphics.width, Graphics.height )
  7050.     @anim_viewport.z = 100
  7051.   end
  7052.  
  7053.   #--------------------------------------------------------------------------#
  7054.   # * alias-method :update
  7055.   #--------------------------------------------------------------------------#
  7056.   alias :ygg_anim_ssm_update :update unless $@
  7057.   def update( *args, &block )
  7058.     return if @disposed
  7059.     ygg_anim_ssm_update( *args, &block )  
  7060.     update_anims()       unless @ygg_anims.nil?()
  7061.     update_projectiles() unless @projectile_sprites.nil?()  
  7062.     update_ranges()      unless @range_sprites.nil?()
  7063.     update_drops()       unless @drop_sprites.nil?()
  7064.   end
  7065.  
  7066.   #--------------------------------------------------------------------------#
  7067.   # * new-method :update_anims
  7068.   #--------------------------------------------------------------------------#
  7069.   def update_anims()
  7070.     @ygg_anims.each { |anim| anim.update() if anim.animation?() }
  7071.   end
  7072.  
  7073.   #--------------------------------------------------------------------------#
  7074.   # * new-method :update_projectiles
  7075.   #--------------------------------------------------------------------------#
  7076.   def update_projectiles()
  7077.     unless $game_yggdrasil.new_projectiles.empty?()
  7078.       $game_yggdrasil.new_projectiles.each { |pro| add_projectile_sprite( pro ) }
  7079.       $game_yggdrasil.new_projectiles.clear()
  7080.     end  
  7081.     @projectile_sprites = @projectile_sprites.inject([]) { |result, spr|
  7082.       spr.update() ; spr.dispose() if spr.character.terminated?()
  7083.       result << spr unless spr.disposed?() ; result
  7084.     } unless @projectile_sprites.empty?()
  7085.   end
  7086.  
  7087.   #--------------------------------------------------------------------------#
  7088.   # * new-method :update_ranges
  7089.   #--------------------------------------------------------------------------#
  7090.   def update_ranges()
  7091.     @range_sprites = @range_sprites.inject([]) { |result, rng|
  7092.       ran.update()
  7093.       if ran.completed()
  7094.         $game_map.active_ranges.delete( ran.pos_data ) ; ran.dispose()
  7095.       else ; ran.update() ; end  
  7096.       result << rng unless ran.disposed?() ; result
  7097.     } unless @range_sprites.empty?()
  7098.   end
  7099.  
  7100.   #--------------------------------------------------------------------------#
  7101.   # * new-method :update_drops
  7102.   #--------------------------------------------------------------------------#
  7103.   def update_drops()
  7104.     @drop_sprites = @drop_sprites.inject([]) { |result, dr|
  7105.       dr.ready_to_remove?() ? dr.dispose() : dr.update()
  7106.       result << dr unless dr.disposed?() ; result
  7107.     } unless @drop_sprites.empty?()
  7108.   end
  7109.  
  7110.   #--------------------------------------------------------------------------#
  7111.   # * alias-method :update_viewports
  7112.   #--------------------------------------------------------------------------#
  7113.   alias :ygg_anim_ssm_update_viewports :update_viewports unless $@
  7114.   def update_viewports( *args, &block )
  7115.     ygg_anim_ssm_update_viewports( *args, &block )
  7116.     @anim_viewport.update() unless @anim_viewport.nil?()
  7117.   end
  7118.  
  7119.   #--------------------------------------------------------------------------#
  7120.   # * alias-method :dispose_viewports
  7121.   #--------------------------------------------------------------------------#
  7122.   alias :ygg_anim_ssm_dispose_viewports :dispose_viewports unless $@
  7123.   def dispose_viewports( *args, &block )
  7124.     ygg_anim_ssm_dispose_viewports( *args, &block )
  7125.     @anim_viewport.dispose() unless @anim_viewport.nil?() ; @anim_viewport = nil
  7126.   end
  7127.  
  7128. end
  7129.  
  7130. # // (YGG_SC) - System Code
  7131. #==============================================================================#
  7132. # // Start Yggdrasil Main Code
  7133. #==============================================================================#
  7134. # ** Game System
  7135. #==============================================================================#
  7136. class Game_System
  7137.  
  7138.   #--------------------------------------------------------------------------#
  7139.   # * Public Instance Variable(s)
  7140.   #--------------------------------------------------------------------------#
  7141.   attr_accessor :ygg_hit_count
  7142.   attr_accessor :ygg_hit_down_wait
  7143.  
  7144.   attr_accessor :draw_damage_ranges
  7145.   attr_accessor :gameover_alldead
  7146.  
  7147.   #--------------------------------------------------------------------------#
  7148.   # * alias-method :initialize
  7149.   #--------------------------------------------------------------------------#
  7150.   alias :ygg_gs_initialize :initialize unless $@
  7151.   def initialize( *args, &block )
  7152.     ygg_gs_initialize( *args, &block )
  7153.     @ygg_hit_count      = 0
  7154.     @ygg_hit_down_wait  = 0
  7155.     @draw_damage_ranges = YGG::DRAW_RANGES
  7156.     @gameover_alldead   = YGG::ALL_DEAD_GAMEOVER
  7157.   end
  7158.  
  7159.   #--------------------------------------------------------------------------#
  7160.   # * new-method :gameover_alldead?
  7161.   #--------------------------------------------------------------------------#
  7162.   def gameover_alldead?() ; return @gameover_alldead end
  7163.    
  7164.   #--------------------------------------------------------------------------#
  7165.   # * alias-method :update
  7166.   #--------------------------------------------------------------------------#
  7167.   alias :ygg_gs_update :update unless $@
  7168.   def update( *args, &block )
  7169.     ygg_gs_update( *args, &block )
  7170.     unless $game_message.visible
  7171.       @ygg_hit_down_wait -= 1 unless @ygg_hit_down_wait == 0
  7172.       @ygg_hit_count = 0 if @ygg_hit_down_wait == 0
  7173.     end if $scene.is_a?( Scene_Map )
  7174.   end
  7175.  
  7176.   #--------------------------------------------------------------------------#
  7177.   # * mew-method :control_self_switch
  7178.   #--------------------------------------------------------------------------#
  7179.   def control_self_switch( map_id, event_id, switch, value )
  7180.     $game_self_switches[[map_id, event_id, switch]] = value
  7181.     $game_map.need_refresh = true
  7182.   end
  7183.  
  7184.   #--------------------------------------------------------------------------#
  7185.   # * new-method :yggdrasil_on?
  7186.   #--------------------------------------------------------------------------#
  7187.   def yggdrasil_on?() ; return $game_yggdrasil.on?() ; end
  7188.    
  7189. end
  7190.  
  7191. #==============================================================================#
  7192. # ** Game Battler
  7193. #==============================================================================#
  7194. class Game_Battler
  7195.  
  7196.   #--------------------------------------------------------------------------#
  7197.   # * Public Instance Variable(s)
  7198.   #--------------------------------------------------------------------------#
  7199.   attr_accessor :character_need_refresh
  7200.   attr_accessor :ygg_slip_counter
  7201.  
  7202.   attr_accessor :ygg_engage
  7203.  
  7204.   attr_accessor :skill_slot_size, :item_slot_size
  7205.  
  7206.   #--------------------------------------------------------------------------#
  7207.   # * alias-method :initialize
  7208.   #--------------------------------------------------------------------------#
  7209.   alias :ygg_gb_initialize :initialize unless $@
  7210.   def initialize( *args, &block )
  7211.     ygg_gb_initialize( *args, &block )
  7212.     @state_ticks      = {}
  7213.     @ygg_slip_counter = 0
  7214.     @ygg_engage       = ::YGG::Handlers::Engage.new( self )
  7215.     @skill_slot_size, @item_slot_size =  5, 5
  7216.     @skill_slots    , @item_slots     = [], []
  7217.     @skill_handles  , @item_handles   = {}, {}
  7218.     @cooldown, @cooldown_max, = 0, 300
  7219.     clear_stat_cache()
  7220.     clear_item_slots()
  7221.     clear_skill_slots()
  7222.   end
  7223.  
  7224.   #--------------------------------------------------------------------------#
  7225.   # * overwrite-method :skill_can_use?
  7226.   #--------------------------------------------------------------------------#
  7227.   def skill_can_use?( skill )
  7228.     return false unless skill.is_a?( RPG::Skill )
  7229.     return false unless movable?()
  7230.     return false if silent?() and skill.spi_f > 0
  7231.     return false if calc_mp_cost( skill ) > mp
  7232.     if $game_temp.in_battle  
  7233.       return skill.battle_ok?()
  7234.     elsif $game_system.yggdrasil_on?() and $scene.is_a?( Scene_Map )
  7235.       return skill.battle_ok?()
  7236.     else
  7237.       return skill.menu_ok?()
  7238.     end
  7239.   end
  7240.    
  7241.   #--------------------------------------------------------------------------#
  7242.   # * new-method :get_action_by_id
  7243.   #--------------------------------------------------------------------------#
  7244.   def get_action_by_id( id )
  7245.     return []
  7246.   end
  7247.  
  7248.   #--------------------------------------------------------------------------#
  7249.   # ** new-method :ygg_range
  7250.   #--------------------------------------------------------------------------#
  7251.   def ygg_range ; return 0 end
  7252.  
  7253.   #--------------------------------------------------------------------------#
  7254.   # ** new-method :drops_attraction?
  7255.   #--------------------------------------------------------------------------#
  7256.   def drops_attraction? ; return false end
  7257.    
  7258.   #--------------------------------------------------------------------------#
  7259.   # ** new-method :equip_icon
  7260.   #--------------------------------------------------------------------------#
  7261.   def equip_icon( eq_id ) ; return 0 ; end
  7262.    
  7263.   #--------------------------------------------------------------------------#
  7264.   # * new-method :equip_atk_act_name
  7265.   #--------------------------------------------------------------------------#    
  7266.   def equip_atk_act_name( eq_id ) ; return "" ; end
  7267.  
  7268.   #--------------------------------------------------------------------------#
  7269.   # * new-method :equip_grd_act_name
  7270.   #--------------------------------------------------------------------------#    
  7271.   def equip_grd_act_name( eq_id ) ; return "" ; end
  7272.  
  7273.   #--------------------------------------------------------------------------#
  7274.   # * alias-method :maxhp/maxmp/atk/def/spi/agi
  7275.   #--------------------------------------------------------------------------#    
  7276.   [:maxhp, :maxmp, :atk, :def, :spi, :agi].each { |m|  
  7277.     module_eval( %Q(
  7278.     alias :ygg_gb_#{m.to_s} #{m} unless $@
  7279.     def #{m.to_s}( *args, &block )
  7280.       @cached_#{m.to_s} ||= ygg_gb_#{m.to_s}( *args, &block )
  7281.       return @cached_#{m.to_s}  
  7282.     end  
  7283.    
  7284.     alias :ygg_gb_#{m.to_s}_set #{m}= unless $@
  7285.     def #{m.to_s}=( new_value )
  7286.       @cached_#{m.to_s} = nil if new_value != @cached_#{m.to_s}
  7287.       ygg_gb_#{m.to_s}_set( new_value )
  7288.     end
  7289.     ) )
  7290.   }  
  7291.  
  7292.   #--------------------------------------------------------------------------#
  7293.   # * new-method :clear_stat_cache
  7294.   #--------------------------------------------------------------------------#  
  7295.   def clear_stat_cache()
  7296.     @cached_maxhp = nil
  7297.     @cached_maxmp = nil
  7298.     @cached_atk   = nil
  7299.     @cached_def   = nil
  7300.     @cached_spi   = nil
  7301.     @cached_agi   = nil
  7302.    
  7303.     @cached_move  = nil
  7304.     @cached_tone  = nil
  7305.     @cached_slip  = nil
  7306.     @cached_slip_freq = nil
  7307.    
  7308.     @cached_level_exp = nil
  7309.     @cached_next_level_exp = nil
  7310.    
  7311.     @character_need_refresh = true
  7312.   end
  7313.  
  7314.   #--------------------------------------------------------------------------#
  7315.   # * alias-method :recover_all
  7316.   #--------------------------------------------------------------------------#
  7317.   alias :ygg_gb_recover_all :recover_all unless $@
  7318.   def recover_all( *args, &block )
  7319.     clear_stat_cache()
  7320.     ygg_gb_recover_all( *args, &block )
  7321.   end
  7322.  
  7323. if ::YGG::FULL_INTEGRATION  
  7324.  
  7325.   #--------------------------------------------------------------------------#
  7326.   # * alias-method :add_state
  7327.   #--------------------------------------------------------------------------#  
  7328.   alias :ygg_gb_fi_add_state :add_state unless $@
  7329.   def add_state( state_id )
  7330.     sti = state_ignore?( state_id )
  7331.     ygg_gb_fi_add_state( state_id )
  7332.     state = $data_states[state_id]        
  7333.     return if state.nil?() ; return if sti
  7334.     @state_ticks[state_id] = state.hold_ticks unless state.id == 1
  7335.   end
  7336.  
  7337.   #--------------------------------------------------------------------------#
  7338.   # * alias-method :remove_state
  7339.   #--------------------------------------------------------------------------#  
  7340.   alias :ygg_gb_fi_remove_state :remove_state unless $@
  7341.   def remove_state( state_id )
  7342.     ygg_gb_fi_remove_state( state_id )
  7343.     @state_ticks.delete( state_id )
  7344.   end
  7345.  
  7346.   #--------------------------------------------------------------------------#
  7347.   # * alias-method :update_state_ticks
  7348.   #--------------------------------------------------------------------------#
  7349.   def update_state_ticks()
  7350.     @state_ticks.keys.clone.each { |key|
  7351.       state = $data_states[key]
  7352.       if state.nil?() ; @state_ticks.delete(key) ; next ; end
  7353.       @state_ticks[key] -= 1
  7354.       remove_state( key ) if @state_ticks[key] < 0 && rand(100) < state.auto_release_prob
  7355.     }
  7356.   end  
  7357.  
  7358.   #--------------------------------------------------------------------------#
  7359.   # * overwrite-method :slip_damage?
  7360.   #--------------------------------------------------------------------------#  
  7361.   def slip_damage?()
  7362.     @cached_slip ||= self.states.any?() { |s| s.slip_damage }
  7363.     return @cached_slip
  7364.   end
  7365.  
  7366.   #--------------------------------------------------------------------------#
  7367.   # * overwrite-method :slip_damage_effect
  7368.   #--------------------------------------------------------------------------#  
  7369.   def slip_damage_effect()
  7370.     self.hp -= 1 if slip_damage? and @hp > 0
  7371.   end
  7372.  
  7373. end # // Full Integration
  7374.  
  7375.   #--------------------------------------------------------------------------#
  7376.   # * overwrite-method :item_growth_effect
  7377.   #--------------------------------------------------------------------------#
  7378.   def item_growth_effect( user, item )
  7379.     if item.parameter_type > 0 and item.parameter_points != 0
  7380.       case item.parameter_type
  7381.       when 1  # Maximum HP
  7382.         @maxhp_plus += item.parameter_points
  7383.         @cached_maxhp = nil
  7384.       when 2  # Maximum MP
  7385.         @maxmp_plus += item.parameter_points
  7386.         @cached_maxmp = nil
  7387.       when 3  # Attack
  7388.         @atk_plus += item.parameter_points
  7389.         @cached_atk = nil
  7390.       when 4  # Defense
  7391.         @def_plus += item.parameter_points
  7392.         @cached_def = nil
  7393.       when 5  # Spirit
  7394.         @spi_plus += item.parameter_points
  7395.         @cached_spi = nil
  7396.       when 6  # Agility
  7397.         @agi_plus += item.parameter_points
  7398.         @cached_agi = nil
  7399.       end
  7400.     end
  7401.   end
  7402.  
  7403.   #--------------------------------------------------------------------------#
  7404.   # * alias-method :add_state
  7405.   #--------------------------------------------------------------------------#  
  7406.   alias :ygg_gb_add_state :add_state unless $@
  7407.   def add_state( *args, &block )
  7408.     old_states = self.states
  7409.     ygg_gb_add_state( *args, &block )
  7410.     clear_stat_cache() unless self.states == old_states
  7411.   end
  7412.  
  7413.   #--------------------------------------------------------------------------#
  7414.   # * alias-method :remove_state
  7415.   #--------------------------------------------------------------------------#  
  7416.   alias :ygg_gb_remove_state :remove_state unless $@
  7417.   def remove_state( *args, &block )
  7418.     old_states = self.states
  7419.     ygg_gb_remove_state( *args, &block )
  7420.     clear_stat_cache() unless self.states == old_states
  7421.   end
  7422.  
  7423.   #--------------------------------------------------------------------------#
  7424.   # * new-method :move_mod
  7425.   #--------------------------------------------------------------------------#  
  7426.   def move_mod()
  7427.     @cached_move ||= self.states.inject(0) { |r, s| r+s.move_mod }
  7428.     return @cached_move
  7429.   end
  7430.  
  7431.   #--------------------------------------------------------------------------#
  7432.   # * new-method :effect_tone
  7433.   #--------------------------------------------------------------------------#  
  7434.   def effect_tone()
  7435.     if @cached_tone.nil?()
  7436.       @cached_tone = ::Tone.new( 0, 0, 0, 0 )
  7437.       self.states.each { |s|
  7438.         if s.tone_effect ; @cached_tone = s.effect_tone ; break ; end }  
  7439.     end  
  7440.     return @cached_tone
  7441.   end
  7442.  
  7443.   #--------------------------------------------------------------------------#
  7444.   # * new-method :slip_frequency
  7445.   #--------------------------------------------------------------------------#  
  7446.   def slip_frequency()
  7447.     if @cached_slip_freq.nil?()
  7448.       r = 1 ; count = 1
  7449.       self.states.each { |s|
  7450.         if s.slip_freq != 0
  7451.           count += 1 ; r += s.slip_freq
  7452.         end  
  7453.       }  
  7454.       @cached_slip_freq = r / count
  7455.     end  
  7456.     return @cached_slip_freq
  7457.   end
  7458.  
  7459.   #--------------------------------------------------------------------------#
  7460.   # * new-method :update_states
  7461.   #--------------------------------------------------------------------------#  
  7462. if ::YGG::FULL_INTEGRATION
  7463.  
  7464.   def update_states()
  7465.     update_state_ticks()
  7466.     update_slip_damage()  if (Graphics.frame_count % slip_frequency) == 0
  7467.   end
  7468.  
  7469. else  
  7470.  
  7471.   def update_states()
  7472.     @ygg_slip_counter = [@ygg_slip_counter-1, 0].max
  7473.     if @ygg_slip_counter == 0
  7474.       remove_states_auto() ; update_slip_damage()
  7475.       @ygg_slip_counter = YGG::STATE_TURN_COUNTER        
  7476.     end
  7477.   end
  7478.  
  7479. end
  7480.  
  7481.   #--------------------------------------------------------------------------#
  7482.   # * new-method :update_slip_damage
  7483.   #--------------------------------------------------------------------------#
  7484.   def update_slip_damage()
  7485.     if slip_damage?()
  7486.       slip_damage_effect() ; self.ygg_engage.engage( 30 )
  7487.     end  
  7488.   end
  7489.  
  7490.   #--------------------------------------------------------------------------#
  7491.   # * new-method :skill_slot_valid?
  7492.   #--------------------------------------------------------------------------#
  7493.   def skill_slot_valid?( i )
  7494.     return i.between?( 0, @skill_slot_size-1 )
  7495.   end
  7496.  
  7497.   #--------------------------------------------------------------------------#
  7498.   # * new-method :item_slot_valid?
  7499.   #--------------------------------------------------------------------------#
  7500.   def item_slot_valid?( i )
  7501.     return i.between?( 0, @item_slot_size-1 )
  7502.   end
  7503.  
  7504.   #--------------------------------------------------------------------------#
  7505.   # * new-method :skill_slot
  7506.   #--------------------------------------------------------------------------#
  7507.   def skill_slot( i )
  7508.     return nil unless skill_slot_valid?( i )
  7509.     return $data_skills[(@skill_slots[i].obj_id)]
  7510.   end
  7511.  
  7512.   #--------------------------------------------------------------------------#
  7513.   # * new-method :skill_slots
  7514.   #--------------------------------------------------------------------------#
  7515.   def skill_slot_skills()
  7516.     result = []
  7517.     @skill_slot_size.times { |i| result << skill_slot( i ) } ; return result
  7518.   end
  7519.  
  7520.   #--------------------------------------------------------------------------#
  7521.   # * new-method :item_slot
  7522.   #--------------------------------------------------------------------------#
  7523.   def item_slot( i )
  7524.     return nil unless item_slot_valid?( i )
  7525.     return $data_items[(@item_slots[i].obj_id)]
  7526.   end
  7527.  
  7528.   #--------------------------------------------------------------------------#
  7529.   # * new-method :item_slot_items
  7530.   #--------------------------------------------------------------------------#
  7531.   def item_slot_items()
  7532.     result = []
  7533.     @item_slot_size.times { |i| result << item_slot( i ) } ; return result
  7534.   end
  7535.  
  7536.   #--------------------------------------------------------------------------#
  7537.   # * new-method :set_skill_slot
  7538.   #--------------------------------------------------------------------------#
  7539.   def set_skill_slot( i, sid )
  7540.     return unless skill_slot_valid?( i )
  7541.     @skill_slots[i] = get_skill_handle( sid )
  7542.   end
  7543.  
  7544.   #--------------------------------------------------------------------------#
  7545.   # * new-method :set_item_slot
  7546.   #--------------------------------------------------------------------------#
  7547.   def set_item_slot( i, iid )
  7548.     return unless item_slot_valid?( i )
  7549.     @item_slots[i] = get_item_handle( iid )
  7550.   end
  7551.  
  7552.   #--------------------------------------------------------------------------#
  7553.   # * new-method :clear_skill_slots
  7554.   #--------------------------------------------------------------------------#  
  7555.   def clear_skill_slots()
  7556.     @skill_slot_size.times { |i| set_skill_slot( i, 0 ) }
  7557.   end
  7558.  
  7559.   #--------------------------------------------------------------------------#
  7560.   # * new-method :clear_item_slots
  7561.   #--------------------------------------------------------------------------#  
  7562.   def clear_item_slots()  
  7563.     @item_slot_size.times { |i| set_item_slot( i, 0 ) }
  7564.   end
  7565.  
  7566.   #--------------------------------------------------------------------------#
  7567.   # * new-method :get_skill_handle
  7568.   #--------------------------------------------------------------------------#
  7569.   def get_skill_handle( sid )  
  7570.     @skill_handles[sid] ||= ::YGG::Handlers::BattleObj.new( sid, :skill )
  7571.     return @skill_handles[sid]
  7572.   end  
  7573.  
  7574.   #--------------------------------------------------------------------------#
  7575.   # * new-method :get_item_handle
  7576.   #--------------------------------------------------------------------------#
  7577.   def get_item_handle( iid )  
  7578.     @item_handles[iid] ||= ::YGG::Handlers::BattleObj.new( iid, :item )
  7579.     return @item_handles[iid]
  7580.   end  
  7581.  
  7582.   #--------------------------------------------------------------------------#
  7583.   # * new-method :update_obj_handles
  7584.   #--------------------------------------------------------------------------#
  7585.   def update_obj_handles()
  7586.     (@skill_slots+@item_slots).each { |hnd| hnd.update() }
  7587.   end
  7588.  
  7589.   #--------------------------------------------------------------------------#
  7590.   # * new-method :cooldown
  7591.   #--------------------------------------------------------------------------#
  7592.   attr_reader :cooldown
  7593.  
  7594.   #--------------------------------------------------------------------------#
  7595.   # * new-method :cooldown=
  7596.   #--------------------------------------------------------------------------#
  7597.   def cooldown=( cool )
  7598.     @cooldown = [cool, @cooldown_max].min
  7599.   end
  7600.  
  7601.   #--------------------------------------------------------------------------#
  7602.   # * new-method :cooldown_max
  7603.   #--------------------------------------------------------------------------#
  7604.   def cooldown_max() ; @cooldown_max ; end
  7605.  
  7606.   #--------------------------------------------------------------------------#
  7607.   # * new-method :cap_cooldown
  7608.   #--------------------------------------------------------------------------#
  7609.   def cap_cooldown()
  7610.     @cooldown = @cooldown_max
  7611.   end
  7612.  
  7613.   #--------------------------------------------------------------------------#
  7614.   # * new-method :update_cooldown
  7615.   #--------------------------------------------------------------------------#
  7616.   def update_cooldown()
  7617.     @cooldown = [@cooldown - 1, 0].max
  7618.   end
  7619.  
  7620.   #--------------------------------------------------------------------------#
  7621.   # * new-method :cooling_down?
  7622.   #--------------------------------------------------------------------------#
  7623.   def cooling_down?() ; return @cooldown > 0 ; end
  7624.  
  7625.   #--------------------------------------------------------------------------#
  7626.   # * new-method :ygg_can_attack?
  7627.   #--------------------------------------------------------------------------#
  7628.   def ygg_can_attack?() ;
  7629.     return false if cooling_down?()
  7630.     return true
  7631.   end
  7632.  
  7633.   #--------------------------------------------------------------------------#
  7634.   # * new-method :ygg_skill_can_use?
  7635.   #--------------------------------------------------------------------------#
  7636.   def ygg_skill_can_use?( obj )
  7637.     return false if cooling_down?()
  7638.     return false unless skill_can_use?( obj )
  7639.     return get_skill_handle( obj.id ).can_use?()
  7640.   end
  7641.  
  7642.   #--------------------------------------------------------------------------#
  7643.   # * new-method :ygg_item_can_use?
  7644.   #--------------------------------------------------------------------------#
  7645.   def ygg_item_can_use?( obj )
  7646.     return false if cooling_down?()
  7647.     return false unless item_can_use?( obj )
  7648.     return get_item_handle( obj.id ).can_use?()
  7649.   end
  7650.  
  7651.   #--------------------------------------------------------------------------#
  7652.   # * new-method :item_can_use?
  7653.   #--------------------------------------------------------------------------#
  7654.   def item_can_use?( obj )
  7655.     return $game_party.item_can_use?( obj )
  7656.   end unless method_defined? :item_can_use?
  7657.  
  7658.   #--------------------------------------------------------------------------#
  7659.   # * new-method :ygg_use_skill
  7660.   #--------------------------------------------------------------------------#
  7661.   def ygg_use_skill( obj )
  7662.     self.mp -= calc_mp_cost( obj )
  7663.   end
  7664.  
  7665.   #--------------------------------------------------------------------------#
  7666.   # * new-method :ygg_use_item
  7667.   #--------------------------------------------------------------------------#
  7668.   def ygg_use_item( obj )
  7669.     $game_party.consume_item( obj )
  7670.   end
  7671.  
  7672. end
  7673.  
  7674. #==============================================================================#
  7675. # ** Game Actor
  7676. #==============================================================================#
  7677. class Game_Actor < Game_Battler
  7678.  
  7679.   #--------------------------------------------------------------------------#
  7680.   # * alias-method :level_up
  7681.   #--------------------------------------------------------------------------#  
  7682.   alias :ygg_gb_level_up :level_up unless $@
  7683.   def level_up( *args, &block )
  7684.     clear_stat_cache()
  7685.     ygg_gb_level_up( *args, &block )
  7686.     clear_stat_cache()
  7687.   end
  7688.  
  7689.   #--------------------------------------------------------------------------#
  7690.   # * alias-method :level_down
  7691.   #--------------------------------------------------------------------------#  
  7692.   alias :ygg_gb_level_down :level_down unless $@
  7693.   def level_down( *args, &block )
  7694.     clear_stat_cache()
  7695.     ygg_gb_level_down( *args, &block )
  7696.     clear_stat_cache()
  7697.   end
  7698.  
  7699.   #--------------------------------------------------------------------------#
  7700.   # * alias-method :change_equip
  7701.   #--------------------------------------------------------------------------#  
  7702.   alias :ygg_gb_change_equip :change_equip unless $@
  7703.   def change_equip( *args, &block )
  7704.     clear_stat_cache()
  7705.     ygg_gb_change_equip( *args, &block )
  7706.     clear_stat_cache()
  7707.   end
  7708.  
  7709.   #--------------------------------------------------------------------------#
  7710.   # * ygg_target_range
  7711.   #--------------------------------------------------------------------------#
  7712.   def ygg_target_range()
  7713.     eq = weapons[0]
  7714.     eq.nil?() ? 0 : eq.ygg_target_range
  7715.   end  
  7716.    
  7717.   #--------------------------------------------------------------------------#
  7718.   # * new-method :drops_attraction?
  7719.   #--------------------------------------------------------------------------#
  7720.   def drops_attraction?() ; equips.compact.any? { |eq| eq.drops_attraction?() } ; end
  7721.    
  7722.   #--------------------------------------------------------------------------#
  7723.   # * new-method :equip_icon
  7724.   #--------------------------------------------------------------------------#
  7725.   def equip_icon( eq_id )
  7726.     if self.two_swords_style
  7727.       weps = weapons
  7728.       return weps[eq_id].nil?() ? 0 : weps[eq_id].icon_index
  7729.     else
  7730.       weps = [weapons[0], armors[0]]
  7731.       return weps[eq_id].nil?() ? 0 : weps[eq_id].icon_index
  7732.     end  
  7733.   end
  7734.  
  7735.   #--------------------------------------------------------------------------#
  7736.   # * new-method :equip_atk_act_name
  7737.   #--------------------------------------------------------------------------#    
  7738.   def equip_atk_act_name( eq_id )
  7739.     if self.two_swords_style
  7740.       weps = weapons
  7741.     else
  7742.       weps = [weapons[0], armors[0]]
  7743.     end
  7744.     return weps[eq_id].nil?() ? "" : weps[eq_id].atk_act_name
  7745.   end
  7746.  
  7747.   #--------------------------------------------------------------------------#
  7748.   # * new-method :equip_grd_act_name
  7749.   #--------------------------------------------------------------------------#    
  7750.   def equip_grd_act_name( eq_id )
  7751.     if self.two_swords_style
  7752.       weps = weapons
  7753.     else
  7754.       weps = [weapons[0], armors[0]]
  7755.     end
  7756.     return weps[eq_id].nil?() ? "" : weps[eq_id].grd_act_name
  7757.   end
  7758.  
  7759.   #--------------------------------------------------------------------------#
  7760.   # * alias-method :change_exp
  7761.   #--------------------------------------------------------------------------#    
  7762.   alias :ygg_gb_change_exp :change_exp unless $@
  7763.   def change_exp( *args, &block )
  7764.     ygg_gb_change_exp( *args, &block )
  7765.     @cached_level_exp = nil
  7766.     @cached_next_level_exp = nil
  7767.   end
  7768.  
  7769.   #--------------------------------------------------------------------------#
  7770.   # * new-method :level_exp
  7771.   #--------------------------------------------------------------------------#    
  7772.   def level_exp()
  7773.     @cached_level_exp ||= @exp - @exp_list[@level]
  7774.     return @cached_level_exp
  7775.   end
  7776.  
  7777.   #--------------------------------------------------------------------------#
  7778.   # * new-method :next_level_exp
  7779.   #--------------------------------------------------------------------------#  
  7780.   def next_level_exp()
  7781.     @cached_next_level_exp ||= @exp_list[@level+1] - @exp_list[@level]
  7782.     return @cached_next_level_exp
  7783.   end
  7784.  
  7785. end
  7786.  
  7787. #==============================================================================#
  7788. # ** Game Enemy
  7789. #==============================================================================#
  7790. class Game_Enemy < Game_Battler
  7791.  
  7792.   #--------------------------------------------------------------------------#
  7793.   # * alias-method :initialize
  7794.   #--------------------------------------------------------------------------#
  7795.   alias :ygg_gmen_initialize :initialize unless $@
  7796.   def initialize( *args, &block )
  7797.     ygg_gmen_initialize( *args, &block )
  7798.     @skill_slot_size = 0
  7799.     skillz = []
  7800.     enemy.actions.each { |act| if act.kind == 1 ; skillz << act.skill_id ; end }
  7801.     @skill_slot_size = skillz.size
  7802.     for i in 0...@skill_slot_size ; set_skill_slot( i, skillz[i] ) ; end
  7803.   end
  7804.  
  7805.   #--------------------------------------------------------------------------#
  7806.   # * new-method :gain_exp
  7807.   #--------------------------------------------------------------------------#
  7808.   def gain_exp( exp, show ) ; end unless method_defined? :gain_exp
  7809.    
  7810.   #--------------------------------------------------------------------------#
  7811.   # * new-method :get_action_by_id
  7812.   #--------------------------------------------------------------------------#
  7813.   def get_action_by_id( id )
  7814.     return enemy.ygg_actions[id]
  7815.   end
  7816.  
  7817.   #--------------------------------------------------------------------------#
  7818.   # * new-method :all_drops
  7819.   #--------------------------------------------------------------------------#
  7820.   def all_drops()
  7821.     dro = []
  7822.     for di in self.enemy.drop_items.compact
  7823.       next if di.kind == 0 ; next if rand(di.denominator) != 0
  7824.       case di.kind
  7825.       when 1 ; dro.push($data_items[di.item_id])
  7826.       when 2 ; dro.push($data_weapons[di.weapon_id])
  7827.       when 3 ; dro.push($data_armors[di.armor_id])
  7828.       end
  7829.     end
  7830.     more_drops.compact.each { |mri|
  7831.       for num in 1..mri[2] ; dro.push(mri[0]) if rand(mri[1]).to_i == 0 ; end
  7832.     } if $imported["IEX_Rand_Drop"]
  7833.     return dro
  7834.   end  
  7835.  
  7836.   #--------------------------------------------------------------------------#
  7837.   # * new-method :atk_animation_id
  7838.   #--------------------------------------------------------------------------#
  7839.   def atk_animation_id ; return enemy.atk_animation_id ; end
  7840.  
  7841.   #--------------------------------------------------------------------------#
  7842.   # * new-method :atk_animation_id2
  7843.   #--------------------------------------------------------------------------#
  7844.   def atk_animation_id2 ; return enemy.atk_animation_id2 ; end
  7845.  
  7846. end
  7847.  
  7848. #==============================================================================#
  7849. # ** Game_Party
  7850. #==============================================================================#
  7851. class Game_Party
  7852.  
  7853.   #--------------------------------------------------------------------------#
  7854.   # * alias-method :on_player_walk
  7855.   #--------------------------------------------------------------------------#
  7856.   alias :ygg1x6_gmpt_on_player_walk :on_player_walk unless $@
  7857.   def on_player_walk( *args, &block )
  7858.     unless $game_system.yggdrasil_on?()
  7859.       ygg1x6_gmpt_on_player_walk( *args, &block )
  7860.     end  
  7861.   end
  7862.  
  7863.   #--------------------------------------------------------------------------#
  7864.   # * new-method :ygg_slip_damage
  7865.   #--------------------------------------------------------------------------#
  7866.   def ygg_slip_damage()
  7867.     ($game_party.members-[$game_player.ygg_battler]).each { |m| m.update_states() }
  7868.   end
  7869.  
  7870. end  
  7871.  
  7872. #==============================================================================#
  7873. # ** Game Map
  7874. #==============================================================================#
  7875. class Game_Map
  7876.  
  7877.   #--------------------------------------------------------------------------#
  7878.   # * new-method :get_map
  7879.   #--------------------------------------------------------------------------#  
  7880.   def get_map( map_id )
  7881.     return load_data( sprintf("Data/Map%03d.rvdata", map_id) )
  7882.   end unless method_defined? :get_map
  7883.  
  7884.   #--------------------------------------------------------------------------#
  7885.   # * alias-method :setup
  7886.   #--------------------------------------------------------------------------#
  7887.   alias :ygg_gmm_setup :setup unless $@
  7888.   def setup( *args, &block )
  7889.     $game_player.ygg_unregister()
  7890.     ygg_gmm_setup( *args, &block )
  7891.     ygg_setup()
  7892.     $game_player.ygg_register()
  7893.   end
  7894.  
  7895.   #--------------------------------------------------------------------------#
  7896.   # * new-method :ygg_setup
  7897.   #--------------------------------------------------------------------------#
  7898.   def ygg_setup()
  7899.     $game_yggdrasil.setup_map( self.map_id )
  7900.   end
  7901.  
  7902.   #--------------------------------------------------------------------------#
  7903.   # * new-method :setup_itemmap
  7904.   #--------------------------------------------------------------------------#
  7905.   def setup_itemmap()
  7906.     $game_yggdrasil.setup_itemmap()  
  7907.   end
  7908.  
  7909.   #--------------------------------------------------------------------------#
  7910.   # * new-method :create_drops
  7911.   #--------------------------------------------------------------------------#
  7912.   def create_drops( x, y, dropee )
  7913.     $game_yggdrasil.create_drops( x, y, dropee )
  7914.   end  
  7915.  
  7916.   #--------------------------------------------------------------------------#
  7917.   # * new-method :place_drops
  7918.   #--------------------------------------------------------------------------#
  7919.   def place_drops( x, y, item_set, gold = nil )
  7920.     return $game_yggdrasil.place_drops( x, y, item_set, gold )
  7921.   end
  7922.  
  7923.   #--------------------------------------------------------------------------#
  7924.   # * new-method :items_map
  7925.   #--------------------------------------------------------------------------#
  7926.   def items_map() ; return $items_map ; end
  7927.  
  7928.   #--------------------------------------------------------------------------#
  7929.   # * alias-method :update
  7930.   #--------------------------------------------------------------------------#
  7931.   #alias :ygg_gm_update :update unless $@
  7932.   #def update( *args, &block )
  7933.   #  ygg_gm_update( *args, &block )
  7934.   #  update_drops()
  7935.   #end
  7936.  
  7937.   #--------------------------------------------------------------------------#
  7938.   # * new-method :active_drops
  7939.   #--------------------------------------------------------------------------#
  7940.   def active_drops() ; return $game_yggdrasil.active_drops ; end
  7941.    
  7942.   #--------------------------------------------------------------------------#
  7943.   # * new-method :active_ranges
  7944.   #--------------------------------------------------------------------------#  
  7945.   def active_ranges() ; return $game_yggdrasil.active_ranges ; end
  7946.    
  7947.   #--------------------------------------------------------------------------#
  7948.   # * new-method :projectiles
  7949.   #--------------------------------------------------------------------------#  
  7950.   def projectiles() ; return $game_yggdrasil.projectiles ; end
  7951.    
  7952.   #--------------------------------------------------------------------------#
  7953.   # * new-method :drops_xy
  7954.   #--------------------------------------------------------------------------#  
  7955.   def drops_xy( x, y )
  7956.     return $game_yggdrasil.drops_xy( x, y )
  7957.   end
  7958.  
  7959. end
  7960.  
  7961. #==============================================================================#
  7962. # ** Game Event
  7963. #==============================================================================#
  7964. class Game_Event < Game_Character
  7965.  
  7966.   #--------------------------------------------------------------------------#
  7967.   # * alias-method :initialize
  7968.   #--------------------------------------------------------------------------#
  7969.   alias :ygg_ge_initialize :initialize unless $@
  7970.   def initialize( *args, &block )
  7971.     ygg_ge_initialize( *args, &block )
  7972.     @ygg_cache_complete = false
  7973.     @ygg_dieing         = false
  7974.     @die_count_down     = 255
  7975.     @ai_operated        = true
  7976.   end
  7977.  
  7978.   #--------------------------------------------------------------------------#
  7979.   # * alias-method :erase
  7980.   #--------------------------------------------------------------------------#
  7981.   alias :ygg_gme_erase :erase unless $@
  7982.   def erase( *args, &block )
  7983.     terminate_ai_engine()
  7984.     ygg_unregister() ; ygg_gme_erase( *args, &block )
  7985.   end
  7986.  
  7987.   #--------------------------------------------------------------------------#
  7988.   # * alias-method :setup
  7989.   #--------------------------------------------------------------------------#
  7990.   alias :ygg_gme_setup :setup unless $@
  7991.   def setup( *args, &block )
  7992.     @dont_scan_events = YGG::DONT_SCAN_EVENTS
  7993.     @ygg_cache_complete = false
  7994.     ygg_gme_setup( *args, &block )
  7995.     ygg_event_cache()
  7996.   end
  7997.  
  7998.   #--------------------------------------------------------------------------#
  7999.   # * new-method :pop_enabled?
  8000.   #--------------------------------------------------------------------------#  
  8001.   def pop_enabled?()
  8002.     return @ygg_pop_enabled
  8003.   end
  8004.  
  8005.   #--------------------------------------------------------------------------#
  8006.   # * new-method :ygg_event_cache
  8007.   #--------------------------------------------------------------------------#
  8008.   def ygg_event_cache()
  8009.     ygg_event_cache_start()
  8010.     return if @list.nil?()
  8011.     for i in 0..@list.size
  8012.       next if @list[i].nil?()
  8013.       if [108, 408].include?( @list[i].code )
  8014.         @list[i].parameters.to_s.split(/[\r\n]+/).each { |line|
  8015.           ygg_event_cache_check( line )
  8016.         }
  8017.       end
  8018.     end
  8019.     ygg_event_cache_end()
  8020.   end
  8021.  
  8022.   #--------------------------------------------------------------------------#
  8023.   # * new-method :ygg_event_cache_start
  8024.   #--------------------------------------------------------------------------#
  8025.   def ygg_event_cache_start()
  8026.     @ygg_cache_complete     = false
  8027.     @ygg_battler            = nil
  8028.     @ygg_ally               = false
  8029.     @ygg_enemy              = false
  8030.     @ygg_boss               = false
  8031.     @ygg_fading_death       = true
  8032.     @ygg_instant_death      = false
  8033.     @ygg_dead_switches      = []
  8034.     @ygg_dead_self_switches = []
  8035.     @ygg_dieing             = false
  8036.     @die_count_down         = 255
  8037.     @ygg_death_anim         = 0
  8038.     @ygg_wild_type          = false
  8039.     @ygg_com_evn_atk        = nil
  8040.     @ygg_invincible         = false
  8041.     @ygg_pop_enabled        = true
  8042.     setup_ai_engine( YGG::Handlers::AIEngines::Default, {} )
  8043.    
  8044.     @__aiengine, @__aieng_setup_data = nil, {}
  8045.     @__read_aiengine = 0
  8046.   end
  8047.  
  8048.   #--------------------------------------------------------------------------#
  8049.   # * new-method :ygg_event_cache_check
  8050.   #--------------------------------------------------------------------------#
  8051.   def ygg_event_cache_check( line )  
  8052.     case line
  8053.     when YGG::REGEXP::EVENT::SELF_SWITCH
  8054.       @ygg_dead_self_switches.push($1.to_s.upcase)
  8055.     when YGG::REGEXP::EVENT::SWITCH
  8056.       @ygg_dead_switches.push([$1.to_i, $2.to_s])
  8057.     when YGG::REGEXP::EVENT::INVINCIBLE
  8058.       @ygg_invincible = true
  8059.     when YGG::REGEXP::EVENT::NO_FADE_DEATH  
  8060.       @ygg_fading_death = false
  8061.     when YGG::REGEXP::EVENT::INSTANT_DEATH
  8062.       @ygg_instant_death = true
  8063.     when YGG::REGEXP::EVENT::ABS_ALLY
  8064.       next if $game_actors[$1.to_i].nil?()
  8065.       setup_ygg_battler( $game_actors[$1.to_i], :actor )
  8066.     when YGG::REGEXP::EVENT::ABS_ENEMY
  8067.       next if $data_enemies[$1.to_i].nil?()
  8068.       setup_ygg_battler( Game_Enemy.new(0, $1.to_i), :enemy )  
  8069.     when YGG::REGEXP::EVENT::ABS_SET_AS_ALLY
  8070.       @ygg_enemy = !@ygg_ally = true
  8071.     when YGG::REGEXP::EVENT::ABS_SET_AS_ENEMY  
  8072.       @ygg_ally = !@ygg_enemy = true
  8073.     when YGG::REGEXP::EVENT::ABS_BOSS
  8074.       @ygg_boss = true
  8075.     when YGG::REGEXP::EVENT::DEATH_ANIM  
  8076.       @ygg_death_anim = $1.to_i
  8077.     when YGG::REGEXP::EVENT::AI_ENGINE1  
  8078.       @__aiengine = ::YGG::AI_ENGINES[$1.to_s.downcase]
  8079.       @__read_aiengine = 1
  8080.     when YGG::REGEXP::EVENT::AI_ENGINE2    
  8081.       @__read_aiengine = 0
  8082.     when YGG::REGEXP::EVENT::ENABLE_POP
  8083.       @ygg_pop_enabled = true
  8084.     when YGG::REGEXP::EVENT::DISABLE_POP
  8085.       @ygg_pop_enabled = false
  8086.     when YGG::REGEXP::EVENT::SHOW_HP_BAR
  8087.       @hp_visible = true
  8088.     when YGG::REGEXP::EVENT::HIDE_HP_BAR    
  8089.       @hp_visible = false
  8090.     when YGG::REGEXP::EVENT::SHOW_MP_BAR    
  8091.       @mp_visible = true
  8092.     when YGG::REGEXP::EVENT::HIDE_MP_BAR    
  8093.       @mp_visible = false
  8094.     else
  8095.       if @__read_aiengine == 1
  8096.         case line
  8097.         when /(.*)\=[ ](.*)/i
  8098.           @__aieng_setup_data[$1] = $2
  8099.         end  
  8100.       end  
  8101.     end
  8102.   end
  8103.  
  8104.   #--------------------------------------------------------------------------#
  8105.   # * new-method :ygg_event_cache_end
  8106.   #--------------------------------------------------------------------------#
  8107.   def ygg_event_cache_end()
  8108.     setup_ai_engine( @__aiengine, @__aieng_setup_data ) unless @__aiengine.nil?()
  8109.     @__read_aiengine, @__aiengine, @__aieng_setup_data = 0, nil, {}
  8110.     @ygg_cache_complete = true
  8111.     #setup_target_group()
  8112.   end
  8113.  
  8114.   #--------------------------------------------------------------------------#
  8115.   # * new-method :setup_ygg_battler
  8116.   #--------------------------------------------------------------------------#  
  8117.   def setup_ygg_battler( battler, type=:actor )
  8118.     @ygg_battler = battler
  8119.     case type
  8120.     when :actor ; @ygg_enemy = !@ygg_ally = true
  8121.     when :enemy ; @ygg_ally  = !@ygg_enemy = true
  8122.     end  
  8123.   end
  8124.  
  8125.   #--------------------------------------------------------------------------#
  8126.   # * new-method :terminate_ygg_battler
  8127.   #--------------------------------------------------------------------------#
  8128.   def terminate_ygg_battler()
  8129.     @ygg_battler = nil
  8130.   end
  8131.  
  8132.   #--------------------------------------------------------------------------#
  8133.   # * new-method :ygg_attacker
  8134.   #--------------------------------------------------------------------------#
  8135.   def ygg_attacker() ; @ygg_battler || super ; end
  8136.    
  8137.   #--------------------------------------------------------------------------#
  8138.   # * new-method :wild_type?
  8139.   #--------------------------------------------------------------------------#
  8140.   def wild_type?() ; return @ygg_wild_type ; end
  8141.  
  8142.   #--------------------------------------------------------------------------#
  8143.   # * new-method :ygg_ally?
  8144.   #--------------------------------------------------------------------------#
  8145.   def ygg_ally?() ; return @ygg_ally ; end
  8146.  
  8147.   #--------------------------------------------------------------------------#
  8148.   # * new-method :Is an enemy?
  8149.   #--------------------------------------------------------------------------#
  8150.   def ygg_enemy? ; return @ygg_enemy ; end
  8151.  
  8152.   #--------------------------------------------------------------------------#
  8153.   # * new-method :ygg_boss?
  8154.   #--------------------------------------------------------------------------#
  8155.   def ygg_boss? ; return @ygg_boss ; end
  8156.  
  8157.   #--------------------------------------------------------------------------#
  8158.   # * new-method :ygg_death
  8159.   #--------------------------------------------------------------------------#
  8160.   def ygg_death()
  8161.     ygg_enemy?() ? Sound.play_enemy_collapse() : Sound.play_actor_collapse()
  8162.     create_drops()
  8163.     @ygg_battler = nil
  8164.     @ygg_boss    = false
  8165.     @ygg_dieing  = true
  8166.   end
  8167.  
  8168.   #--------------------------------------------------------------------------#
  8169.   # * new-method :create_drops
  8170.   #--------------------------------------------------------------------------#
  8171.   def create_drops() ; $game_map.create_drops( self.x, self.y, ygg_battler.create_drops_object() ) ; end
  8172.  
  8173.   #--------------------------------------------------------------------------#
  8174.   # * alias-method :update
  8175.   #--------------------------------------------------------------------------#
  8176.   alias :ygg_gme_update :update unless $@
  8177.   def update()
  8178.     ygg_gme_update()
  8179.     ygg_abs_update() if $game_system.yggdrasil_on?()
  8180.   end
  8181.  
  8182.   #--------------------------------------------------------------------------#
  8183.   # * new-method :ygg_abs_update
  8184.   #--------------------------------------------------------------------------#
  8185.   def ygg_abs_update()
  8186.     super()
  8187.     unless self.ygg_battler.nil?()
  8188.       update_battler()
  8189.       if ygg_attacker.dead? ; ygg_death()
  8190.       else                  ; ygg_update_ai()
  8191.       end
  8192.     end
  8193.     if @ygg_dieing
  8194.       if @ygg_instant_death  
  8195.         @die_count_down = 0
  8196.       elsif @ygg_fading_death
  8197.         @opacity = @die_count_down -= 255 / YGG::DIE_WAIT_TIME
  8198.       else
  8199.         @die_count_down -= 255 / YGG::DIE_WAIT_TIME
  8200.       end  
  8201.       if @die_count_down <= 0
  8202.         @ygg_dieing = false
  8203.         ygg_perform_death()
  8204.       end  
  8205.     end
  8206.   end
  8207.  
  8208.   #--------------------------------------------------------------------------#
  8209.   # * new-method :ygg_perform_death
  8210.   #--------------------------------------------------------------------------#
  8211.   # Hp == 0 .'. Dead. If no switch is present the event is simply erased
  8212.   # If IRME is present, and the event is generated the irme_die is called
  8213.   # Therefore the event is removed.
  8214.   #--------------------------------------------------------------------------#
  8215.   if $imported["IRME_Event_Generator"]
  8216.     def ygg_perform_death()
  8217.       ygg_death_operations()
  8218.       if @ygg_dead_self_switches.empty? and @ygg_dead_switches.empty? # If no switches are present do normal erasing
  8219.         unless @generator_id.nil?()
  8220.           self.irme_die()
  8221.         else
  8222.           self.erase
  8223.         end  
  8224.       end
  8225.     end  
  8226.   else
  8227.     def ygg_perform_death()
  8228.       ygg_death_operations()
  8229.       if @ygg_dead_self_switches.empty? and @ygg_dead_switches.empty? # If no switches are present do normal erasing
  8230.         self.erase()
  8231.       end
  8232.     end
  8233.   end
  8234.  
  8235.   #--------------------------------------------------------------------------#
  8236.   # * new-method :ygg_death_operations
  8237.   #--------------------------------------------------------------------------#
  8238.   def ygg_death_operations()
  8239.     @ygg_anims.push(@ygg_death_anim) if @ygg_death_anim > 0
  8240.     if !@ygg_dead_self_switches.empty?() or !@ygg_dead_switches.empty?()
  8241.       @ygg_dead_self_switches.compact.each { |selswit|
  8242.         $game_system.control_self_switch( $game_map.map_id, @id, selswit, true )
  8243.       }
  8244.       @ygg_dead_switches.compact.each { |swit|
  8245.         swit_id = swit[0]
  8246.         case swit[1].to_s
  8247.         when /(?:TRUE|ON)/i
  8248.           $game_switches[swit_id] = true
  8249.           $game_map.need_refresh = true
  8250.         when /(?:FALSE|OFF)/i  
  8251.           $game_switches[swit_id] = false
  8252.           $game_map.need_refresh = true
  8253.         end          
  8254.       }
  8255.       $game_map.need_refresh = true
  8256.     end
  8257.   end
  8258.  
  8259. end
  8260.  
  8261. #==============================================================================#
  8262. # ** Game Player
  8263. #==============================================================================#
  8264. class Game_Player < Game_Character
  8265.  
  8266.   #--------------------------------------------------------------------------#
  8267.   # * Public Instance Variable(s)
  8268.   #--------------------------------------------------------------------------#
  8269.   attr_accessor :ygg_gained_items
  8270.  
  8271.   #--------------------------------------------------------------------------#
  8272.   # * alias-method :initialize
  8273.   #--------------------------------------------------------------------------#
  8274.   alias :ygg_gmp_initialize :initialize unless $@
  8275.   def initialize( *args, &block )
  8276.     ygg_gmp_initialize( *args, &block )
  8277.     @ygg_targeting_mode = false
  8278.     @ygg_remote_sprite  = nil
  8279.     @ygg_old_actor      = nil
  8280.     @ygg_old_target_pos = [0, 0]
  8281.     @ygg_gained_items   = []
  8282.   end
  8283.    
  8284.   #--------------------------------------------------------------------------#
  8285.   # * alias-method :update
  8286.   #--------------------------------------------------------------------------#
  8287.   alias :ygg_gmp_update :update unless $@
  8288.   def update( *args, &block )
  8289.     abs_on = $game_system.yggdrasil_on?()  
  8290.     if abs_on    
  8291.       ygg_abs_update()
  8292.       ygg_update_pickup()
  8293.     end  
  8294.     ygg_gmp_update( *args, &block )
  8295.     if abs_on
  8296.       @ygg_old_actor = $game_party.members[0]
  8297.     end  
  8298.   end
  8299.  
  8300.   #--------------------------------------------------------------------------#
  8301.   # * new-method :ygg_update_pickup
  8302.   #--------------------------------------------------------------------------#
  8303.   def ygg_update_pickup()
  8304.     $game_map.drops_xy( self.x, self.y ).compact.each { |dr|
  8305.       self.ygg_gain_drop( dr.drop ) ; dr.drop_remove() }
  8306.   end
  8307.  
  8308.   #--------------------------------------------------------------------------#
  8309.   # * new-method :gain_drop
  8310.   #--------------------------------------------------------------------------#
  8311.   def ygg_gain_drop( drop )
  8312.     return if drop.nil?()
  8313.     drop.pickup_sfx.play() unless drop.pickup_sfx.nil?()
  8314.     @ygg_gained_items << drop
  8315.     @ygg_gained_items.shift() while @ygg_gained_items.size > 20 # // remove really old drops to save memory
  8316.     if drop.is_a?( YGG::Containers::GoldItem )
  8317.       $game_party.gain_gold( drop.gold_amount )
  8318.     else
  8319.       $game_party.gain_item( drop, 1 )
  8320.     end  
  8321.   end
  8322.  
  8323.   #--------------------------------------------------------------------------#
  8324.   # * new-method :ygg_abs_update
  8325.   #--------------------------------------------------------------------------#
  8326.   def ygg_abs_update()
  8327.     super()
  8328.     unless self.ygg_battler.nil?()
  8329.       update_battler() ; ygg_attack_input()
  8330.     end  
  8331.   end
  8332.  
  8333.   #--------------------------------------------------------------------------#
  8334.   # * new-method :ygg_attacker
  8335.   #--------------------------------------------------------------------------#
  8336.   def ygg_attacker() ; return $game_party.members[0] ; end
  8337.  
  8338.   #--------------------------------------------------------------------------#
  8339.   # * new-method :ygg_ally?, ygg_enemy?, ygg_wild?, ygg_boss?
  8340.   #--------------------------------------------------------------------------#
  8341.   def ygg_ally?  ; return true  ; end
  8342.   def ygg_enemy? ; return false ; end
  8343.   def ygg_wild?  ; return false ; end
  8344.   def ygg_boss?  ; return false ; end
  8345.    
  8346.   #--------------------------------------------------------------------------#
  8347.   # * new-method :ygg_can_move?
  8348.   #--------------------------------------------------------------------------#
  8349.   def ygg_can_move?() ; super() ; end
  8350.  
  8351.   #--------------------------------------------------------------------------#
  8352.   # * overwrite-method :use_equipment
  8353.   #--------------------------------------------------------------------------#
  8354.   def use_equipment ; return true ; end
  8355.      
  8356. end
  8357.  
  8358. #==============================================================================#
  8359. # ** YGG::Drop_Character
  8360. #==============================================================================#
  8361. class YGG::Drop_Character < YGG::Handlers::Screen
  8362.  
  8363.   #--------------------------------------------------------------------------#
  8364.   # * Public Instance Variable(s)
  8365.   #--------------------------------------------------------------------------#  
  8366.   attr_accessor :icon_index
  8367.   attr_accessor :ready_to_remove
  8368.   attr_accessor :icon_time_out
  8369.   attr_accessor :opacity
  8370.   attr_accessor :visible
  8371.  
  8372.   #--------------------------------------------------------------------------#
  8373.   # * super-method :initialize
  8374.   #--------------------------------------------------------------------------#
  8375.   def initialize( object, time = 640 )
  8376.     super( 0, 0, 0 )
  8377.     @drop_object     = object
  8378.     @icon_index      = @drop_object.icon_index
  8379.     @icon_time_out   = time
  8380.     @icon_fade_thres = YGG::DROP_FADE_THRESHOLD
  8381.     @opacity         = 255
  8382.     @visible         = true
  8383.   end
  8384.  
  8385.   #--------------------------------------------------------------------------#
  8386.   # * new-method :pos?
  8387.   #--------------------------------------------------------------------------#
  8388.   def pos?( tx, ty ) ; return (self.x == tx && self.y == ty) ; end
  8389.    
  8390.   #--------------------------------------------------------------------------#
  8391.   # * new-method :update
  8392.   #--------------------------------------------------------------------------#
  8393.   def update()
  8394.     @icon_time_out   = [@icon_time_out-1, 0].max
  8395.     @ready_to_remove = true if @icon_time_out <= 0
  8396.     @opacity -= 255 / 60 if @icon_time_out <= @icon_fade_thres
  8397.     if $game_player.drop_attraction?()
  8398.       if $game_player.x > self.x    ; self.x = [self.x-0.1, $game_player.x].min
  8399.       elsif $game_player.x < self.x ; self.x = [self.x-0.1, $game_player.x].max
  8400.       end  
  8401.       if $game_player.y > self.y    ; self.y = [self.y-0.1, $game_player.y].min
  8402.       elsif $game_player.y < self.y ; self.y = [self.y-0.1, $game_player.y].max
  8403.       end
  8404.       @real_x = self.x*256 ; @real_y = self.y*256
  8405.     end  
  8406.   end
  8407.  
  8408.   #--------------------------------------------------------------------------#
  8409.   # * super-method :drop_remove
  8410.   #--------------------------------------------------------------------------#
  8411.   def drop_remove()
  8412.     @drop_object = nil
  8413.     @icon_index = 0
  8414.     @icon_time_out = 0
  8415.   end
  8416.  
  8417.   #--------------------------------------------------------------------------#
  8418.   # * new-method :timeout?
  8419.   #--------------------------------------------------------------------------#
  8420.   def timeout? ; return @icon_time_out == 0 end
  8421.    
  8422.   #--------------------------------------------------------------------------#
  8423.   # * new-method :drop
  8424.   #--------------------------------------------------------------------------#
  8425.   def drop ; return @drop_object end
  8426.    
  8427. end
  8428.  
  8429. #==============================================================================#
  8430. # ** Scene_Title
  8431. #==============================================================================#  
  8432. class Scene_Title < Scene_Base
  8433.  
  8434.   #--------------------------------------------------------------------------#
  8435.   # * alias-method :load_database
  8436.   #--------------------------------------------------------------------------#  
  8437.   alias :ygg_sct_load_database :load_database unless $@
  8438.   def load_database()
  8439.     ygg_sct_load_database()
  8440.     load_ygg_database()
  8441.   end
  8442.  
  8443.   #--------------------------------------------------------------------------#
  8444.   # * alias-method :load_bt_database
  8445.   #--------------------------------------------------------------------------#  
  8446.   alias :ygg_sct_load_bt_database :load_bt_database unless $@
  8447.   def load_bt_database()
  8448.     ygg_sct_load_bt_database()
  8449.     load_ygg_database()
  8450.   end
  8451.  
  8452.   #--------------------------------------------------------------------------#
  8453.   # * alias-method :load_ygg_database
  8454.   #--------------------------------------------------------------------------#  
  8455.   def load_ygg_database()
  8456.     data = []
  8457.     data += $data_items
  8458.     data += $data_skills
  8459.     data += $data_enemies
  8460.     data += $data_weapons
  8461.     data += $data_armors
  8462.     data += $data_states
  8463.     data.compact.each { |obj| obj.yggdrasil_1x6_cache() }
  8464.   end
  8465.  
  8466.   #--------------------------------------------------------------------------#
  8467.   # * alias-method :create_game_objects
  8468.   #--------------------------------------------------------------------------#
  8469.   alias :ygg_sct_ptxt_create_game_objects :create_game_objects unless $@
  8470.   def create_game_objects()
  8471.     $game_yggdrasil = YGG::System.new()
  8472.     ygg_sct_ptxt_create_game_objects()
  8473.   end
  8474.  
  8475. end
  8476.  
  8477. #==============================================================================#
  8478. # ** Scene_Map
  8479. #==============================================================================#
  8480. class Scene_Map < Scene_Base
  8481.  
  8482.   #--------------------------------------------------------------------------#
  8483.   # * Public Instance Variable(s)
  8484.   #--------------------------------------------------------------------------#  
  8485.   attr_accessor :spriteset
  8486.        
  8487.   #--------------------------------------------------------------------------#
  8488.   # * new-method :push_ygg_anim
  8489.   #--------------------------------------------------------------------------#
  8490.   def push_ygg_anim( anim_id, x, y, targets=[], looped = false )
  8491.     @spriteset.push_anim( anim_id, x, y, targets, looped ) unless @spriteset.nil?()
  8492.   end  
  8493.  
  8494.   #--------------------------------------------------------------------------#
  8495.   # * alias-method :update
  8496.   #--------------------------------------------------------------------------#
  8497.   alias :ygg_scm_update :update unless $@
  8498.   def update( *args, &block )
  8499.     ygg_scm_update( *args, &block )
  8500.     $game_yggdrasil.update()
  8501.     $game_party.ygg_slip_damage() if $game_yggdrasil.on?()
  8502.     $game_yggdrasil.gameover_process() if $game_party.all_dead?() if $game_system.gameover_alldead?()
  8503.   end
  8504.  
  8505. if ::YGG::USE_DROPS_WINDOW
  8506.  
  8507.   #--------------------------------------------------------------------------#
  8508.   # * alias-method :start
  8509.   #--------------------------------------------------------------------------#  
  8510.   alias :ygg_drop_win_start :start unless $@
  8511.   def start( *args, &block )
  8512.     ygg_drop_win_start( *args, &block )
  8513.     create_drops_window()
  8514.   end
  8515.  
  8516.   #--------------------------------------------------------------------------#
  8517.   # * new-method :create_drops_window
  8518.   #--------------------------------------------------------------------------#
  8519.   def create_drops_window()
  8520.     size = YGG::DROPS_WINDOW_SIZE
  8521.     @drops_logging = YGG::Drops_Window.new(
  8522.       { :x => size[0], :y => size[1], :z => size[2], :width => size[3] }, nil )  
  8523.     @drops_logging.visible = $game_yggdrasil.drops_window_visible?()
  8524.   end
  8525.  
  8526.   #--------------------------------------------------------------------------#
  8527.   # * alias-method :terminate
  8528.   #--------------------------------------------------------------------------#
  8529.   alias :ygg_drop_win_terminate :terminate unless $@
  8530.   def terminate( *args, &block )
  8531.     @drops_logging.dispose() unless @drops_logging.nil?() ; @drops_logging = nil
  8532.     ygg_drop_win_terminate( *args, &block )
  8533.   end
  8534.  
  8535.   #--------------------------------------------------------------------------#
  8536.   # * alias-method :update
  8537.   #--------------------------------------------------------------------------#  
  8538.   alias :ygg_drop_win_update :update unless $@
  8539.   def update( *args, &block )
  8540.     unless @drops_logging.nil?()
  8541.       @drops_logging.visible = $game_yggdrasil.drops_window_visible?()
  8542.       @drops_logging.update()
  8543.     end
  8544.     ygg_drop_win_update( *args, &block )
  8545.   end
  8546.  
  8547. end # // Drops Window
  8548.  
  8549. end
  8550.  
  8551. # // (YGG_ShiftSystem)
  8552. if YGG::USE_SHIFT_SYSTEM
  8553. #==============================================================================#
  8554. # ** Game_Party
  8555. #==============================================================================#
  8556. class Game_Party < Game_Unit
  8557.  
  8558.   #--------------------------------------------------------------------------#
  8559.   # * Public Instance Variables
  8560.   #--------------------------------------------------------------------------#
  8561.   attr_accessor :actors
  8562.  
  8563. end
  8564.  
  8565. #==============================================================================#
  8566. # ** YGG::Handlers::Shift
  8567. #==============================================================================#
  8568. class YGG::Handlers::Shift
  8569.  
  8570.   #--------------------------------------------------------------------------#
  8571.   # * Public Instance Variables
  8572.   #--------------------------------------------------------------------------#  
  8573.   attr_accessor :shift_time
  8574.   attr_accessor :shift_cap
  8575.  
  8576.   #--------------------------------------------------------------------------#
  8577.   # * new-method :initialize
  8578.   #--------------------------------------------------------------------------#
  8579.   def initialize()
  8580.     @shift_time = 0
  8581.     @shift_cap  = Graphics.frame_rate*5
  8582.   end
  8583.  
  8584.   #--------------------------------------------------------------------------#
  8585.   # * new-method :reset_shift_time
  8586.   #--------------------------------------------------------------------------#
  8587.   def reset_shift_time() ; @shift_time = @shift_cap ; end
  8588.  
  8589.   #--------------------------------------------------------------------------#
  8590.   # * new-method :time
  8591.   #--------------------------------------------------------------------------#  
  8592.   def time() ; return @shift_time ; end
  8593.  
  8594.   #--------------------------------------------------------------------------#
  8595.   # * new-method :cap
  8596.   #--------------------------------------------------------------------------#  
  8597.   def cap() ; return @shift_cap ; end  
  8598.    
  8599.   #--------------------------------------------------------------------------#
  8600.   # * new-method :can_shift?
  8601.   #--------------------------------------------------------------------------#  
  8602.   def can_shift?() ; return @shift_time == 0 ; end
  8603.  
  8604.   #--------------------------------------------------------------------------#
  8605.   # * new-method :swap_actors
  8606.   #--------------------------------------------------------------------------#
  8607.   def swap_actors( target_index, swap_index )
  8608.     target_id = $game_party.actors[target_index]
  8609.     swap_id = $game_party.actors[swap_index]
  8610.   end
  8611.  
  8612.   #--------------------------------------------------------------------------#
  8613.   # * new-method :rotate_actors
  8614.   #--------------------------------------------------------------------------#
  8615.   def rotate_actors( n=1 )
  8616.     $game_party.actors.rotate!( n )
  8617.   end
  8618.  
  8619.   #--------------------------------------------------------------------------#
  8620.   # * new-method :perform_shift
  8621.   #--------------------------------------------------------------------------#
  8622.   def perform_shift( n )
  8623.     rotate_actors( n ) ;
  8624.     $game_player.ygg_anims << 81
  8625.     $game_player.thrust_backward()
  8626.     $game_player.refresh()
  8627.     reset_shift_time()
  8628.   end
  8629.  
  8630.   #--------------------------------------------------------------------------#
  8631.   # * new-method :update
  8632.   #--------------------------------------------------------------------------#
  8633.   def update()
  8634.     @shift_time = [@shift_time - 1, 0].max
  8635.     update_shift() if can_shift?
  8636.     perform_shift( 1 ) while $game_party.members[0].dead?() unless $game_party.all_dead?()
  8637.   end
  8638.  
  8639.   #--------------------------------------------------------------------------#
  8640.   # * new-method :update_shift
  8641.   #--------------------------------------------------------------------------#
  8642.   def update_shift()
  8643.     if Input.trigger?( Input::R )
  8644.       perform_shift( 1 )
  8645.     elsif Input.trigger?( Input::L )  
  8646.       perform_shift( -1 )
  8647.     end  
  8648.   end
  8649.  
  8650. end
  8651.  
  8652. #==============================================================================#
  8653. # ** YGG::System
  8654. #==============================================================================#
  8655. class YGG::System
  8656.  
  8657.   #--------------------------------------------------------------------------#
  8658.   # * Public Instance Variables
  8659.   #--------------------------------------------------------------------------#  
  8660.   attr_accessor :shift_system
  8661.  
  8662.   #--------------------------------------------------------------------------#
  8663.   # * alias-method :initialize
  8664.   #--------------------------------------------------------------------------#  
  8665.   alias :ygg_shift_sys_initialize :initialize unless $@
  8666.   def initialize( *args, &block )
  8667.     ygg_shift_sys_initialize( *args, &block )
  8668.     @shift_system = ::YGG::Handlers::Shift.new()
  8669.   end
  8670.  
  8671.   #--------------------------------------------------------------------------#
  8672.   # * alias-method :update
  8673.   #--------------------------------------------------------------------------#  
  8674.   alias :ygg_shift_sys_update :update unless $@
  8675.   def update( *args, &block )
  8676.     ygg_shift_sys_update( *args, &block )
  8677.     @shift_system.update()
  8678.   end
  8679.  
  8680. end
  8681.  
  8682. end
  8683.  
  8684. # // (YGG_LevelUpWindow)
  8685. if YGG::USE_LEVEL_UP_WINDOW > 0
  8686. #==============================================================================#
  8687. # ** YGG::Windows::Level_Up
  8688. #==============================================================================#
  8689. class YGG::Windows::Level_Up < ::Sprite
  8690.  
  8691.   #--------------------------------------------------------------------------#
  8692.   # * Constant(s)
  8693.   #--------------------------------------------------------------------------#  
  8694.   WLH = 20
  8695.   BORDER_SIZE = 2
  8696.  
  8697.   #--------------------------------------------------------------------------#
  8698.   # * super-method :initialize
  8699.   #--------------------------------------------------------------------------#  
  8700.   def initialize( x, y, width, viewport=nil )
  8701.     super( viewport )
  8702.     @background = Sprite.new( self.viewport )
  8703.     @background.bitmap = Bitmap.new( width, WLH )
  8704.     @background.bitmap.fill_rect( BORDER_SIZE, BORDER_SIZE,
  8705.       width-(BORDER_SIZE*2), WLH-(BORDER_SIZE*2),
  8706.       Color.new( 0, 0, 0 ) )
  8707.     @background.bitmap.blur() ; @background.bitmap.blur()
  8708.     @background.opacity = 198
  8709.     self.bitmap = Bitmap.new( width, WLH*7 )
  8710.     self.src_rect.set( 0, 0, width, WLH )
  8711.     @count = 0 ; @index = 0
  8712.     self.x, self.y, self.z = x, y, 9999
  8713.     @target_opacity = 0
  8714.   end
  8715.  
  8716.   #--------------------------------------------------------------------------#
  8717.   # * super-method :dispose
  8718.   #--------------------------------------------------------------------------#
  8719.   def dispose()
  8720.     unless @background.nil?()
  8721.       @background.bitmap.dispose() ; @background.dispose()
  8722.     end
  8723.     self.bitmap.dispose()
  8724.     super()
  8725.   end
  8726.  
  8727.   #--------------------------------------------------------------------------#
  8728.   # * super-method :x=
  8729.   #--------------------------------------------------------------------------#
  8730.   def x=( new_x )
  8731.     super( new_x )
  8732.     @background.x = self.x
  8733.   end
  8734.  
  8735.   #--------------------------------------------------------------------------#
  8736.   # * super-method :y=
  8737.   #--------------------------------------------------------------------------#
  8738.   def y=( new_y )
  8739.     super( new_y )
  8740.     @background.y = self.y
  8741.   end
  8742.  
  8743.   #--------------------------------------------------------------------------#
  8744.   # * super-method :z=
  8745.   #--------------------------------------------------------------------------#
  8746.   def z=( new_z )
  8747.     super( new_z+1 )
  8748.     @background.z = new_z
  8749.   end
  8750.  
  8751.   #--------------------------------------------------------------------------#
  8752.   # * super-method :viewport=
  8753.   #--------------------------------------------------------------------------#
  8754.   def viewport=( new_viewport )
  8755.     super( new_viewport )
  8756.     @background.viewport = self.viewport
  8757.   end
  8758.  
  8759.   #--------------------------------------------------------------------------#
  8760.   # * super-method :visible=
  8761.   #--------------------------------------------------------------------------#
  8762.   def visible=( new_visible )
  8763.     super( new_visible )
  8764.     @background.visible = self.visible
  8765.   end
  8766.  
  8767.   #--------------------------------------------------------------------------#
  8768.   # * super-method :show_level_up
  8769.   #--------------------------------------------------------------------------#
  8770.   def show_level_up( battler, old_level )
  8771.     self.bitmap.clear()
  8772.     @count = 0 ; @index = 0 ; @last_index = -1
  8773.     stats = [:maxhp, :maxmp, :atk, :def, :spi, :agi]
  8774.     self.bitmap.font.size = 16
  8775.     self.bitmap.draw_text( 0, 0, self.width, WLH,
  8776.       sprintf( "%s: %s > %s", Vocab.level, old_level, battler.level ) )
  8777.     for i in 0...stats.size
  8778.       stat = stats[i]
  8779.       self.bitmap.draw_text( 0, WLH+(WLH*i), self.width, 20,
  8780.         sprintf( "%s: %s", Vocab.send( stat ), battler.send( stat ) ) )
  8781.     end  
  8782.     @target_opacity = 198
  8783.     self.visible = true
  8784.   end
  8785.  
  8786.   #--------------------------------------------------------------------------#
  8787.   # * super-method :update
  8788.   #--------------------------------------------------------------------------#
  8789.   def update()
  8790.     super()
  8791.     return if @index >= 8
  8792.     @count += 1
  8793.     @index += 1 if @count % 60 == 0
  8794.     if @index >= 7
  8795.       @target_opacity = 0
  8796.       self.visible = false
  8797.     else  
  8798.       if @index != @last_index
  8799.         self.src_rect.set( 0, WLH*@index, self.width, WLH )
  8800.         @last_index = @index
  8801.       end  
  8802.     end  
  8803.     if @background.opacity > @target_opacity
  8804.       @background.opacity = [@background.opacity - (255/30.0), @target_opacity].max
  8805.     elsif @background.opacity < @target_opacity  
  8806.       @background.opacity = [@background.opacity + (255/30.0), @target_opacity].min
  8807.     end  
  8808.   end
  8809.  
  8810. end  
  8811.  
  8812. #==============================================================================#
  8813. # ** Scene_Map
  8814. #==============================================================================#
  8815. class Scene_Map < Scene_Base
  8816.  
  8817.   #--------------------------------------------------------------------------#
  8818.   # * Public Instance Variable(s)
  8819.   #--------------------------------------------------------------------------#
  8820.   attr_accessor :level_up_window
  8821.  
  8822.   #--------------------------------------------------------------------------#
  8823.   # * alias-method :start
  8824.   #--------------------------------------------------------------------------#
  8825.   alias :ygg_lvl_up_win_scm_start :start unless $@
  8826.   def start( *args, &block )
  8827.     ygg_lvl_up_win_scm_start( *args, &block )
  8828.     @level_up_window = YGG::Windows::Level_Up.new( 0, 0, 128 )
  8829.   end
  8830.  
  8831.   #--------------------------------------------------------------------------#
  8832.   # * alias-method :terminate
  8833.   #--------------------------------------------------------------------------#
  8834.   alias :ygg_lvl_up_win_scm_terminate :terminate unless $@
  8835.   def terminate( *args, &block )
  8836.     ygg_lvl_up_win_scm_terminate( *args, &block )
  8837.     @level_up_window.dispose() unless @level_up_window.nil?() ; @level_up_window = nil
  8838.   end
  8839.  
  8840.   #--------------------------------------------------------------------------#
  8841.   # * alias-method :update
  8842.   #--------------------------------------------------------------------------#
  8843.   alias :ygg_lvl_up_win_scm_update :update unless $@
  8844.   def update( *args, &block )
  8845.     ygg_lvl_up_win_scm_update( *args, &block )
  8846.     @level_up_window.update() unless @level_up_window.nil?()
  8847.   end
  8848.  
  8849. end
  8850.  
  8851. end # // Level Up Window
  8852.  
  8853. #==============================================================================#
  8854. # ** Scene_File
  8855. #==============================================================================#
  8856. class Scene_File < Scene_Base
  8857.  
  8858.   #--------------------------------------------------------------------------#
  8859.   # * alias-method :write_save_data
  8860.   #--------------------------------------------------------------------------#
  8861.   alias :ygg_scnf_ptxt_write_save_data :write_save_data unless $@
  8862.   def write_save_data( file )
  8863.     ygg_scnf_ptxt_write_save_data( file )
  8864.     Marshal.dump( $game_yggdrasil,      file )
  8865.   end  
  8866.  
  8867.   #--------------------------------------------------------------------------#
  8868.   # * alias-method :read_save_data
  8869.   #--------------------------------------------------------------------------#
  8870.   alias :ygg_scnf_ptxt_read_save_data :read_save_data unless $@
  8871.   def read_save_data( file )
  8872.     ygg_scnf_ptxt_read_save_data( file )
  8873.     $game_yggdrasil = Marshal.load( file )
  8874.   end
  8875.  
  8876. end
  8877.  
  8878. # // (Skill/Item Setting) // #
  8879. #==============================================================================#
  8880. # ** YGG::Windows::ActorObjSlots
  8881. #==============================================================================#
  8882. class ::YGG::Windows::ActorObjSlots < ::Window_Selectable
  8883.  
  8884.   #--------------------------------------------------------------------------#
  8885.   # * super-method :initialize
  8886.   #--------------------------------------------------------------------------#  
  8887.   def initialize( actor, x, y, width, height )
  8888.     super( x, y, width, height )
  8889.     @actor = actor
  8890.     @column_max = 1
  8891.     self.active = false
  8892.     self.index  = 0
  8893.     refresh()
  8894.   end
  8895.  
  8896.   #--------------------------------------------------------------------------#
  8897.   # * new-method :enabled?
  8898.   #--------------------------------------------------------------------------#  
  8899.   def enabled?( index )
  8900.     return !@data[index].nil?()
  8901.   end
  8902.  
  8903.   #--------------------------------------------------------------------------#
  8904.   # * new-method :obj
  8905.   #--------------------------------------------------------------------------#  
  8906.   def obj( i=@index ) ; return @data[i] ; end
  8907.    
  8908.   #--------------------------------------------------------------------------#
  8909.   # * new-method :get_objs
  8910.   #--------------------------------------------------------------------------#  
  8911.   def get_objs()
  8912.     return []
  8913.   end
  8914.  
  8915.   #--------------------------------------------------------------------------#
  8916.   # * new-method :refresh
  8917.   #--------------------------------------------------------------------------#  
  8918.   def refresh()
  8919.     @data     = get_objs()
  8920.     @item_max = @data.size
  8921.     @data_enabled = []
  8922.     create_contents()
  8923.     for i in 0...@item_max
  8924.       @data_enabled[i] = enabled?( i )
  8925.       draw_item( i )
  8926.     end
  8927.   end
  8928.  
  8929.   #--------------------------------------------------------------------------#
  8930.   # * new-method :selective_refresh
  8931.   #--------------------------------------------------------------------------#  
  8932.   def selective_refresh()
  8933.     newdata   = get_objs()
  8934.     @item_max = newdata.size
  8935.     if @data.size != @item_max
  8936.       @data.clear()
  8937.       create_contents()
  8938.     end
  8939.     for i in 0...newdata.size
  8940.       if newdata[i] != @data[i] || @data_enabled[i] != enabled?( i )
  8941.         @data[i] = newdata[i]
  8942.         @data_enabled[i] = enabled?( i )
  8943.         draw_item( i )
  8944.       end  
  8945.     end
  8946.   end
  8947.  
  8948.   #--------------------------------------------------------------------------#
  8949.   # * new-method :draw_item
  8950.   #--------------------------------------------------------------------------#  
  8951.   def draw_item( index )
  8952.     rect = item_rect( index )
  8953.     obj  = @data[index]
  8954.     enabled = enabled?( index )
  8955.     self.contents.clear_rect( rect )
  8956.     self.contents.font.color = normal_color
  8957.     self.contents.font.color.alpha -= 128 unless enabled
  8958.     unless obj.nil?()
  8959.       draw_item_name( obj, rect.x, rect.y, enabled )
  8960.     else
  8961.       draw_icon( 98, rect.x, rect.y )
  8962.       rect.x += 24
  8963.       self.contents.draw_text( rect, "----------------" )
  8964.     end  
  8965.   end
  8966.  
  8967.   #--------------------------------------------------------------------------#
  8968.   # * kill-method :cursor_pagedown
  8969.   #--------------------------------------------------------------------------#  
  8970.   def cursor_pagedown() ; end
  8971.    
  8972.   #--------------------------------------------------------------------------#
  8973.   # * kill-method :cursor_pageup
  8974.   #--------------------------------------------------------------------------#    
  8975.   def cursor_pageup() ; end
  8976.    
  8977. end  
  8978.  
  8979. #==============================================================================#
  8980. # ** YGG::Windows::ItemList
  8981. #==============================================================================#
  8982. class ::YGG::Windows::ItemList < ::YGG::Windows::ActorObjSlots
  8983.  
  8984.   #--------------------------------------------------------------------------#
  8985.   # * new-method :item
  8986.   #--------------------------------------------------------------------------#    
  8987.   def item() ; return obj() ; end
  8988.    
  8989.   #--------------------------------------------------------------------------#
  8990.   # * new-method :enabled?
  8991.   #--------------------------------------------------------------------------#    
  8992.   def enabled?( index )
  8993.     return false if @actor.item_slot_items.include?( @data[index] )
  8994.     return false if @data[index].cant_equip_slot unless @data[index].nil?()
  8995.     return super( index )
  8996.   end
  8997.  
  8998.   #--------------------------------------------------------------------------#
  8999.   # * overwrite-method :get_objs
  9000.   #--------------------------------------------------------------------------#    
  9001.   def get_objs()
  9002.     return [nil] + ($game_party.items.inject([]) { |r, i| r << i if i.is_a?(RPG::Item) }) + [nil]
  9003.   end
  9004.  
  9005.   #--------------------------------------------------------------------------#
  9006.   # * overwrite-method :update_help
  9007.   #--------------------------------------------------------------------------#    
  9008.   def update_help()
  9009.     @help_window.set_text(item.nil?() ? "" : item.description)
  9010.   end
  9011.  
  9012. end
  9013.  
  9014. #==============================================================================#
  9015. # ** YGG::Windows::SkillList
  9016. #==============================================================================#
  9017. class ::YGG::Windows::SkillList < ::YGG::Windows::ActorObjSlots
  9018.  
  9019.   #--------------------------------------------------------------------------#
  9020.   # * new-method :skill
  9021.   #--------------------------------------------------------------------------#    
  9022.   def skill() ; return obj() ; end
  9023.    
  9024.   #--------------------------------------------------------------------------#
  9025.   # * super-method :enabled?
  9026.   #--------------------------------------------------------------------------#    
  9027.   def enabled?( index )
  9028.     return false if @actor.skill_slot_skills.include?( @data[index] )
  9029.     return false if @data[index].cant_equip_slot unless @data[index].nil?()
  9030.     return super( index )
  9031.   end
  9032.  
  9033.   #--------------------------------------------------------------------------#
  9034.   # * overwrite-method :get_objs
  9035.   #--------------------------------------------------------------------------#    
  9036.   def get_objs()
  9037.     return [nil] + @actor.skills() + [nil]
  9038.   end
  9039.  
  9040.   #--------------------------------------------------------------------------#
  9041.   # * overwrite-method :update_help
  9042.   #--------------------------------------------------------------------------#    
  9043.   def update_help()
  9044.     @help_window.set_text(skill.nil?() ? "" : skill.description)
  9045.   end
  9046.  
  9047. end
  9048.  
  9049. #==============================================================================#
  9050. # ** YGG::Windows::ActorItemSlots
  9051. #==============================================================================#
  9052. class ::YGG::Windows::ActorItemSlots < ::YGG::Windows::ActorObjSlots
  9053.  
  9054.   #--------------------------------------------------------------------------#
  9055.   # * new-method :item
  9056.   #--------------------------------------------------------------------------#    
  9057.   def item() ; return obj() ; end
  9058.    
  9059.   #--------------------------------------------------------------------------#
  9060.   # * overwrite-method :get_objs
  9061.   #--------------------------------------------------------------------------#    
  9062.   def get_objs()
  9063.     return @actor.item_slot_items()
  9064.   end
  9065.  
  9066.   #--------------------------------------------------------------------------#
  9067.   # * overwrite-method :update_help
  9068.   #--------------------------------------------------------------------------#    
  9069.   def update_help()
  9070.     @help_window.set_text(item.nil?() ? "" : item.description)
  9071.   end
  9072.  
  9073. end  
  9074.  
  9075. #==============================================================================#
  9076. # ** YGG::Windows::ActorSkillSlots
  9077. #==============================================================================#
  9078. class ::YGG::Windows::ActorSkillSlots < ::YGG::Windows::ActorObjSlots
  9079.  
  9080.   #--------------------------------------------------------------------------#
  9081.   # * new-method :skill
  9082.   #--------------------------------------------------------------------------#    
  9083.   def skill() ; return obj() ; end
  9084.    
  9085.   #--------------------------------------------------------------------------#
  9086.   # * overwrite-method :get_objs
  9087.   #--------------------------------------------------------------------------#    
  9088.   def get_objs()
  9089.     return @actor.skill_slot_skills()
  9090.   end
  9091.  
  9092.   #--------------------------------------------------------------------------#
  9093.   # * overwrite-method :update_help
  9094.   #--------------------------------------------------------------------------#    
  9095.   def update_help()
  9096.     @help_window.set_text(skill.nil?() ? "" : skill.description)
  9097.   end
  9098.  
  9099. end  
  9100.  
  9101. # // Is there a good reason why I haven't super classes these? YES
  9102. #==============================================================================#
  9103. # ** YGG::Scenes::ObjSet
  9104. #==============================================================================#
  9105. class ::YGG::Scenes::ObjSet < ::Scene_Base
  9106.  
  9107.   #--------------------------------------------------------------------------#
  9108.   # * super-method :initialize
  9109.   #--------------------------------------------------------------------------#
  9110.   def initialize( actor, called=:map, return_index=0 )
  9111.     super()
  9112.     # ---------------------------------------------------- #
  9113.     @actor = nil
  9114.     @act_index = 0
  9115.     @index_call = false
  9116.     # ---------------------------------------------------- #
  9117.     if actor.kind_of?( Game_Battler )
  9118.       @actor = actor
  9119.     elsif actor != nil  
  9120.       @actor = $game_party.members[actor]
  9121.       @act_index = actor
  9122.       @index_call = true
  9123.     end
  9124.     @calledfrom = called
  9125.     @return_index = return_index
  9126.   end
  9127.  
  9128.   #--------------------------------------------------------------------------#
  9129.   # * new-method :start
  9130.   #--------------------------------------------------------------------------#
  9131.   def start()
  9132.     super()
  9133.   end
  9134.  
  9135.   #--------------------------------------------------------------------------#
  9136.   # * new-method :return_scene
  9137.   #--------------------------------------------------------------------------#
  9138.   def return_scene()
  9139.     case @calledfrom
  9140.     when :map
  9141.       $scene = Scene_Map.new()
  9142.     when :menu
  9143.       $scene = Scene_Menu.new( @return_index )
  9144.     end  
  9145.   end
  9146.  
  9147.   #--------------------------------------------------------------------------#
  9148.   # * super-method :terminate
  9149.   #--------------------------------------------------------------------------#  
  9150.   def terminate()
  9151.     super()
  9152.     dispose_menu_background()
  9153.     @help_window.dispose() unless @help_window.nil?()     ; @help_window = nil
  9154.     @obj_window.dispose() unless @obj_window.nil?()       ; @obj_window = nil
  9155.     @slot_window.dispose() unless @slot_window.nil?()     ; @slot_window = nil
  9156.     @status_window.dispose() unless @status_window.nil?() ; @status_window = nil
  9157.   end
  9158.  
  9159.   #--------------------------------------------------------------------------#
  9160.   # * super-method :update
  9161.   #--------------------------------------------------------------------------#  
  9162.   def update()
  9163.     super()
  9164.     update_menu_background()
  9165.     @obj_window.update() ; @slot_window.update()
  9166.     # // Basic Update
  9167.     if Input.trigger?( Input::B )
  9168.       command_cancel()
  9169.     elsif Input.trigger?( Input::R ) && @index_call    
  9170.       command_next()
  9171.     elsif Input.trigger?( Input::L ) && @index_call
  9172.       command_prev()
  9173.     # // Actual Input    
  9174.     elsif Input.trigger?( Input::C )
  9175.       command_accept()
  9176.     elsif Input.trigger?( Input::Z )
  9177.       # // Used to pop extended help window, if I ever implement it
  9178.     elsif Input.trigger?( Input::X ) || Input.trigger?( Input::LEFT )  
  9179.       command_prevslot()
  9180.     elsif Input.trigger?( Input::Y ) || Input.trigger?( Input::RIGHT )  
  9181.       command_nextslot()
  9182.     end  
  9183.   end  
  9184.  
  9185.   #--------------------------------------------------------------------------#
  9186.   # * new-method :command_cancel
  9187.   #--------------------------------------------------------------------------#
  9188.   def command_cancel()
  9189.     Sound.play_cancel()
  9190.     return_scene()
  9191.   end
  9192.  
  9193.   #--------------------------------------------------------------------------#
  9194.   # * new-method :command_next
  9195.   #--------------------------------------------------------------------------#
  9196.   def command_next()
  9197.     Sound.play_decision()
  9198.     $scene = self.class.new(
  9199.       (@act_index+1)%$game_party.members.size, @calledfrom, @return_index )
  9200.   end
  9201.  
  9202.   #--------------------------------------------------------------------------#
  9203.   # * new-method :command_prev
  9204.   #--------------------------------------------------------------------------#
  9205.   def command_prev()
  9206.     Sound.play_decision()  
  9207.     $scene = self.class.new(
  9208.       (@act_index-1)%$game_party.members.size, @calledfrom, @return_index )
  9209.   end
  9210.  
  9211.   #--------------------------------------------------------------------------#
  9212.   # * new-method :command_nextslot
  9213.   #--------------------------------------------------------------------------#
  9214.   def command_nextslot()
  9215.     Sound.play_cursor()
  9216.     @slot_window.index = (@slot_window.index + 1) % @slot_window.item_max
  9217.   end
  9218.    
  9219.   #--------------------------------------------------------------------------#
  9220.   # * new-method :command_prevslot
  9221.   #--------------------------------------------------------------------------#
  9222.   def command_prevslot()
  9223.     Sound.play_cursor()
  9224.     @slot_window.index = (@slot_window.index - 1) % @slot_window.item_max
  9225.   end
  9226.    
  9227.   #--------------------------------------------------------------------------#
  9228.   # * new-method :command_accept
  9229.   #--------------------------------------------------------------------------#
  9230.   def command_accept()
  9231.   end
  9232.  
  9233. end  
  9234.  
  9235. #==============================================================================#
  9236. # ** YGG::Scenes::ItemSet
  9237. #==============================================================================#
  9238. class ::YGG::Scenes::ItemSet < ::YGG::Scenes::ObjSet
  9239.  
  9240.   #--------------------------------------------------------------------------#
  9241.   # * super-method :start
  9242.   #--------------------------------------------------------------------------#  
  9243.   def start()
  9244.     super()
  9245.     create_menu_background()
  9246.     @help_window   = ::Window_Help.new()
  9247.     @status_window = ::Window_SkillStatus.new( 0, 56, @actor )
  9248.     @obj_window   = ::YGG::Windows::ItemList.new(
  9249.       @actor,
  9250.       Graphics.width/2, 112,
  9251.       Graphics.width/2, Graphics.height-112 )
  9252.     @obj_window.help_window = @help_window  
  9253.     @slot_window   = ::YGG::Windows::ActorItemSlots.new(
  9254.       @actor,
  9255.       0, 112,
  9256.       Graphics.width/2, Graphics.height-112 )
  9257.     @obj_window.active = true  
  9258.   end
  9259.  
  9260.   #--------------------------------------------------------------------------#
  9261.   # * new-method :command_accept
  9262.   #--------------------------------------------------------------------------#
  9263.   def command_accept()
  9264.     if @obj_window.enabled?( @obj_window.index ) || @obj_window.obj.nil?()
  9265.       Sound.play_decision
  9266.       id = @obj_window.item.nil?() ? 0 : @obj_window.item.id
  9267.       @actor.set_item_slot( @slot_window.index, id )
  9268.       @obj_window.selective_refresh() #.draw_item( @obj_window.index )
  9269.       @slot_window.refresh()
  9270.     else
  9271.       Sound.play_buzzer()
  9272.     end  
  9273.   end
  9274.  
  9275. end
  9276.  
  9277. # // Scene_ItemSet.new( actor, called_from, [return_index)]
  9278. Scene_ItemSet = YGG::Scenes::ItemSet
  9279.  
  9280. #==============================================================================#
  9281. # ** YGG::Scenes::SkillSet
  9282. #==============================================================================#
  9283. class ::YGG::Scenes::SkillSet < ::YGG::Scenes::ObjSet
  9284.  
  9285.   #--------------------------------------------------------------------------#
  9286.   # * super-method :start
  9287.   #--------------------------------------------------------------------------#  
  9288.   def start()
  9289.     super()
  9290.     create_menu_background()
  9291.     @help_window   = ::Window_Help.new()
  9292.     @status_window = ::Window_SkillStatus.new( 0, 56, @actor )
  9293.     @obj_window    = ::YGG::Windows::SkillList.new(
  9294.       @actor,
  9295.       Graphics.width/2, 112,
  9296.       Graphics.width/2, Graphics.height-112 )
  9297.     @obj_window.help_window = @help_window  
  9298.     @slot_window   = ::YGG::Windows::ActorSkillSlots.new(
  9299.       @actor,
  9300.       0, 112,
  9301.       Graphics.width/2, Graphics.height-112 )
  9302.     @obj_window.active = true  
  9303.   end
  9304.    
  9305.   #--------------------------------------------------------------------------#
  9306.   # * new-method :command_accept
  9307.   #--------------------------------------------------------------------------#
  9308.   def command_accept()
  9309.     if @obj_window.enabled?( @obj_window.index ) || @obj_window.obj.nil?()
  9310.       Sound.play_decision
  9311.       id = @obj_window.skill.nil?() ? 0 : @obj_window.skill.id
  9312.       @actor.set_skill_slot( @slot_window.index, id )
  9313.       @obj_window.selective_refresh() #draw_item( @obj_window.index )
  9314.       @slot_window.refresh()
  9315.     else
  9316.       Sound.play_buzzer()
  9317.     end  
  9318.   end
  9319.  
  9320. end  
  9321. # // Scene_SkillSet.new( actor, called_from, [return_index)]
  9322. Scene_SkillSet = YGG::Scenes::SkillSet
  9323.  
  9324. # // (YGG_HudSetting) // #
  9325. module YGG ; end ; module YGG::Handlers ; end
  9326. #==============================================================================#
  9327. # ** YGG::Handlers::Hud
  9328. #==============================================================================#
  9329. class ::YGG::Handlers::Hud
  9330. #==============================================================================#
  9331. # ** Sprite_Back
  9332. #==============================================================================#  
  9333.   class Sprite_Back < ::Sprite
  9334.    
  9335.   #--------------------------------------------------------------------------#
  9336.   # * Public Instance Variables
  9337.   #--------------------------------------------------------------------------#  
  9338.     attr_accessor :add_x, :add_y, :add_z
  9339.    
  9340.   #--------------------------------------------------------------------------#
  9341.   # * super-method :initialize
  9342.   #--------------------------------------------------------------------------#      
  9343.     def initialize( viewport )
  9344.       @add_x, @add_y, @add_z = 0, 0, 0
  9345.       super( viewport )
  9346.     end
  9347.    
  9348.   end
  9349.  
  9350. #==============================================================================#
  9351. # ** Sprite_Icon
  9352. #==============================================================================#    
  9353.   class Sprite_Icon < ::Sprite
  9354.   #--------------------------------------------------------------------------#
  9355.   # * Constant(s)
  9356.   #--------------------------------------------------------------------------#    
  9357.     ICON_SIZE = [24, 24]
  9358.    
  9359.   #--------------------------------------------------------------------------#
  9360.   # * Public Instance Variable(s)
  9361.   #--------------------------------------------------------------------------#  
  9362.     attr_reader :icon_index
  9363.     attr_accessor :add_x, :add_y, :add_z
  9364.     attr_accessor :active_effect
  9365.    
  9366.   #--------------------------------------------------------------------------#
  9367.   # * super-method :initialize
  9368.   #--------------------------------------------------------------------------#      
  9369.     def initialize( viewport=nil )
  9370.       @add_x, @add_y, @add_z = 0, 0, 0
  9371.       super( viewport )
  9372.       self.bitmap = Cache.system( "Iconset" )
  9373.       self.icon_index = 0
  9374.       @active_effect = "none"
  9375.     end
  9376.  
  9377.   #--------------------------------------------------------------------------#
  9378.   # * new-method :icon_index=
  9379.   #--------------------------------------------------------------------------#  
  9380.     def icon_index=( new_index )
  9381.       return if @icon_index == new_index
  9382.       self.src_rect.set(
  9383.        new_index % 16 * ICON_SIZE[0], new_index / 16 * ICON_SIZE[1],
  9384.        ICON_SIZE[0], ICON_SIZE[1] )
  9385.       @icon_index = new_index
  9386.     end
  9387.    
  9388.   #--------------------------------------------------------------------------#
  9389.   # * overwrite-method :update
  9390.   #--------------------------------------------------------------------------#    
  9391.     def update()
  9392.       case @active_effect
  9393.       when "fadeout"
  9394.         self.opacity -= 255 / 30.0
  9395.         @active_effect = "none" if self.opacity == 0
  9396.       when "fadein"  
  9397.         self.opacity += 255 / 30.0
  9398.         @active_effect = "none" if self.opacity == 255
  9399.       end  
  9400.     end
  9401.    
  9402.   end
  9403.  
  9404. #==============================================================================#
  9405. # ** Sprite_ValueBar
  9406. #==============================================================================#      
  9407.   class Sprite_ValueBar < ::Sprite
  9408.    
  9409.   #--------------------------------------------------------------------------#
  9410.   # * Public Instance Variables
  9411.   #--------------------------------------------------------------------------#  
  9412.     attr_accessor :value, :max
  9413.     attr_accessor :add_x, :add_y, :add_z
  9414.    
  9415.   #--------------------------------------------------------------------------#
  9416.   # * super-method :initialize
  9417.   #--------------------------------------------------------------------------#    
  9418.     def initialize( viewport=nil )
  9419.       @add_x, @add_y, @add_z = 0, 0, 0
  9420.       super( viewport )
  9421.       @value = 0 ; @max = 1
  9422.     end
  9423.  
  9424.   #--------------------------------------------------------------------------#
  9425.   # * super-method :update
  9426.   #--------------------------------------------------------------------------#    
  9427.     def update()
  9428.       super()
  9429.       self.src_rect.width = self.bitmap.width * @value / @max unless self.bitmap.nil?()
  9430.     end  
  9431.    
  9432.   end
  9433.  
  9434. #==============================================================================#
  9435. # ** Sprite_TinyPortrait
  9436. #==============================================================================#      
  9437.   class Sprite_TinyPortrait < ::Sprite
  9438.    
  9439.   #--------------------------------------------------------------------------#
  9440.   # * Public Instance Variables
  9441.   #--------------------------------------------------------------------------#    
  9442.     attr_accessor :add_x, :add_y, :add_z
  9443.  
  9444.   #--------------------------------------------------------------------------#
  9445.   # * super-method :initialize
  9446.   #--------------------------------------------------------------------------#
  9447.     def initialize( viewport=nil )
  9448.       @add_x, @add_y, @add_z = 0, 0, 0
  9449.       super( viewport )
  9450.     end
  9451.    
  9452.   #--------------------------------------------------------------------------#
  9453.   # * new-method :refresh
  9454.   #--------------------------------------------------------------------------#  
  9455.     def refresh( character_name, character_index )
  9456.       self.bitmap = Cache.character( character_name )
  9457.       sign = character_name[/^[\!\$]./]
  9458.       if sign != nil and sign.include?('$')
  9459.         cw = bitmap.width / 3
  9460.         ch = bitmap.height / 4
  9461.       else
  9462.         cw = bitmap.width / 12
  9463.         ch = bitmap.height / 8
  9464.       end
  9465.       n = character_index
  9466.       self.src_rect.set( (n%4*3+1)*cw, (n/4*4)*ch, cw, ch )
  9467.     end
  9468.    
  9469.   end
  9470.  
  9471.   #--------------------------------------------------------------------------#
  9472.   # * Public Instance Variables
  9473.   #--------------------------------------------------------------------------#  
  9474.   attr_reader :viewport
  9475.   attr_reader :x, :y, :z
  9476.   attr_accessor :actor
  9477.   attr_reader :visible
  9478.  
  9479.   #--------------------------------------------------------------------------#
  9480.   # * new-method :initialize
  9481.   #--------------------------------------------------------------------------#  
  9482.   def initialize( actor, x=0, y=0, z=0 )
  9483.     @visible = true
  9484.     @disposed = false
  9485.     @x, @y, @z = x, y, z
  9486.     @actor = actor
  9487.     create_all()
  9488.     refresh()
  9489.   end
  9490.  
  9491.   #--------------------------------------------------------------------------#
  9492.   # * new-method :create_all
  9493.   #--------------------------------------------------------------------------#
  9494.   def create_all()
  9495.     @skill_setsize = 5#@actor.skill_slot_size
  9496.     @item_setsize  = 5#@actor.item_slot_size
  9497.     create_skills()
  9498.     create_items()
  9499.     @back_sprite = Sprite_Back.new( self.viewport )
  9500.     @back_sprite.bitmap = Cache.system( "1x6Hud2" )
  9501.     @hp_sprite   = Sprite_ValueBar.new( self.viewport )
  9502.     @hp_sprite.bitmap = Cache.system( "1x6Hud_HpBar" )
  9503.     @hp_sprite.add_x = 232
  9504.     @hp_sprite.add_y = 12
  9505.     @hp_sprite.add_z = 3
  9506.     @mp_sprite   = Sprite_ValueBar.new( self.viewport )
  9507.     @mp_sprite.bitmap = Cache.system( "1x6Hud_MpBar" )
  9508.     @mp_sprite.add_x = 232
  9509.     @mp_sprite.add_y = 28
  9510.     @mp_sprite.add_z = 3
  9511.     # // Extended
  9512.     @exp_sprite   = Sprite_ValueBar.new( self.viewport )
  9513.     @exp_sprite.bitmap = Cache.system( "1x6Hud_ExpBar" )
  9514.     @exp_sprite.add_x = 40
  9515.     @exp_sprite.add_y = 9
  9516.     @exp_sprite.add_z = 3
  9517.     if YGG::USE_SHIFT_SYSTEM
  9518.       @shift_sprite   = Sprite_ValueBar.new( self.viewport )
  9519.       @shift_sprite.bitmap = Cache.system( "1x6Hud_ShiftBar" )
  9520.       @shift_sprite.add_x = 384
  9521.       @shift_sprite.add_y = 9
  9522.       @shift_sprite.add_z = 3
  9523.     end
  9524.     @charge_sprite   = Sprite_ValueBar.new( self.viewport )
  9525.     @charge_sprite.bitmap = Cache.system( "1x6Hud_ChargeBar" )
  9526.     @charge_sprite.add_x = 472
  9527.     @charge_sprite.add_y = 9
  9528.     @charge_sprite.add_z = 3
  9529.     @portrait_sprite = Sprite_TinyPortrait.new( self.viewport )
  9530.     @portrait_sprite.add_x = 196
  9531.     @portrait_sprite.add_y = 8
  9532.     @portrait_sprite.add_z = 3
  9533.     @sprites = [@back_sprite, @hp_sprite, @mp_sprite, @portrait_sprite]
  9534.     @sprites+= [@exp_sprite, @charge_sprite]
  9535.     @sprites << @shift_sprite unless @shift_sprite.nil?()
  9536.   end
  9537.  
  9538.   #--------------------------------------------------------------------------#
  9539.   # * new-method :disposed?
  9540.   #--------------------------------------------------------------------------#
  9541.   def disposed?() ; return @disposed ; end
  9542.    
  9543.   #--------------------------------------------------------------------------#
  9544.   # * new-method :dispose
  9545.   #--------------------------------------------------------------------------#
  9546.   def dispose()
  9547.     each_sprite { |s| s.dispose() }
  9548.     @back_sprite = nil ; @hp_sprite = nil ; @mp_sprite = nil
  9549.     @skills = nil ; @items = nil
  9550.     @disposed = true
  9551.   end
  9552.  
  9553.   #--------------------------------------------------------------------------#
  9554.   # * new-method :refresh
  9555.   #--------------------------------------------------------------------------#
  9556.   def refresh()
  9557.     #each_sprite { |s| s.dispose() }
  9558.     @portrait_sprite.refresh( @actor.character_name, @actor.character_index )
  9559.     refresh_xyz()
  9560.   end
  9561.  
  9562.   #--------------------------------------------------------------------------#
  9563.   # * new-method :create_skills
  9564.   #--------------------------------------------------------------------------#  
  9565.   def create_skills()
  9566.     @skills = Array.new( @skill_setsize ).map! { Sprite_Icon.new( self.viewport ) }
  9567.     for i in 0...@skills.size
  9568.       @skills[i].add_x = 36 + i * 32
  9569.       @skills[i].add_y = 16
  9570.       @skills[i].add_z = 3
  9571.       @skills[i].bush_opacity = 48
  9572.     end  
  9573.   end
  9574.  
  9575.   #--------------------------------------------------------------------------#
  9576.   # * new-method :create_items
  9577.   #--------------------------------------------------------------------------#  
  9578.   def create_items()
  9579.     @items = Array.new( @item_setsize ).map! { Sprite_Icon.new( self.viewport ) }
  9580.     for i in 0...@items.size
  9581.       @items[i].add_x = 376 + i * 32
  9582.       @items[i].add_y = 16
  9583.       @items[i].add_z = 3
  9584.       @items[i].bush_opacity = 48
  9585.     end
  9586.   end
  9587.  
  9588.   #--------------------------------------------------------------------------#
  9589.   # * new-method :each_sprite
  9590.   #--------------------------------------------------------------------------#  
  9591.   def each_sprite()
  9592.     (@sprites+@skills.to_a+@items.to_a).each { |s| yield s unless s.nil?() }
  9593.   end
  9594.  
  9595.   #--------------------------------------------------------------------------#
  9596.   # * new-method :x=
  9597.   #--------------------------------------------------------------------------#  
  9598.   def x=( new_x )
  9599.     @x = new_x ; refresh_x()
  9600.   end
  9601.  
  9602.   #--------------------------------------------------------------------------#
  9603.   # * new-method :visible=
  9604.   #--------------------------------------------------------------------------#  
  9605.   def visible=( new_visible )
  9606.     @visible = new_visible ; refresh_visible()
  9607.   end
  9608.  
  9609.   #--------------------------------------------------------------------------#
  9610.   # * new-method :y=
  9611.   #--------------------------------------------------------------------------#  
  9612.   def y=( new_y )
  9613.     @y = new_y ; refresh_y()
  9614.   end
  9615.  
  9616.   #--------------------------------------------------------------------------#
  9617.   # * new-method :z=
  9618.   #--------------------------------------------------------------------------#  
  9619.   def z=( new_z )
  9620.     @z = new_z ; refresh_z()
  9621.   end
  9622.  
  9623.   #--------------------------------------------------------------------------#
  9624.   # * new-method :viewport=
  9625.   #--------------------------------------------------------------------------#  
  9626.   def viewport=( new_viewport )
  9627.     @viewport = new_viewport
  9628.     each_sprite { |s| s.viewport = @viewport }
  9629.   end
  9630.  
  9631.   #--------------------------------------------------------------------------#
  9632.   # * new-method :refresh_x
  9633.   #--------------------------------------------------------------------------#
  9634.   def refresh_x()
  9635.     each_sprite { |s| s.x = @x + s.add_x }
  9636.   end
  9637.  
  9638.   #--------------------------------------------------------------------------#
  9639.   # * new-method :refresh_y
  9640.   #--------------------------------------------------------------------------#
  9641.   def refresh_y()
  9642.     each_sprite { |s| s.y = @y + s.add_y }
  9643.   end
  9644.  
  9645.   #--------------------------------------------------------------------------#
  9646.   # * new-method :refresh_z
  9647.   #--------------------------------------------------------------------------#
  9648.   def refresh_z()
  9649.     each_sprite { |s| s.z = @z + s.add_z }
  9650.   end
  9651.  
  9652.   #--------------------------------------------------------------------------#
  9653.   # * new-method :refresh_xyz
  9654.   #--------------------------------------------------------------------------#
  9655.   def refresh_xyz()
  9656.     each_sprite { |s| s.x, s.y, s.z = @x + s.add_x, @y + s.add_y, @z + s.add_z }
  9657.   end
  9658.  
  9659.   #--------------------------------------------------------------------------#
  9660.   # * new-method :refresh_visible
  9661.   #--------------------------------------------------------------------------#
  9662.   def refresh_visible()
  9663.     each_sprite { |s| s.visible = @visible }
  9664.   end
  9665.  
  9666.   #--------------------------------------------------------------------------#
  9667.   # * new-method :update
  9668.   #--------------------------------------------------------------------------#
  9669.   def update()
  9670.     if @actor.nil?()
  9671.       @hp_sprite.value, @hp_sprite.max = 0, 1
  9672.       @mp_sprite.value, @mp_sprite.max = 0, 1
  9673.       @exp_sprite.value, @exp_sprite.max = 0, 1
  9674.       @shift_sprite.value, @shift_sprite.max = 0, 1 unless @shift_sprite.nil?()
  9675.       @charge_sprite.value, @charge_sprite.max = 0, 1
  9676.     else
  9677.       @hp_sprite.value, @hp_sprite.max = @actor.hp, @actor.maxhp
  9678.       @mp_sprite.value, @mp_sprite.max = @actor.mp, @actor.maxmp
  9679.       @exp_sprite.value, @exp_sprite.max = @actor.level_exp, @actor.next_level_exp
  9680.       @shift_sprite.value, @shift_sprite.max = $game_yggdrasil.shift_system.time, $game_yggdrasil.shift_system.cap unless @shift_sprite.nil?()
  9681.       @charge_sprite.value, @charge_sprite.max = @actor.cooldown, @actor.cooldown_max
  9682.     end  
  9683.     @hp_sprite.update()
  9684.     @mp_sprite.update()
  9685.     @exp_sprite.update()
  9686.     @shift_sprite.update() unless @shift_sprite.nil?()
  9687.     @charge_sprite.update()
  9688.     unless @actor.nil?()
  9689.       for i in 0...@skills.size
  9690.         obj = @actor.skill_slot( i )
  9691.         hnd = @actor.get_skill_handle( obj.nil?() ? 0 : obj.id )
  9692.         sprite = @skills[i]
  9693.         sprite.tone.gray = 255.0 * hnd.time.to_f / [hnd.cap, 1].max
  9694.         sprite.bush_depth = sprite.height * hnd.time.to_f / [hnd.cap, 1].max
  9695.         icon_index = obj.nil?() ? 0 : obj.icon_index
  9696.         if sprite.icon_index != icon_index
  9697.           if sprite.active_effect == "none" && sprite.opacity == 0
  9698.             sprite.icon_index = icon_index
  9699.             sprite.active_effect = "fadein"
  9700.           elsif sprite.active_effect == "none" && sprite.opacity > 0
  9701.             sprite.opacity = 0 if sprite.icon_index == 0
  9702.             sprite.active_effect = "fadeout"
  9703.           end  
  9704.         end  
  9705.         sprite.update()
  9706.       end
  9707.       for i in 0...@items.size
  9708.         obj = @actor.item_slot( i )
  9709.         hnd = @actor.get_item_handle( obj.nil?() ? 0 : obj.id )
  9710.         sprite = @items[i]
  9711.         sprite.tone.gray = 255.0 * hnd.time.to_f / [hnd.cap, 1].max
  9712.         sprite.bush_depth = sprite.height * hnd.time.to_f / [hnd.cap, 1].max
  9713.         icon_index = obj.nil?() ? 0 : obj.icon_index
  9714.         if sprite.icon_index != icon_index
  9715.           if sprite.active_effect == "none" && sprite.opacity == 0
  9716.             sprite.icon_index = icon_index
  9717.             sprite.active_effect = "fadein"
  9718.           elsif sprite.active_effect == "none" && sprite.opacity > 0
  9719.             sprite.opacity = 0 if sprite.icon_index == 0
  9720.             sprite.active_effect = "fadeout"
  9721.           end  
  9722.         end  
  9723.         sprite.update()
  9724.       end  
  9725.     end  
  9726.   end
  9727.  
  9728. end
  9729.  
  9730. #==============================================================================#
  9731. # ** YGG::System
  9732. #==============================================================================#
  9733. class YGG::System
  9734.  
  9735. if YGG::HUD_SWITCH.nil?() || YGG::HUD_SWITCH == 0
  9736.  
  9737.   #--------------------------------------------------------------------------#
  9738.   # * new-method :hud_visible?
  9739.   #--------------------------------------------------------------------------#  
  9740.   def hud_visible?() ; return true ; end
  9741.  
  9742. else
  9743.  
  9744.   #--------------------------------------------------------------------------#
  9745.   # * new-method :hud_visible?
  9746.   #--------------------------------------------------------------------------#  
  9747.   def hud_visible?()
  9748.     return $game_switches[::YGG::HUD_SWITCH]
  9749.   end
  9750.  
  9751. end
  9752.  
  9753. if YGG::DROPS_WINDOW_SWITCH.nil?() || YGG::DROPS_WINDOW_SWITCH == 0
  9754.  
  9755.   #--------------------------------------------------------------------------#
  9756.   # * new-method :drops_window_visible?
  9757.   #--------------------------------------------------------------------------#
  9758.   def drops_window_visible?() ; return true ; end
  9759.  
  9760. else
  9761.  
  9762.   #--------------------------------------------------------------------------#
  9763.   # * new-method :drops_window_visible?
  9764.   #--------------------------------------------------------------------------#
  9765.   def drops_window_visible?()
  9766.     return $game_switches[::YGG::DROPS_WINDOW_SWITCH]
  9767.   end
  9768.  
  9769. end
  9770.  
  9771.   #alias :ygg_hud_sys_initialize :initialize unless $@
  9772.   #def initialize( *args, &block )
  9773.   #  ygg_hud_sys_initialize( *args, &block )
  9774.   #  @hud_wrapper = YGG::Handlers::HudWrapper.new()
  9775.   #end
  9776.  
  9777. end
  9778.  
  9779. if YGG::USE_HUD
  9780. #==============================================================================#
  9781. # ** Scene_Map
  9782. #==============================================================================#
  9783. class Scene_Map < Scene_Base
  9784.  
  9785.   @@__temp = 0
  9786.  
  9787.   #--------------------------------------------------------------------------#
  9788.   # * alias-method :start
  9789.   #--------------------------------------------------------------------------#
  9790.   alias :ygg1x6_hud_start :start unless $@
  9791.   def start( *args, &block )
  9792.     ygg1x6_hud_start( *args, &block )
  9793.     @ygg_hud = ::YGG::Handlers::Hud.new( $game_player.ygg_battler, -12, Graphics.height-48, 1000 )
  9794.     @@__temp = $game_yggdrasil.hud_visible?()
  9795.     @ygg_hud.visible = @@__temp if @ygg_hud.visible != @@__temp
  9796.     @ygg_hud.update()
  9797.   end
  9798.  
  9799.   #--------------------------------------------------------------------------#
  9800.   # * alias-method :update
  9801.   #--------------------------------------------------------------------------#
  9802.   alias :ygg1x6_hud_update :update unless $@
  9803.   def update( *args, &block )
  9804.     ygg1x6_hud_update( *args, &block )
  9805.     if @ygg_hud.actor != $game_player.ygg_battler
  9806.       @ygg_hud.actor = $game_player.ygg_battler
  9807.       @ygg_hud.refresh()
  9808.     end
  9809.     @@__temp = $game_yggdrasil.hud_visible?()
  9810.     @ygg_hud.visible = @@__temp if @ygg_hud.visible != @@__temp
  9811.     @ygg_hud.update()
  9812.   end
  9813.  
  9814.   #--------------------------------------------------------------------------#
  9815.   # * alias-method :terminate
  9816.   #--------------------------------------------------------------------------#
  9817.   alias :ygg1x6_hud_terminate :terminate unless $@
  9818.   def terminate( *args, &block )
  9819.     ygg1x6_hud_terminate( *args, &block )
  9820.     @ygg_hud.dispose() unless @ygg_hud.nil?() ; @ygg_hud = nil
  9821.   end
  9822.  
  9823. end  
  9824.  
  9825. end
  9826.  
  9827. #==============================================================================#
  9828. # ** YGG::System
  9829. #==============================================================================#
  9830. class YGG::System
  9831.  
  9832.   #--------------------------------------------------------------------------#
  9833.   # * new-method :start_target_selection
  9834.   #--------------------------------------------------------------------------#  
  9835.   def start_target_selection( target_count=1, targets=[] )
  9836.     return [] if targets.empty?()
  9837.     darken_sprite = Sprite.new()
  9838.     darken_sprite.bitmap = Cache.picture( "BlackSheet" )
  9839.     darken_sprite.opacity = 96
  9840.     target_cursor = Sprite.new()
  9841.     target_cursor.bitmap = Cache.picture( "YGG2_Cursor" )
  9842.     target_cursor.ox, target_cursor.oy = 16, 64
  9843.     hold_cursors = [] ; target_index = 0
  9844.     targets.sort! { |a, b| a.screen_x <=> b.screen_x }
  9845.     target = targets[target_index]
  9846.     selected_targets = []
  9847.     target_cursor.x, target_cursor.y = target.screen_x, target.screen_y unless target.nil?()
  9848.     loop do
  9849.       Graphics.update()
  9850.       Input.update()
  9851.       if Input.trigger?( Input::RIGHT ) || Input.trigger?( Input::DOWN )
  9852.         Sound.play_cursor()
  9853.         target_index = (target_index + 1) % [targets.size, 1].max
  9854.         target = targets[target_index]
  9855.       elsif Input.trigger?( Input::LEFT ) || Input.trigger?( Input::UP )
  9856.         Sound.play_cursor()
  9857.         target_index = (target_index - 1) % [targets.size, 1].max
  9858.         target = targets[target_index]
  9859.       end
  9860.       if Input.trigger?( Input::C )
  9861.         Sound.play_decision()
  9862.         selected_targets << target
  9863.         if selected_targets.size == target_count
  9864.           break
  9865.         else
  9866.           sp = Sprite.new()
  9867.           sp.bitmap = Cache.picture( "YGG2_Cursor" )
  9868.           sp.ox, sp.oy = 16, 64
  9869.           sp.zoom_x, sp.zoom_y = 0.75, 0.75
  9870.           sp.x, sp.y = target.screen_x, target.screen_y
  9871.           hold_cursors << sp
  9872.         end  
  9873.       elsif Input.trigger?( Input::B )
  9874.         Sound.play_cancel()
  9875.         selected_targets.pop()
  9876.         sp = hold_cursors.pop() ; sp.dispose() unless sp.nil?()
  9877.         break if selected_targets.empty?()
  9878.       end  
  9879.       unless target.nil?()
  9880.         if target.screen_x > target_cursor.x
  9881.           target_cursor.x = [target_cursor.x + Graphics.width/30.0, target.screen_x].min
  9882.         elsif target.screen_x < target_cursor.x  
  9883.           target_cursor.x = [target_cursor.x - Graphics.width/30.0, target.screen_x].max
  9884.         end  
  9885.         if target.screen_y > target_cursor.y
  9886.           target_cursor.y = [target_cursor.y + Graphics.height/30.0, target.screen_y].min
  9887.         elsif target.screen_y < target_cursor.y
  9888.           target_cursor.y = [target_cursor.y - Graphics.height/30.0, target.screen_y].max
  9889.         end
  9890.       end  
  9891.     end  
  9892.     hold_cursors.each { |s| s.dispose unless s.nil?() } ; hold_cursors = nil
  9893.     target_cursor.dispose() ; darken_sprite.dispose()
  9894.     return selected_targets
  9895.   end
  9896.  
  9897.   def start_xy_selection()
  9898.   end
  9899.  
  9900.   def gameover_process()
  9901.     $game_temp.next_scene = "gameover"
  9902.   end
  9903.  
  9904. end  
  9905.  
  9906. #=*==========================================================================*=#
  9907. # ** END OF FILE
  9908. #=*==========================================================================*=#
  9909.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement