Advertisement
Kakakadafi

[Overwrite] XAS

Oct 20th, 2017
584
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 270.55 KB | None | 0 0
  1.  
  2. =begin
  3. ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  4. ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  5. ■■ X A S  - Xiderwong Action System (For Advanced Users)
  6. ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  7. ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  8.                                                                        
  9.  X - Xiderowng
  10.  A - Action
  11.  S - System
  12.  
  13.  Created by XIDEROWNG  (XMS / XRXS / ちいさな本屋 / 森穂(もりほ)  
  14.  http://xrxs.at-ninja.jp/
  15.  
  16. #===============================================================================
  17. # ■ TERMS OF USE
  18. #===============================================================================
  19.  
  20.   English
  21.  
  22.  - You need to give credits to Xiderowng.
  23.  - You need to link the official Xiderowng website.
  24.    http://xrxs.at-ninja.jp/
  25.  
  26.   Português
  27.  
  28.  > Termos de uso <
  29.  - Você precisa dar os creditos para o Xiderowg.
  30.  - Você precisa divulgar a página oficial do Xiderowg.
  31.    http://xrxs.at-ninja.jp/
  32.    
  33.  
  34. #===============================================================================
  35. # ■ XAS Hero Edition ACE (Ver Experimental 0.5  - 2012 / 01 / 04)                                                
  36. #===============================================================================
  37.  
  38.  Updates for XAS Hero Edtion.
  39.  http://www.atelier-rgss.com/
  40.  
  41.  XAS Tutorials.
  42.  http://xasabs.wordpress.com/
  43.  
  44. #===============================================================================
  45. # ■ Caracteristicas (MAIN FEATURES)                                                          
  46. #===============================================================================
  47.    Sistema de batalha ativa no mapa (ou) e de interação com o cenário.
  48.    
  49. #===============================================================================
  50. # ■ Histórico  
  51. #===============================================================================
  52.   (V 0.5)
  53.    - introdução inicial do XAS Hero Edition para o Rpg Maker VX ACE.
  54.    - Versão de teste para correção de bugs, glitches e teste de performance.
  55. =end
  56.  
  57.  
  58. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  59. # XAS - SETUP
  60. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  61. #===============================================================================
  62. # ■ XAS SYSTEN SETTING
  63. #===============================================================================
  64. # Disable one of the systems below if you have any problem
  65. # compatibility with other systems of script, performance problem or
  66. # if you do not want to use any of the following systems
  67. #-------------------------------------------------------------------------------
  68. module XAS_SYSTEM
  69.   # Enable the battle system, leave it as false if you want to use only the
  70.   # system tools (Interaction scenario)
  71.   # If you want to disable the battle system in the game use the command
  72.   # below.
  73.   #
  74.   # $game_system.xas_battle = X
  75.   #
  76.   BATTLE_SYSTEM = true
  77.   #Enable the display of damage(Sprite).
  78.   DAMAGE_POP = true
  79.   # Enable the system pose stock.
  80.   CHARACTER_POSE_NAME = true
  81.   # Enable the system sprites
  82.   CHARACTER_SPRITE_EFFECTS = true
  83.   # Enable the system dash advanced to the XAS.
  84.   DASH_SYSTEM = false
  85.   # Enable the system to diagonal player.
  86.   PLAYER_DIAGONAL_MOVEMENT  = true
  87.   # Enable the diagonal system for the event
  88.   EVENT_DIAGONAL_MOVEMENT  = true
  89.   # Enable the system conditions for battler.
  90.   STATE_SYSTEM = true
  91.   # Definition of the map that will be the events of the tools.
  92.   ACTION_TEMPLATE_MAP_ID = 22
  93.   # Setting the variable ID representing ID tool,
  94.   # This ID is used to create interactive events with the tools.
  95.   HIT_ID = 3
  96. end
  97.  
  98. #===============================================================================
  99. # ■ XAS BUTTON SETTING
  100. #===============================================================================
  101. module XAS_BUTTON
  102.   #Defining the attack button.
  103.   ACTION_1_BUTTON = Input::X
  104.   #Defining Button setting shell.
  105.   ACTION_2_BUTTON = Input::L
  106.   #Defining button skill
  107.   SKILL_BUTTON = Input::Z  
  108.   #Defining item button.
  109.   ITEM_BUTTON = Input::Y
  110.   #Defining the run button.
  111.   DASH_BUTTON = Input::A
  112.   #Defining button to change leader.
  113.   CHANGE_LEADER_BUTTON = Input::R
  114.   #Activate the attack button.
  115.   ENABLE_ACTION_1_BUTTON = true
  116.   #Activate the button shield.  
  117.   ENABLE_ACTION_2_BUTTON = true
  118.   #Activate the button skill.
  119.   ENABLE_SKILL_BUTTON = true
  120.   #Activate the button item.
  121.   ENABLE_ITEM_BUTTON = true
  122.   #Enable the run button.
  123.   ENABLE_DASH_BUTTON = true
  124.   #Activate Enable button to change leader.  
  125.   ENABLE_CHANGE_LEADER_BUTTON = true
  126. end
  127.  
  128. #===============================================================================
  129. # ■ WORD SETTING
  130. #===============================================================================
  131. # Definition of terms used in XAS
  132. #-------------------------------------------------------------------------------
  133. module XAS_WORD
  134.   # Activate the words.
  135.   ENABLE_WORD = true
  136.   # Word used when the battler uses the defense system.
  137.   GUARD = "Guard"
  138.   # Word used when you do not have enough MP to use the skill.
  139.   NO_MP = "No MP"
  140.   # Word used when you do not have the ability to activate item.
  141.   NO_ITEM = "No Item"  
  142.   # Word used when the character level increases.
  143.   LEVEL_UP = "Level Up"
  144.   # Word used when the character is sealed with the actions.
  145.   SEAL = "Sealed!"
  146.   # Word used when the character is invincible.
  147.   INVINCIBLE = "Invincible!"
  148.   # Word used to define experience.
  149.   EXP = "Exp"
  150.   #Word used when the target dodges the attack.
  151.   EVADED = "Evaded!"
  152.   # Word used when the battler misses the attack.
  153.   MISSED = "Missed!"
  154.   # Word used when the counter is enabled.
  155.   COUNTER = "Counter"
  156.   # Word used when the ability is reflected.
  157.   REFLECT = "Reflected"
  158. end
  159.  
  160. #===============================================================================
  161. # ■ XAS DAMAGE POP
  162. #===============================================================================
  163. #System definition sprites damage.
  164. #-------------------------------------------------------------------------------
  165. module XAS_DAMAGE_POP
  166.   # Source definition.
  167.   DAMAGE_FONT_NAME = "Hobo"
  168.   # Setting the font size.
  169.   DAMAGE_FONT_SIZE = 22
  170.   # Enable bold font.
  171.   DAMAGE_FONT_BOLD = true
  172.   # Enable italic font.
  173.   DAMAGE_FONT_ITALIC = true
  174.   #Enable Zoom in damage when critical damage.
  175.   DAMAGE_CRITICAL_ZOOM = true
  176.   #Display the amount of experience and money.
  177.   DAMAGE_EXP_GOLD_POP = true
  178.   # Display the name of the condition (States).
  179.   DAMAGE_STATE_POP = true
  180.   #Display the name of the item to get on the battlefield.
  181.   DAMAGE_ITEM_POP = false
  182.   # Setting the default font color.
  183.   DAMAGE_DEFAULT_FONT_COLOR = Color.new(255, 255, 255)
  184.   # Setting the color of the background.
  185.   DAMAGE_EXP_FONT_COLOR = Color.new(0, 255, 100)
  186.   # Setting the Color of Money (Gold).
  187.   DAMAGE_GOLD_FONT_COLOR = Color.new(255, 255, 50)
  188.   # Setting the color of the item.
  189.   DAMAGE_ITEM_FONT_COLOR = Color.new(55, 55, 250)
  190. end
  191.  
  192. #===============================================================================
  193. # ■ SOUND SETTING
  194. #===============================================================================
  195. # Setting the system sounds XAS.
  196. #-------------------------------------------------------------------------------
  197. module XAS_SOUND
  198.   #Sound runs to pick up the item.  
  199.   ITEM_DROP = "Heal3"
  200.   #Sound level up to the run
  201.   LEVEL_UP = "Item3"
  202.   #Sound played when no item or mp enough.
  203.   ACTION_COST = "nothing"
  204. end
  205.  
  206. #===============================================================================
  207. # ■ ANIMATION SETTING
  208. #===============================================================================
  209. # System definition animations XAS.
  210. # If you do not want to use the animations, sets the value to 0 (Zero).
  211. #-------------------------------------------------------------------------------
  212. module XAS_ANIMATION
  213.   # Animation when the defense system is activated.
  214.   GUARD_ANIMATION_ID = 127
  215.   #Animation when the leader is replaced.
  216.   CHANGE_LEADER_ANIMATION_ID = 186
  217.   # Animation when the battler hit the target condition invincible.
  218.   INVINCIBLE_ANIMATION_ID = 110
  219.   #Animation when the battler using the system charge weapon.
  220.   CHARGE_ANIMATION1_ID = 191
  221.   # Animation of the battler after the gun is loaded.
  222.   CHARGE_ANIMATION2_ID = 193
  223.   # Animation displayed when loading the skills.
  224.   CAST_TIME_ANIMATION_ID = 193
  225.   # Speed ​​of the animations loop.
  226.   LOOP_ANIMATIONS_SPEED = 60
  227.   # Animation to reflect
  228.   REFLECT_ANIMATION_ID = 128
  229. end
  230.  
  231. #===============================================================================
  232. # ■ GENERAL BATTLER SETTING
  233. #===============================================================================
  234. # General definition of the battle system of the XAS.
  235. #-------------------------------------------------------------------------------
  236. module XAS_BA
  237.   #Time to turn power button change leader.
  238.   CHANGE_LEADER_WAIT_TIME = 45
  239.   #Leave a hud visible when starting the game.
  240.   #You can enable or disable the hud using the code below
  241.   # $game_system.hud_visible = true
  242.   HUD_VISIBLE_AT_STARTUP = false
  243.   # Setting the Switch page shares short.
  244.   SENSOR_SELF_SWITCH = "D"
  245.   # Definition of the variable that defines the area to activate the default page
  246.   # actions short.
  247.   DEFAULT_SENSOR_RANGE_VARIABLE_ID = 6
  248.   # Time standard fallback (lockout) the battler.
  249.   DEFAULT_KNOCK_BACK_DURATION = 30
  250.   # Enable sprite shaking when the battler is in retreat.
  251.   KNOCKBACKING_SHAKE = false
  252.   # Basic speed movement
  253.   BASE_MOVE_SPEED = 3.55
  254.   # Extra speed when the battler is running.
  255.   DASH_MOVE_SPEED = 0
  256.   # Return the position of 4 directions after position diagonally.
  257.   DIAGONAL_DURATION_ENABLE = false
  258.   #Time to return the position of 4 directions.
  259.   DIAGONAL_DURATION = 1
  260.   #Definition of how the experience is divided between allies.
  261.   # 0 - EXP only for who killed the enemy.
  262.   # 1 - EXP is distributed to the group, the full value of exp.
  263.   # 2 - EXP is divided by the number of the group and distributed to all.
  264.   EXP_TYPE = 2
  265.   # Setting the time to remove the treasure map.
  266.   TREASURE_ERASE_TIME = 30
  267.   # Enable animation fade in treasure.
  268.   FADE_TREASURE_SPRITE = true
  269.   # Enable animation levitation in treasure.
  270.   FLOAT_TREASURE_SPRITE = false
  271.   # Secure the balloon position independent from the actual height of the sprite.
  272.   FIX_BALLOON_POSITION = true
  273.   # When the balloon is fixed.
  274.   BALLOON_HEIGHT = 45
  275. end  
  276.  
  277. #===============================================================================
  278. # ■ ENEMY SETTING
  279. #===============================================================================
  280.  
  281. module XAS_BA_ENEMY
  282.   # Definition of what skills the enemy will be invulnerablel.
  283.   #
  284.   # INVUNERABLE_ACTIONS = { A=>[B,B,B,B],  A=>[B,B,B,B], ...}
  285.   # A - ID the enemy.
  286.   # B - ID the ability.
  287.   INVUNERABLE_ACTIONS = {
  288.   6=>[39,40,41,42,43],
  289.   7=>[24,25,26,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45],
  290.   8=>[1,2,3,4,5,6,7,11,12,13,14,15,16,17,18,19,20,21,24,25,26],
  291.   44=>[1,2,3,4,5,6,7,11,12,13,14,15,16,17,18,19,20,21,24,25,26],
  292.   45=>[1,2,3,4,5,6,7,11,12,13,14,15,16,17,18,19,20,21,24,25,26],
  293.   9=>[39,40,41,42,43],
  294.   10=>[39,40,41,42,43],
  295.   84=>[1,2,3,4,5,6,7,11,12,13,14,15,16,17,18,19,20,21,24,25,26],
  296.   11=>[39,40,41,42,43]
  297.   }
  298.   # Definition of the directions that the enemy will be invulnerable.
  299.   # GUARD_DIRECTIONS = { A=>[B],  A=>[B,B,B,B], ...}
  300.   # A - ID the enemy
  301.   # B - Directions of Invulnerability.
  302.   #     -> 2 = below.   -> 4 = left.
  303.   #     -> 6 = right.  -> 8 = above.
  304.   GUARD_DIRECTIONS = {
  305.   }  
  306.   # Definition of skills Counter Attack
  307.   #
  308.   # COUNTER_ATTACK = { A=>[B,B,B,B],  A=>[B,B,B,B], ...}
  309.   COUNTER_ATTACK = {
  310.   }
  311.  
  312. end  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  322. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  323. #■ INITIALIZE
  324. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  325. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  326.  
  327.  
  328. #===============================================================================
  329. # ■ Game_Temp
  330. #===============================================================================
  331. class Game_Temp
  332.   attr_accessor :change_leader_wait_time
  333.   attr_accessor :reset_battler_time
  334.   attr_accessor :tool_event
  335.   attr_accessor :animation_garbage
  336.  
  337.   #--------------------------------------------------------------------------
  338.   # ● Initialize
  339.   #--------------------------------------------------------------------------  
  340.   alias xas_initialize initialize
  341.   def initialize
  342.       @change_leader_wait_time = 0
  343.       @reset_battler_time = 0
  344.       @tool_event = nil
  345.       @animation_garbage = []
  346.       xas_initialize
  347.   end
  348.  
  349. end
  350.  
  351. #===============================================================================
  352. # ■ Game_System
  353. #===============================================================================
  354. class Game_System
  355.   attr_accessor :tools_on_map
  356.   attr_accessor :old_interpreter_running
  357.   attr_accessor :hud_visible
  358.   attr_accessor :enable_hud
  359.   attr_accessor :command_enable
  360.   attr_accessor :pre_leader_id
  361.   attr_accessor :xas_battle
  362.   #--------------------------------------------------------------------------
  363.   # ● Initialize
  364.   #--------------------------------------------------------------------------  
  365.   alias x_initialize initialize
  366.   def initialize
  367.       @tools_on_map = []
  368.       @old_interpreter_running = false
  369.       @hud_visible = XAS_BA::HUD_VISIBLE_AT_STARTUP
  370.       @enable_hud = false
  371.       @command_enable  = true
  372.       @pre_leader_id = 0
  373.       @xas_battle = XAS_SYSTEM::BATTLE_SYSTEM
  374.       x_initialize
  375.   end  
  376. end  
  377.  
  378. #===============================================================================
  379. # ■ Game_Battler
  380. #===============================================================================
  381. class Game_Battler
  382.   attr_accessor :damage_pop
  383.   attr_accessor :damage
  384.   attr_accessor :damage_type
  385.   attr_accessor :critical
  386.   attr_accessor :invunerable_duration
  387.   attr_accessor :shield
  388.   attr_accessor :invunerable_actions
  389.   attr_accessor :guard_directions
  390.   attr_accessor :guard
  391.   attr_accessor :invunerable
  392.   attr_accessor :x_combo
  393.   attr_accessor :cast_action
  394.   attr_accessor :defeated
  395.   attr_accessor :death_zoom_effect
  396.   attr_accessor :counter_action
  397.   attr_accessor :knockback_duration
  398.   attr_accessor :hp_damage
  399.   attr_accessor :mp_damage
  400.  
  401.  #--------------------------------------------------------------------------
  402.  # ● Initialize
  403.  #--------------------------------------------------------------------------  
  404.   alias x_initialize initialize
  405.   def initialize
  406.       @damage = 0
  407.       @damage_pop = false
  408.       @damage_type = 0
  409.       @critical = false
  410.       @invunerable_duration = 0
  411.       @shield = false
  412.       @invunerable_actions = []
  413.       @guard_directions = []
  414.       @guard = true
  415.       @invunerable = false
  416.       @x_combo = [0,-1,0]
  417.       @defeated = false
  418.       @death_zoom_effect = 0
  419.       @cast_action = [0,0,0,0,0]
  420.       @counter_action = [0,0,true]
  421.       @knockback_duration = XAS_BA::DEFAULT_KNOCK_BACK_DURATION
  422.       x_initialize
  423.   end
  424.  
  425.  #--------------------------------------------------------------------------
  426.  # ● Add Invunerable Actions
  427.  #--------------------------------------------------------------------------    
  428.  def add_inv(action_id = 0)
  429.      return if action_id == nil or action_id <= 0
  430.      return if @invunerable_actions.include?(action_id)
  431.      @invunerable_actions.push(action_id)    
  432.  end
  433.  
  434.  #--------------------------------------------------------------------------
  435.  # ● Remove Invunerable Actions
  436.  #--------------------------------------------------------------------------    
  437.  def remove_inv(action_id = 0)
  438.      return if action_id == nil or action_id <= 0
  439.      return unless @invunerable_actions.include?(action_id)
  440.      @invunerable_actions.delete(action_id)    
  441.  end
  442.    
  443.  #--------------------------------------------------------------------------
  444.  # ● Add Guard Directions
  445.  #--------------------------------------------------------------------------    
  446.  def add_guard_dir(direction = 0)
  447.      return if direction == nil or direction <= 0
  448.      return if @guard_directions.include?(direction)
  449.      @guard_directions.push(direction)    
  450.  end
  451.  
  452.  #--------------------------------------------------------------------------
  453.  # ● Remove Guard Directions
  454.  #--------------------------------------------------------------------------    
  455.  def remove_guard_dir(direction = 0)
  456.      return if direction == nil or direction <= 0
  457.      return unless @guard_directions.include?(direction)
  458.      @guard_directions.delete(direction)    
  459.  end  
  460.  
  461. end  
  462.  
  463. #===============================================================================
  464. # ■ Game Actor
  465. #===============================================================================
  466. class Game_Actor < Game_Battler
  467.  
  468.   attr_accessor :x_action1_id
  469.   attr_accessor :x_action2_id
  470.   attr_accessor :skill_id
  471.   attr_accessor :skill2_id
  472.   attr_accessor :x_item_id
  473.   attr_accessor :x_charge_action
  474.   attr_accessor :old_equipment_id
  475.   attr_accessor :item_id
  476.   attr_accessor :old_level
  477.   attr_reader :actor_id
  478.  
  479.  #--------------------------------------------------------------------------
  480.  # ● Setup
  481.  #--------------------------------------------------------------------------    
  482.  alias x_setup setup
  483.  def setup(actor_id)
  484.       @x_action1_id = 0
  485.       @x_action2_id = 0
  486.       @skill_id = 0
  487.       @skill2_id = 0
  488.       @x_item_id = 0
  489.       @item_id = 0
  490.       @x_charge_action = [0,0,0,0]
  491.       @old_level = @level
  492.       @old_equipment_id = [0,0,0,0,0]
  493.       x_setup(actor_id)
  494.  end
  495.  
  496.  #--------------------------------------------------------------------------
  497.  # ● Display Level Up
  498.  #--------------------------------------------------------------------------    
  499.   alias x_display_level_up display_level_up
  500.   def display_level_up(new_skills)
  501.       return unless $game_party.in_battle
  502.       x_display_level_up(new_skills)
  503.   end
  504.  
  505. end
  506.  
  507. #===============================================================================
  508. # ■ Character
  509. #===============================================================================
  510. class Game_Character < Game_CharacterBase
  511.  
  512.   attr_accessor :tool_id
  513.   attr_accessor :tool_effect  
  514.   attr_accessor :target
  515.   attr_accessor :target2
  516.   attr_accessor :old_x
  517.   attr_accessor :old_y
  518.   attr_accessor :pre_x
  519.   attr_accessor :pre_y
  520.   attr_accessor :temp_id
  521.   attr_accessor :angle
  522.   attr_accessor :force_action_times
  523.   attr_accessor :force_action
  524.   attr_accessor :move_frequency
  525.   attr_accessor :move_speed
  526.   attr_accessor :direction_fix
  527.   attr_accessor :walk_anime
  528.   attr_accessor :step_anime
  529.   attr_accessor :x
  530.   attr_accessor :y
  531.   attr_accessor :pattern
  532.   attr_accessor :pattern_count  
  533.   attr_accessor :jump_count
  534.   attr_accessor :jump_peak
  535.   attr_accessor :dash_active
  536.   attr_accessor :direction
  537.   attr_accessor :through
  538.   attr_accessor :bush_depth  
  539.   attr_accessor :blend_type
  540.   attr_accessor :priority_type  
  541.   attr_accessor :jump_count
  542.   attr_accessor :zoom_x
  543.   attr_accessor :zoom_y
  544.   attr_accessor :stop
  545.   attr_accessor :force_update
  546.   attr_accessor :treasure_time
  547.   attr_accessor :treasure_float
  548.   attr_accessor :can_update
  549.   attr_accessor :pre_move_speed
  550.   attr_accessor :knock_back_duration
  551.   attr_accessor :orig_pos_x
  552.   attr_accessor :orig_pos_y
  553.   attr_accessor :shoot_time
  554.   #--------------------------------------------------------------------------
  555.   # ● Initialize
  556.   #--------------------------------------------------------------------------    
  557.   alias x_initialize initialize
  558.   def initialize
  559.       x_initialize
  560.       @tool_id = 0
  561.       @tool_effect = ""
  562.       @target = false
  563.       @target2 = nil
  564.       @old_x = @x
  565.       @old_y = @y
  566.       @pre_x = @x
  567.       @pre_y = @y  
  568.       @orig_pos_x = @x
  569.       @orig_pos_y = @y
  570.       @angle = 0
  571.       @force_action_times = 0
  572.       @force_action = ""
  573.       @dash_active = false
  574.       @zoom_x = 1.00
  575.       @zoom_y = 1.00
  576.       @stop = false
  577.       @force_update = false
  578.       @treasure_time = 0
  579.       @treasure_float = [0,0,0,0]
  580.       @can_update = true
  581.       @temp_id = 0
  582.       @pre_move_speed = @move_speed
  583.       @shoot_time = [0,0]
  584.   end
  585.  
  586.   #--------------------------------------------------------------------------
  587.   # ● Invunerable
  588.   #--------------------------------------------------------------------------      
  589.   def invunerable(enable = false)
  590.       return if @battler == nil or @battler.dead?
  591.       @battler.invunerable = enable
  592.   end  
  593.  
  594.   #--------------------------------------------------------------------------
  595.   # ● Fast Breath
  596.   #--------------------------------------------------------------------------        
  597.   def fast_breath(enable = true)
  598.      return if @battler == nil or @battler.dead?
  599.      @battler.fast_breath_effect = enable
  600.   end
  601. end
  602.  
  603. #===============================================================================
  604. # ■ Game_Event
  605. #===============================================================================
  606. class Game_Event < Game_Character
  607.   attr_accessor :target
  608.   attr_reader   :name
  609.   attr_accessor :collision_attack
  610.  
  611.  #--------------------------------------------------------------------------
  612.  # ● Object
  613.  #--------------------------------------------------------------------------      
  614.  alias x_event_initialize initialize
  615.  def initialize(map_id, event)
  616.      x_event_initialize(map_id, event)
  617.      @collision_attack = false
  618.      if @event.name =~ /<O(\d+)>/i
  619.         @opacity = $1.to_i  
  620.      end  
  621.      if @event.name =~ /<B(\d+)>/i  
  622.         @blend_type = $1.to_i
  623.      end  
  624.  end  
  625.    
  626.  #--------------------------------------------------------------------------
  627.  # ● Erase
  628.  #--------------------------------------------------------------------------        
  629.  alias x_event_erase erase
  630.  def erase
  631.      if self.tool_id > 0
  632.         $game_system.tools_on_map.delete(self.tool_id)
  633.      end  
  634.      x_event_erase
  635.  end    
  636.  
  637.  #--------------------------------------------------------------------------
  638.  # ● Event Name
  639.  #--------------------------------------------------------------------------
  640.   def name
  641.       return @event.name  
  642.   end  
  643.  
  644. end
  645.  
  646. #===============================================================================
  647. # ■ Game Followers
  648. #===============================================================================
  649. class Game_Followers
  650.  
  651.  #--------------------------------------------------------------------------
  652.  # ● Initialize
  653.  #--------------------------------------------------------------------------  
  654.   alias x_party_initialize initialize
  655.   def initialize(leader)
  656.       x_party_initialize(leader)
  657.       if $xas_party_system == nil
  658.          @visible = false
  659.       end  
  660.   end  
  661. end  
  662.  
  663. #===============================================================================
  664. # ■ Game Map
  665. #===============================================================================
  666. class Game_Map  
  667.  
  668.  #--------------------------------------------------------------------------
  669.  # ● Setup
  670.  #--------------------------------------------------------------------------  
  671.   alias x_initial_setup setup
  672.   def setup(map_id)
  673.       x_initial_setup(map_id)
  674.       xas_initial_setup(map_id)
  675.   end
  676.  
  677.  #--------------------------------------------------------------------------
  678.  # ● XAS Initial Setup
  679.  #--------------------------------------------------------------------------  
  680.   def xas_initial_setup(map_id)
  681.       for actor in $game_party.members
  682.           setup_initial_members(actor)
  683.       end  
  684.   end  
  685.    
  686.  #--------------------------------------------------------------------------
  687.  # ● Setup Initial Membes
  688.  #--------------------------------------------------------------------------    
  689.   def setup_initial_members(actor)
  690.      
  691.   end  
  692. end  
  693.  
  694.  
  695. #==============================================================================
  696. # ■ Scene_Map
  697. #==============================================================================
  698. class Scene_Map < Scene_Base
  699.  
  700.   #--------------------------------------------------------------------------
  701.   # ● Call Menu
  702.   #--------------------------------------------------------------------------    
  703.   alias x_call_menu call_menu
  704.   def call_menu
  705.       return if $game_player.action != nil
  706.       $game_player.reset_charge_temp
  707.       x_call_menu
  708.   end
  709.    
  710. end    
  711. #===============================================================================
  712. # ■ Scene_Refresh
  713. #===============================================================================
  714. class Scene_Refresh
  715.  
  716.  #--------------------------------------------------------------------------
  717.  # ● Main
  718.  #--------------------------------------------------------------------------
  719.   def main
  720.       SceneManager.call(Scene_Map)
  721.   end
  722. end
  723.  
  724. #==============================================================================
  725. # ■ Game_Player
  726. #==============================================================================
  727. class Game_Player < Game_Character
  728.  
  729.  #--------------------------------------------------------------------------
  730.  # ● Leader Changed
  731.  #--------------------------------------------------------------------------  
  732.   def leader_changed?(actor)
  733.       if $game_party.members[0] == nil
  734.          return true if actor != nil
  735.       elsif $game_party.members[0] != nil
  736.          return true if actor == nil    
  737.          return true if actor.actor_id != $game_party.members[0].actor_id        
  738.       end  
  739.       return false
  740.   end
  741.  
  742. end  
  743. $xas = true
  744.  
  745.  
  746. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  747. #■ MOVEMENT - DIAGONAL MOVEMENT
  748. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  749.  
  750.  
  751. #===============================================================================
  752. # ■ Game Character
  753. #===============================================================================
  754. class Game_CharacterBase
  755.  
  756.   #--------------------------------------------------------------------------
  757.   # ● Set Direction
  758.   #--------------------------------------------------------------------------          
  759.    alias diagonal_set_direction set_direction
  760.    def set_direction(d)
  761.        diagonal_set_direction(d)
  762.        @diagonal_direction = 0
  763.        reset_diagonal
  764.    end
  765.    
  766. end  
  767.  
  768. #===============================================================================
  769. # ■  Game Character
  770. #===============================================================================
  771. class Game_Character < Game_CharacterBase
  772.  
  773.   attr_accessor :diagonal
  774.   attr_accessor :diagonal_direction
  775.   attr_accessor :sprite_angle_enable
  776.   attr_accessor :diagonal_time
  777.  
  778.   #--------------------------------------------------------------------------
  779.   # ● Initialize
  780.   #--------------------------------------------------------------------------        
  781.   alias diagonal_initialize initialize
  782.   def initialize
  783.       diagonal_initialize
  784.       if XAS_SYSTEM::EVENT_DIAGONAL_MOVEMENT
  785.          @diagonal = true
  786.       else  
  787.          @diagonal = false
  788.       end  
  789.       @diagonal_direction = 0
  790.       @sprite_angle_enable = false
  791.       @diagonal_time = 0
  792.   end  
  793.    
  794.   #--------------------------------------------------------------------------
  795.   # ● Reset Diagonal
  796.   #--------------------------------------------------------------------------            
  797.   def reset_diagonal
  798.       return if @direction_fix
  799.       return if @diagonal == false
  800.       @diagonal_direction = 0    
  801.       @diagonal_time = 0
  802.       @angle = 0 if @sprite_angle_enable
  803.   end  
  804.  
  805.   #--------------------------------------------------------------------------
  806.   # ● Enable Diagonal
  807.   #--------------------------------------------------------------------------            
  808.   def enable_diagonal(dir = 0)
  809.      return if @direction_fix
  810.      return if @diagonal == false
  811.      return if dir == 0
  812.      @diagonal_direction = dir
  813.      @diagonal_time = XAS_BA::DIAGONAL_DURATION
  814.      @angle = 315 if @sprite_angle_enable
  815.   end  
  816.  
  817.   #--------------------------------------------------------------------------
  818.   # ● Turn Upper Right
  819.   #--------------------------------------------------------------------------  
  820.   def turn_upper_right
  821.       enable_diagonal(9)
  822.       @direction = 8 unless @direction_fix
  823.   end  
  824.  
  825.   #--------------------------------------------------------------------------
  826.   # ● Turn Upper Left
  827.   #--------------------------------------------------------------------------  
  828.   def turn_upper_left
  829.       enable_diagonal(7)
  830.       @direction = 4 unless @direction_fix
  831.   end  
  832.  
  833.   #--------------------------------------------------------------------------
  834.   # ● Turn Lower Right
  835.   #--------------------------------------------------------------------------  
  836.   def turn_lower_right
  837.       enable_diagonal(3)
  838.       @direction = 6 unless @direction_fix
  839.   end      
  840.  
  841.   #--------------------------------------------------------------------------
  842.   # ● Turn Lower Left
  843.   #--------------------------------------------------------------------------  
  844.   def turn_lower_left
  845.       enable_diagonal(1)
  846.       @direction = 2 unless @direction_fix
  847.   end  
  848.    
  849.   #--------------------------------------------------------------------------
  850.   # ● Move forward
  851.   #--------------------------------------------------------------------------                
  852.   alias diagonal_move_forward move_forward
  853.   def move_forward
  854.       return if move_forward_diagonal?
  855.       diagonal_move_forward
  856.   end
  857.  
  858.   #--------------------------------------------------------------------------
  859.   # ● Move forward Diagonal?
  860.   #--------------------------------------------------------------------------                  
  861.   def move_forward_diagonal?
  862.       return false if @diagonal == false
  863.       if @diagonal_direction != 0
  864.          case @diagonal_direction
  865.               when 1 #Lower Left
  866.                  move_diagonal(4, 2)
  867.                  @direction = 2
  868.               when 3 #Lower Right
  869.                  move_diagonal(6, 2)
  870.                  @direction = 6
  871.               when 7 #Upper Left
  872.                  move_diagonal(4, 8)
  873.                  @direction = 4
  874.               when 9 #Upper Right
  875.                  move_diagonal(6, 8)
  876.                  @direction = 8
  877.           end
  878.           enable_diagonal(@diagonal_direction)      
  879.          return true
  880.       end  
  881.       return false
  882.   end
  883.  
  884.   #--------------------------------------------------------------------------
  885.   # ● Move Backward
  886.   #--------------------------------------------------------------------------                
  887.   alias diagonal_move_backward move_backward
  888.   def move_backward
  889.       return if move_backward_diagonal?
  890.       diagonal_move_backward
  891.   end
  892.  
  893.   #--------------------------------------------------------------------------
  894.   # ● Move Backward Diagonal?
  895.   #--------------------------------------------------------------------------                  
  896.   def move_backward_diagonal?
  897.       return false if @diagonal == false
  898.       if @diagonal_direction != 0
  899.          last_direction_fix = @direction_fix
  900.          @direction_fix = true      
  901.          case @diagonal_direction
  902.               when 1
  903.                  move_diagonal(6, 8)
  904.                  @direction = 6
  905.               when 3
  906.                  move_diagonal(4, 8)
  907.                  @direction = 4
  908.               when 7
  909.                  move_diagonal(6, 2)
  910.                  @direction = 6
  911.               when 9        
  912.                  move_diagonal(4, 2)
  913.                  @direction = 2
  914.          end
  915.          enable_diagonal(@diagonal_direction)      
  916.          @direction_fix = last_direction_fix
  917.          return true
  918.       end  
  919.       return false
  920.   end  
  921.  
  922.   #--------------------------------------------------------------------------
  923.   # ● Turn Toward Player
  924.   #--------------------------------------------------------------------------
  925.   alias turn_toward_player_diagonal turn_toward_player
  926.   def turn_toward_player
  927.       if @diagonal
  928.          diagonal_turn_toward_player
  929.          return
  930.       end
  931.       turn_toward_player_diagonal
  932.   end  
  933.  
  934.   #--------------------------------------------------------------------------
  935.   # ● Diagonal Turn Toward Player
  936.   #--------------------------------------------------------------------------
  937.   def diagonal_turn_toward_player
  938.       sx = distance_x_from($game_player.x)
  939.       sy = distance_y_from($game_player.y)
  940.       sd = sx.abs - sy.abs
  941.       sdx = sd.abs - sx.abs
  942.       sdy = sd.abs - sy.abs
  943.       return if sx == 0 and sy == 0
  944.       #Turn Upper Right
  945.       if sx < 0 and sy > 0
  946.          if sx.abs > sy.abs and sdx.abs < sd.abs
  947.             set_direction(6)
  948.          elsif sx.abs < sy.abs and sdy.abs < sd.abs
  949.             set_direction(8)
  950.          else
  951.             turn_upper_right
  952.          end
  953.          enable_diagonal(9)
  954.       #Turn Upper Left
  955.       elsif sx > 0 and sy > 0
  956.          if sx.abs > sy.abs and sdx.abs < sd.abs
  957.             set_direction(4)
  958.          elsif sx.abs < sy.abs and sdy.abs < sd.abs
  959.             set_direction(8)            
  960.          else
  961.             set_direction(4)
  962.             turn_upper_left
  963.          end
  964.          enable_diagonal(7)  
  965.       #Turn Lower Left  
  966.       elsif sx > 0 and sy < 0
  967.          if sx.abs > sy.abs and sdx.abs < sd.abs
  968.             set_direction(4)
  969.          elsif sx.abs < sy.abs and sdy.abs < sd.abs
  970.             set_direction(2)        
  971.          else                    
  972.             turn_lower_left
  973.          end
  974.          enable_diagonal(1)  
  975.        #Turn Lower Right    
  976.        elsif sx < 0 and sy < 0        
  977.          if sx.abs > sy.abs and sdx.abs < sd.abs
  978.             set_direction(6)
  979.          elsif sx.abs < sy.abs and sdy.abs < sd.abs
  980.             set_direction(2)          
  981.          else        
  982.             turn_lower_right
  983.          end
  984.          enable_diagonal(3)
  985.       elsif sx < 0
  986.          set_direction(6)
  987.       elsif sx > 0
  988.          set_direction(4)
  989.       elsif sy > 0
  990.          set_direction(8)
  991.       elsif sy < 0
  992.          set_direction(2)  
  993.       end    
  994.  
  995.   end  
  996.  
  997.   #--------------------------------------------------------------------------
  998.   # ● Move toward Player
  999.   #--------------------------------------------------------------------------
  1000.   alias move_toward_player_diagonal move_toward_player
  1001.   def move_toward_player
  1002.       if @diagonal
  1003.          diagonal_move_toward_player
  1004.          return  
  1005.       end
  1006.       move_toward_player_diagonal
  1007.   end  
  1008.    
  1009.   #--------------------------------------------------------------------------
  1010.   # ● Diagonal Move Toward Player
  1011.   #--------------------------------------------------------------------------  
  1012.   def diagonal_move_toward_player
  1013.       sx = distance_x_from($game_player.x)
  1014.       sy = distance_y_from($game_player.y)
  1015.       if sx == 0 and sy == 0
  1016.          return
  1017.       end
  1018.       abs_sx = sx.abs
  1019.       abs_sy = sy.abs
  1020.       if abs_sx == abs_sy
  1021.         rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
  1022.       end
  1023.       if abs_sx
  1024.          if sx < 0 and sy > 0
  1025.             move_diagonal(6, 8)
  1026.             move_random unless moving?
  1027.             enable_diagonal(9)
  1028.          elsif sx > 0 and sy > 0
  1029.             move_diagonal(4, 8)
  1030.             move_random unless moving?
  1031.             enable_diagonal(7)
  1032.          elsif sx > 0 and sy < 0
  1033.             move_diagonal(4, 2)
  1034.             move_random unless moving?
  1035.             enable_diagonal(1)
  1036.          elsif sx < 0 and sy < 0
  1037.             move_diagonal(6, 2)
  1038.             move_random unless moving?
  1039.             enable_diagonal(3)
  1040.          elsif sx < 0
  1041.             move_straight(6)
  1042.          elsif sx > 0
  1043.             move_straight(4)
  1044.          elsif sy > 0
  1045.             move_straight(8)
  1046.          elsif sy < 0
  1047.             move_straight(2)
  1048.          end
  1049.          if abs_sx != 1 and abs_sy != 1
  1050.             move_random unless moving?
  1051.          end  
  1052.       end
  1053.  end
  1054.  
  1055.  #--------------------------------------------------------------------------
  1056.  # ● turn_right_45
  1057.  #--------------------------------------------------------------------------      
  1058.  def turn_right_45
  1059.      if @diagonal and @diagonal_direction != 0    
  1060.         case @diagonal_direction
  1061.           when 1;  set_direction(4)
  1062.           when 3;  set_direction(2)
  1063.           when 7;  set_direction(8)
  1064.           when 9;  set_direction(6)  
  1065.         end
  1066.      else  
  1067.         case @direction
  1068.           when 2;  turn_lower_left
  1069.           when 4;  turn_upper_left
  1070.           when 6;  turn_lower_right
  1071.           when 8;  turn_upper_right
  1072.         end
  1073.      end  
  1074.  end
  1075.  
  1076.  #--------------------------------------------------------------------------
  1077.  # ● turn_left_45
  1078.  #--------------------------------------------------------------------------  
  1079.  def turn_left_45
  1080.      if @diagonal and @diagonal_direction != 0    
  1081.         case @diagonal_direction
  1082.           when 1;  set_direction(2)
  1083.           when 3;  set_direction(6)
  1084.           when 7;  set_direction(4)
  1085.           when 9;  set_direction(8)
  1086.         end
  1087.      else  
  1088.         case @direction
  1089.           when 2;  turn_lower_right
  1090.           when 4;  turn_lower_left
  1091.           when 6;  turn_upper_right
  1092.           when 8;  turn_upper_left
  1093.         end
  1094.      end  
  1095.  end
  1096.  
  1097.  #--------------------------------------------------------------------------
  1098.  # ● turn_right_90
  1099.  #--------------------------------------------------------------------------  
  1100.  alias diagonal_turn_right_90 turn_right_90
  1101.   def turn_right_90
  1102.       if @diagonal and @diagonal_direction != 0
  1103.          turn_diagonal_right_90
  1104.          return
  1105.       end  
  1106.       diagonal_turn_right_90
  1107.   end
  1108.  
  1109.  #--------------------------------------------------------------------------
  1110.  # ● turn_diagonal_right_90
  1111.  #--------------------------------------------------------------------------    
  1112.   def turn_diagonal_right_90
  1113.       case @diagonal_direction
  1114.          when 1;  turn_upper_left
  1115.          when 3;  turn_lower_left
  1116.          when 7;  turn_upper_right
  1117.          when 9;  turn_lower_right
  1118.       end
  1119.   end
  1120.    
  1121.  #--------------------------------------------------------------------------
  1122.  # ● turn_left_90
  1123.  #--------------------------------------------------------------------------    
  1124.   alias diagonal_turn_left_90 turn_left_90
  1125.   def turn_left_90
  1126.       if @diagonal and @diagonal_direction != 0
  1127.          turn_diagonal_left_90
  1128.          return
  1129.       end
  1130.       diagonal_turn_left_90
  1131.   end  
  1132.    
  1133.  #--------------------------------------------------------------------------
  1134.  # ● turn_diagonal_left_90
  1135.  #--------------------------------------------------------------------------    
  1136.   def turn_diagonal_left_90
  1137.       case @diagonal_direction
  1138.          when 1;  turn_lower_right
  1139.          when 3;  turn_upper_right
  1140.          when 7;  turn_lower_left
  1141.          when 9;  turn_upper_left
  1142.       end
  1143.   end    
  1144.    
  1145.   #--------------------------------------------------------------------------
  1146.   # ● diagonal_turn_180
  1147.   #--------------------------------------------------------------------------
  1148.   alias diagonal_turn_180 turn_180
  1149.   def turn_180  
  1150.       if @diagonal and @diagonal_direction != 0
  1151.          turn_diagonal_180
  1152.          return
  1153.       end
  1154.       diagonal_turn_180
  1155.   end
  1156.  
  1157.  #--------------------------------------------------------------------------
  1158.  # ● turn_diagonal_180
  1159.  #--------------------------------------------------------------------------    
  1160.   def turn_diagonal_180
  1161.       case @diagonal_direction
  1162.          when 1;  turn_upper_right
  1163.          when 3;  turn_upper_left
  1164.          when 7;  turn_lower_right
  1165.          when 9;  turn_lower_left
  1166.       end
  1167.   end  
  1168.    
  1169.  #--------------------------------------------------------------------------
  1170.  # ● turn_random
  1171.  #--------------------------------------------------------------------------    
  1172.   alias diagonal_turn_random turn_random
  1173.   def turn_random
  1174.       if @diagonal
  1175.          turn_diagonal_random
  1176.          return
  1177.       end  
  1178.       diagonal_turn_random
  1179.   end  
  1180.  
  1181.  #--------------------------------------------------------------------------
  1182.  # ● turn_diagonal_random
  1183.  #--------------------------------------------------------------------------    
  1184.   def turn_diagonal_random
  1185.       case rand(8)
  1186.           when 0;  set_direction(8)
  1187.           when 1;  set_direction(6)
  1188.           when 2;  set_direction(4)
  1189.           when 3;  set_direction(2)
  1190.           when 4;  turn_lower_left  
  1191.           when 5;  turn_lower_right
  1192.           when 6;  turn_upper_left  
  1193.           when 7;  turn_upper_right
  1194.       end
  1195.   end
  1196.  
  1197. end    
  1198.  
  1199. #===============================================================================
  1200. # ■ Game_Player
  1201. #===============================================================================
  1202. class Game_Player < Game_Character
  1203.  
  1204.   #--------------------------------------------------------------------------
  1205.   # ● Move By Input
  1206.   #--------------------------------------------------------------------------    
  1207.   alias diagonal_move_by_input move_by_input
  1208.   def move_by_input
  1209.       if XAS_SYSTEM::PLAYER_DIAGONAL_MOVEMENT
  1210.          player_diagonal_move_by_input
  1211.         # update_sprite_diagonal
  1212.          update_return_direction
  1213.          return
  1214.       end
  1215.       diagonal_move_by_input
  1216.   end  
  1217.    
  1218.   #--------------------------------------------------------------------------
  1219.   # ● Update Sprite Diagonal
  1220.   #--------------------------------------------------------------------------        
  1221.   def update_sprite_diagonal
  1222.       return if @diagonal_direction == 0
  1223.       return if self.action != nil
  1224.       return if @dash_active
  1225.       make_pose("_Diagonal", 2)
  1226.   end  
  1227.  
  1228.   #--------------------------------------------------------------------------
  1229.   # ● Update Return Direction
  1230.   #--------------------------------------------------------------------------          
  1231.   def update_return_direction
  1232.       return if XAS_BA::DIAGONAL_DURATION_ENABLE == false
  1233.       return if @diagonal_time == 0
  1234.       return if moving? or @stop
  1235.       @diagonal_time -= 1
  1236.       @diagonal_direction = 0 if @diagonal_time == 0
  1237.   end
  1238.    
  1239.   #--------------------------------------------------------------------------
  1240.   # ● Move by Input.dir8
  1241.   #--------------------------------------------------------------------------  
  1242.   def move_by_input_dir8
  1243.       case Input.dir8
  1244.            when 1
  1245.                move_diagonal(4, 2)
  1246.                unless moving?
  1247.                    move_straight(4)
  1248.                    move_straight(2)                
  1249.                end  
  1250.                @diagonal_direction = 1  
  1251.            when 2; move_straight(2)
  1252.            when 3
  1253.                 move_diagonal(6, 2)
  1254.                 unless moving?
  1255.                    move_straight(6)
  1256.                    move_straight(2)
  1257.                 end
  1258.                 @diagonal_direction = 3
  1259.            when 4;  move_straight(4)
  1260.            when 6;  move_straight(6)
  1261.            when 7
  1262.                  move_diagonal(4, 8)
  1263.                  unless moving?
  1264.                     move_straight(4)
  1265.                     move_straight(8)
  1266.                 end
  1267.                 @diagonal_direction = 7
  1268.            when 8;  move_straight(8)
  1269.            when 9  
  1270.                  move_diagonal(6, 8)
  1271.                  unless moving?
  1272.                     move_straight(6)
  1273.                     move_straight(8)
  1274.                 end
  1275.                 @diagonal_direction = 9  
  1276.       end
  1277.   end
  1278.    
  1279.   #--------------------------------------------------------------------------
  1280.   # ● Player Diagonal Move By Input
  1281.   #--------------------------------------------------------------------------      
  1282.   def player_diagonal_move_by_input    
  1283.       return unless movable?
  1284.       return if $game_map.interpreter.running?
  1285.      
  1286.       diagonal = false
  1287.      
  1288.       if true # Diagonal Moving
  1289.       # Move Diagonal Bottom Left
  1290.       if Input.press?(PadConfig.move_left) && Input.press?(PadConfig.move_down)
  1291.         if PadConfig.move_left && PadConfig.move_down
  1292.         if PadConfig.move_left != :_left && PadConfig.move_down != :_down
  1293.           move_diagonal(4, 2)
  1294.           unless moving?
  1295.              move_straight(4)
  1296.              move_straight(2)                
  1297.           end  
  1298.           @diagonal_direction = 1
  1299.           diagonal = true
  1300.         end
  1301.         end
  1302.       end
  1303.      
  1304.       # Move Diagonal Bottom Right
  1305.       if Input.press?(PadConfig.move_right) && Input.press?(PadConfig.move_down)
  1306.         if PadConfig.move_right && PadConfig.move_down
  1307.         if PadConfig.move_right != :_right && PadConfig.move_down != :_down
  1308.           move_diagonal(6, 2)
  1309.           unless moving?
  1310.              move_straight(6)
  1311.              move_straight(2)                
  1312.           end  
  1313.           @diagonal_direction = 3
  1314.           diagonal = true
  1315.         end
  1316.         end
  1317.       end
  1318.      
  1319.       # Move Diagonal Upper Left
  1320.       if Input.press?(PadConfig.move_left) && Input.press?(PadConfig.move_up)
  1321.         if PadConfig.move_left && PadConfig.move_up
  1322.         if PadConfig.move_left != :_left && PadConfig.move_up != :_up
  1323.           move_diagonal(4, 8)
  1324.           unless moving?
  1325.              move_straight(4)
  1326.              move_straight(8)                
  1327.           end  
  1328.           @diagonal_direction = 7
  1329.           diagonal = true
  1330.         end
  1331.         end
  1332.       end
  1333.      
  1334.       # Move Diagonal Upper Right
  1335.       if Input.press?(PadConfig.move_right) && Input.press?(PadConfig.move_up)
  1336.         if PadConfig.move_right && PadConfig.move_up
  1337.         if PadConfig.move_right != :_right && PadConfig.move_up != :_up
  1338.           move_diagonal(6, 8)
  1339.           unless moving?
  1340.              move_straight(6)
  1341.              move_straight(8)                
  1342.           end  
  1343.           @diagonal_direction = 9
  1344.           diagonal = true
  1345.         end
  1346.         end
  1347.       end
  1348.     end # Diagonal Moving
  1349.    
  1350.       unless diagonal # 4 Direction Moving
  1351.       move = false
  1352.      
  1353.       # Move Left
  1354.       if PadConfig.move_left && PadConfig.move_left != :_left
  1355.         if Input.repeat?(PadConfig.move_left) || Input.press?(PadConfig.move_left)
  1356.           move_straight(4)
  1357.           move = true
  1358.         end
  1359.       else
  1360.         unless move
  1361.           move_by_input_dir8
  1362.           move = true
  1363.         end
  1364.       end
  1365.      
  1366.       # Move Right
  1367.       if PadConfig.move_right && PadConfig.move_right != :_right
  1368.         if Input.repeat?(PadConfig.move_right) || Input.press?(PadConfig.move_right)
  1369.           move_straight(6)
  1370.           move = true
  1371.         end
  1372.       else
  1373.         unless move
  1374.           move_by_input_dir8
  1375.           move = true
  1376.         end
  1377.       end
  1378.      
  1379.       # Move Up
  1380.       if PadConfig.move_up && PadConfig.move_up != :_up
  1381.         if Input.repeat?(PadConfig.move_up) || Input.press?(PadConfig.move_up)
  1382.           move_straight(8)
  1383.           move = true
  1384.         end
  1385.       else
  1386.         unless move
  1387.           move_by_input_dir8
  1388.           move = true
  1389.         end
  1390.       end
  1391.      
  1392.       # Move Down
  1393.       if PadConfig.move_down && PadConfig.move_down != :_down
  1394.         if Input.repeat?(PadConfig.move_down) || Input.press?(PadConfig.move_down)
  1395.           move_straight(2)
  1396.           move = true
  1397.         end
  1398.       else
  1399.         unless move
  1400.           move_by_input_dir8
  1401.           move = true
  1402.         end
  1403.       end
  1404.      
  1405.       move = false
  1406.     end # 4 Direction Moving
  1407.     diagonal = false
  1408.   end  
  1409.  
  1410. end
  1411.  
  1412.  
  1413. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  1414. #■ MOVEMENT - FORCE ACTION
  1415. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  1416.  
  1417.  
  1418. #===============================================================================
  1419. # ■ Game Character
  1420. #===============================================================================
  1421. class Game_Character < Game_CharacterBase
  1422.  
  1423.   #--------------------------------------------------------------------------
  1424.   # ● moving 2?
  1425.   #--------------------------------------------------------------------------  
  1426.   def moving2?
  1427.       @real_x != @x || @real_y != @y
  1428.   end  
  1429.  
  1430.   #--------------------------------------------------------------------------
  1431.   # ● Can Force Action?
  1432.   #--------------------------------------------------------------------------          
  1433.   def can_force_action?
  1434.       return false if @force_action_times  == 0
  1435.       return false if self.moving2?
  1436.       return false if self.jumping?
  1437.       return false if self.knockbacking?
  1438.       return false if self.stop
  1439.       return true
  1440.   end
  1441.    
  1442.   #--------------------------------------------------------------------------
  1443.   # ● Update Force Action
  1444.   #--------------------------------------------------------------------------        
  1445.   def update_force_action
  1446.       @force_action_times -= 1
  1447.       execute_force_action
  1448.       execute_force_action_tool_effect if @tool_id > 0 and @tool_effect != ""
  1449.       reset_auto_action if @force_action_times == 0
  1450.   end
  1451.  
  1452.   #--------------------------------------------------------------------------
  1453.   # ● Execute Force Action
  1454.   #--------------------------------------------------------------------------          
  1455.   def execute_force_action  
  1456.       case @force_action
  1457.         when "Forward"
  1458.             move_forward
  1459.         when "Backward"
  1460.             move_backward
  1461.         when "Toward Player"  
  1462.             move_toward_player
  1463.         when "Move Left"    
  1464.             move_straight(4)
  1465.         when "Move Right"
  1466.             move_straight(6)
  1467.         when "Move Up"    
  1468.             move_straight(8)
  1469.         when "Move Down"
  1470.             move_straight(2)
  1471.         when "All Shoot"  
  1472.               if self.action != nil
  1473.                  turn_right_45
  1474.                  self.shoot(self.action.id) unless @force_action_times == 0
  1475.               end
  1476.         when "Four Shoot"  
  1477.               if self.action != nil
  1478.                  turn_right_90
  1479.                  self.shoot(self.action.id) unless @force_action_times == 0
  1480.               end              
  1481.         when "Three Shoot"  
  1482.               if self.action != nil
  1483.                  case @force_action_times
  1484.                      when 2
  1485.                        turn_right_45
  1486.                      when 1
  1487.                        turn_left_90
  1488.                      when 0
  1489.                        turn_right_45
  1490.                  end  
  1491.                  self.shoot(self.action.id) unless @force_action_times == 0
  1492.               end      
  1493.         when "Two Shoot"  
  1494.               if self.action != nil
  1495.                  turn_180
  1496.                  self.shoot(self.action.id) unless @force_action_times == 0
  1497.               end  
  1498.         end  
  1499.   end  
  1500.  
  1501.   #--------------------------------------------------------------------------
  1502.   # ● Execute Force Action Tool Effect
  1503.   #--------------------------------------------------------------------------
  1504.   def execute_force_action_tool_effect
  1505.       action_effect_during_move    
  1506.       action_effect_after_move if @force_action_times == 0
  1507.   end  
  1508.  
  1509.   #--------------------------------------------------------------------------
  1510.   # ● Auto Action Effect During Move
  1511.   #--------------------------------------------------------------------------            
  1512.   def reset_auto_action  
  1513.       @force_action = ""
  1514.       @force_action_times = 0
  1515.       @anime_count = 0
  1516.   end
  1517.  
  1518.   #--------------------------------------------------------------------------
  1519.   # ● Action Effect During Move
  1520.   #--------------------------------------------------------------------------          
  1521.   def action_effect_during_move  
  1522.       if @tool_effect == "Boomerang" and @force_action == "Toward Player"  
  1523.          if @x == $game_player.x and @y == $game_player.y  
  1524.             self.action.duration = 5
  1525.             @force_action_times = 0
  1526.             @force_action_type = ""            
  1527.           end
  1528.       end
  1529.   end  
  1530.  
  1531.   #--------------------------------------------------------------------------
  1532.   # ● Action Effect After Move
  1533.   #--------------------------------------------------------------------------            
  1534.   def action_effect_after_move
  1535.       if @tool_effect == "Boomerang"
  1536.          @force_action_times = 5
  1537.          @force_action = "Toward Player"  
  1538.          @move_frequency = 6
  1539.          @move_speed = 5.5          
  1540.       end    
  1541.   end      
  1542.      
  1543. end  
  1544.  
  1545.  
  1546. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  1547. #■ MOVEMENT - EXTRA MOVEMENT
  1548. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  1549.  
  1550.  
  1551. #===============================================================================
  1552. # ■ Game Character
  1553. #===============================================================================
  1554. class Game_Character < Game_CharacterBase
  1555.  
  1556.   #--------------------------------------------------------------------------
  1557.   # ● Check XY
  1558.   #--------------------------------------------------------------------------      
  1559.   def check_xy
  1560.       @pre_x = @x
  1561.       @pre_y = @y
  1562.   end    
  1563.  
  1564.   #--------------------------------------------------------------------------
  1565.   # ● Turn Reverse
  1566.   #--------------------------------------------------------------------------          
  1567.   def turn_reverse(dir)
  1568.       case dir    
  1569.         when 2; set_direction(8)
  1570.         when 4; set_direction(6)
  1571.         when 6; set_direction(4)
  1572.         when 8; set_direction(2)
  1573.       end    
  1574.   end
  1575.  
  1576.   #--------------------------------------------------------------------------
  1577.   # ● Org Here
  1578.   #--------------------------------------------------------------------------        
  1579.   def org_here
  1580.       @orig_pos_x = @x
  1581.       @orig_pos_y = @y
  1582.   end  
  1583.  
  1584.   #--------------------------------------------------------------------------
  1585.   # ● return_org
  1586.   #--------------------------------------------------------------------------          
  1587.   def return_org(type = 0)
  1588.       if type == 1
  1589.          moveto(@orig_pos_x,@orig_pos_x)
  1590.       else  
  1591.          jump(0,0)
  1592.       end
  1593.       @x = @orig_pos_x
  1594.       @y = @orig_pos_y
  1595.   end  
  1596.  
  1597.   #--------------------------------------------------------------------------
  1598.   # ● Dual Switch
  1599.   #--------------------------------------------------------------------------    
  1600.   def dual_switch(switch_on, switch_off,percentage = 100)
  1601.       enable_per = rand(100)
  1602.       if enable_per <= percentage
  1603.          $game_switches[switch_on] = true    
  1604.          $game_switches[switch_off] = false
  1605.          $game_map.need_refresh = true
  1606.       end  
  1607.   end  
  1608.  
  1609.   #--------------------------------------------------------------------------
  1610.   # ● Move Forward 2
  1611.   #--------------------------------------------------------------------------  
  1612.   def move_forward2
  1613.       return if moving2?
  1614.       move_forward
  1615.   end  
  1616.  
  1617.   #--------------------------------------------------------------------------
  1618.   # ● Bounce Direction
  1619.   #--------------------------------------------------------------------------  
  1620.   def bounce_direction
  1621.       @diagonal = true
  1622.       turn_random  
  1623.   end
  1624.  
  1625.   #--------------------------------------------------------------------------
  1626.   # ● Turn_back
  1627.   #--------------------------------------------------------------------------            
  1628.   def turn_back
  1629.       if @diagonal_direction != 0
  1630.          case @diagonal_direction
  1631.               when 1
  1632.                 turn_upper_right
  1633.               when 3
  1634.                 turn_upper_left
  1635.               when 7
  1636.                 turn_lower_right
  1637.               when 9        
  1638.                 turn_lower_left
  1639.          end
  1640.       else
  1641.           case @direction
  1642.                when 2;   set_direction(8)
  1643.                when 4;   @direction = 6#move_straight(6)#set_direction(6)
  1644.                when 6;   set_direction(4)
  1645.                when 8;   set_direction(2)
  1646.           end
  1647.       end    
  1648.   end  
  1649.  
  1650.   #--------------------------------------------------------------------------
  1651.   # ● Jump_high
  1652.   #--------------------------------------------------------------------------
  1653.   def jump_high(x_plus,y_plus,high = 10)    
  1654.       @x += x_plus
  1655.       @y += y_plus
  1656.       distance = Math.sqrt(x_plus * x_plus + y_plus * y_plus).round
  1657.       @jump_peak = high + distance - @move_speed
  1658.       @jump_count = @jump_peak * 2
  1659.       @stop_count = 0
  1660.       straighten
  1661.   end
  1662.  
  1663.   #--------------------------------------------------------------------------
  1664.   # ● Passable Temp
  1665.   #--------------------------------------------------------------------------    
  1666.  def passable_temp_id?(x, y)
  1667.      return false unless $game_map.valid?(x, y)    
  1668.      return true if @through or debug_through?    
  1669.      return false unless map_passable?(x, y,@direction)        
  1670.      return false if collide_with_characters_temp_id?(x, y)
  1671.      return true                                  
  1672.   end
  1673.  
  1674.   #--------------------------------------------------------------------------
  1675.   # ● Collide With Characters
  1676.   #--------------------------------------------------------------------------      
  1677.   def collide_with_characters_temp_id?(x, y)
  1678.       for event in $game_map.events_xy(x, y)        
  1679.           unless event.through or event.battler != nil    
  1680.              return true if self.is_a?(Game_Event)      
  1681.              return true if event.priority_type >= 1    
  1682.           end
  1683.       end
  1684.       return false
  1685.   end  
  1686.  
  1687.   #--------------------------------------------------------------------------
  1688.   # ● Force Move Route
  1689.   #--------------------------------------------------------------------------
  1690.   alias x_force_move_route force_move_route
  1691.   def force_move_route(move_route)
  1692.       if self.battler != nil and self.is_a?(Game_Event)
  1693.          return
  1694.       end  
  1695.       x_force_move_route(move_route)
  1696.   end  
  1697. end  
  1698.  
  1699.  
  1700. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  1701. #■ MOVEMENT - PLAYER COMMANDS
  1702. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  1703.  
  1704.  
  1705. #==============================================================================
  1706. # ■ Game_Player
  1707. #==============================================================================
  1708. class Game_Player < Game_Character
  1709.   include XAS_BUTTON
  1710.  
  1711.   #--------------------------------------------------------------------------
  1712.   # ● Update Action Command
  1713.   #--------------------------------------------------------------------------  
  1714.   def update_action_command
  1715.       update_check_battler_equipment if can_check_battler_equipment?
  1716.       update_dash_button
  1717.       update_auto_target_shoot
  1718.       update_combo_time
  1719.       update_action_1_button
  1720.       update_action_2_button
  1721.       update_skill_button
  1722.       update_item_button
  1723.       update_change_leader_button
  1724.       update_charge_button
  1725.   end  
  1726.  
  1727.   #--------------------------------------------------------------------------
  1728.   # ● Can Use Command?
  1729.   #--------------------------------------------------------------------------      
  1730.   def can_use_command?
  1731.       return false if $game_map.interpreter.running?
  1732.       return false if $game_message.visible
  1733.       return false if self.battler == nil
  1734.       return false if self.action != nil
  1735.       return false if self.knockbacking?      
  1736.       return false if @stop
  1737.       return true
  1738.   end    
  1739.  
  1740.   #--------------------------------------------------------------------------
  1741.   # ● Update Check Battler Equipment
  1742.   #--------------------------------------------------------------------------      
  1743.   def update_check_battler_equipment
  1744.  
  1745.   end  
  1746.  
  1747.   #--------------------------------------------------------------------------
  1748.   # ● Can Check Battler Equipment
  1749.   #--------------------------------------------------------------------------        
  1750.   def can_check_battler_equipment?
  1751.       if self.battler.old_equipment_id[0] != self.battler.equips[0] or
  1752.          self.battler.old_equipment_id[1] != self.battler.equips[1] or
  1753.          self.battler.old_equipment_id[2] != self.battler.equips[2] or
  1754.          self.battler.old_equipment_id[3] != self.battler.equips[3] or
  1755.          self.battler.old_equipment_id[4] != self.battler.equips[4]
  1756.          self.battler.old_equipment_id[0] = self.battler.equips[0]
  1757.          self.battler.old_equipment_id[1] = self.battler.equips[1]
  1758.          self.battler.old_equipment_id[2] = self.battler.equips[2]
  1759.          self.battler.old_equipment_id[3] = self.battler.equips[3]
  1760.          self.battler.old_equipment_id[4] = self.battler.equips[4]      
  1761.          return true
  1762.       end  
  1763.       return false
  1764.   end
  1765.  
  1766.   #--------------------------------------------------------------------------
  1767.   # ● Update Charge Button
  1768.   #--------------------------------------------------------------------------    
  1769.   def update_charge_button
  1770.       return unless can_charge_command?
  1771.       if Input.press?(ACTION_1_BUTTON) and ENABLE_ACTION_1_BUTTON
  1772.          update_charge_effect(0)
  1773.          reset_charge_temp if Input.press?(ACTION_2_BUTTON) and ENABLE_ACTION_2_BUTTON
  1774.       elsif Input.press?(ACTION_2_BUTTON)
  1775.          update_charge_effect(1)
  1776.          reset_charge_temp if Input.press?(ACTION_1_BUTTON)
  1777.       else
  1778.          if self.battler.x_charge_action[2] >= self.battler.x_charge_action[1]
  1779.             self.shoot(self.battler.x_charge_action[0])
  1780.          end
  1781.         reset_charge_temp
  1782.       end  
  1783.   end
  1784.  
  1785.   #--------------------------------------------------------------------------
  1786.   # ● Update Charge Effect
  1787.   #--------------------------------------------------------------------------        
  1788.   def update_charge_effect(type)
  1789.       if self.battler.x_charge_action[2] == 0
  1790.          return unless equipped_charge_action?(type)
  1791.       end  
  1792.       if self.battler.x_charge_action[2] < self.battler.x_charge_action[1]
  1793.          self.battler.x_charge_action[2] += 1
  1794.       end
  1795.       self.battler.x_charge_action[3] += 1
  1796.       if self.battler.x_charge_action[3] > XAS_ANIMATION::LOOP_ANIMATIONS_SPEED
  1797.          self.battler.x_charge_action[3] = 0
  1798.          if self.battler.x_charge_action[2] < self.battler.x_charge_action[1]
  1799.             self.animation_id = XAS_ANIMATION::CHARGE_ANIMATION1_ID
  1800.          else
  1801.             self.animation_id = XAS_ANIMATION::CHARGE_ANIMATION2_ID
  1802.          end  
  1803.       end
  1804.   end
  1805.  
  1806.   #--------------------------------------------------------------------------
  1807.   # ● Equipped Charge Action
  1808.   #--------------------------------------------------------------------------          
  1809.   def equipped_charge_action?(type)
  1810.       case type
  1811.          when 0
  1812.            weapon = self.battler.equips[0]
  1813.          when 1
  1814.            weapon = self.battler.equips[1]
  1815.       end
  1816.       if weapon == nil
  1817.          return false
  1818.          reset_charge_temp
  1819.       end
  1820.       if weapon.note =~ /<Charge Action = (\d+) - (\d+)>/  
  1821.          self.battler.x_charge_action[0] = $1.to_i rescue 0#Skill ID
  1822.          self.battler.x_charge_action[1] = $2.to_i rescue 0#Max Time
  1823.          self.battler.x_charge_action[2] = 0#Current Time
  1824.          self.battler.x_charge_action[3] = 0#Loop Anime Time
  1825.          return true
  1826.       end            
  1827.       return false    
  1828.       reset_charge_temp
  1829.   end
  1830.  
  1831.   #--------------------------------------------------------------------------
  1832.   # ● Update Combo Time
  1833.   #--------------------------------------------------------------------------        
  1834.   def update_combo_time
  1835.       return if self.battler.x_combo[2] == 0
  1836.       self.battler.x_combo[2] -= 1
  1837.       if self.battler.x_combo[2] == 0
  1838.          self.battler.x_combo[0] = 0
  1839.          self.battler.x_combo[1] = -1
  1840.       end  
  1841.   end  
  1842.  
  1843.   #--------------------------------------------------------------------------
  1844.   # ● Can Use Weapon Command?
  1845.   #--------------------------------------------------------------------------    
  1846.   def can_use_weapon_command?
  1847.       return false if $game_system.command_enable == false
  1848.       return false unless ENABLE_ACTION_1_BUTTON
  1849.       return false if self.battler.shield
  1850.       return false if self.battler.cast_action[4] > 0
  1851.       return false if self.battler.x_charge_action[2] > 0
  1852.       return true
  1853.   end
  1854.  
  1855.   #--------------------------------------------------------------------------
  1856.   # ● Can Use Shield Command?
  1857.   #--------------------------------------------------------------------------      
  1858.   def can_use_shield_command?
  1859.       return false if $game_system.command_enable == false
  1860.       return false unless ENABLE_ACTION_2_BUTTON
  1861.       return false if self.battler.equips[1] == nil
  1862.       return false if self.battler.equips[1].id == 0
  1863.       return false if self.battler.cast_action[4] > 0
  1864.       return false if self.battler.x_charge_action[2] > 0
  1865.       return true
  1866.   end
  1867.  
  1868.   #--------------------------------------------------------------------------
  1869.   # ● Can Use Skill Command?
  1870.   #--------------------------------------------------------------------------    
  1871.   def can_use_skill_command?
  1872.       return false if $game_system.command_enable == false
  1873.       return false unless ENABLE_SKILL_BUTTON
  1874.       return false if self.battler.shield
  1875.       return false if self.battler.cast_action[4] > 0
  1876.       return false if self.battler.x_charge_action[2] > 0
  1877.       return true
  1878.   end    
  1879.  
  1880.   #--------------------------------------------------------------------------
  1881.   # ● Can Use Item Command?
  1882.   #--------------------------------------------------------------------------    
  1883.   def can_use_item_command?
  1884.       return false if $game_system.command_enable == false
  1885.       return false unless ENABLE_ITEM_BUTTON
  1886.       return false if self.battler.shield    
  1887.       return false if self.battler.cast_action[4] > 0
  1888.       return false if self.battler.x_charge_action[2] > 0
  1889.       return true
  1890.   end      
  1891.  
  1892.   #--------------------------------------------------------------------------
  1893.   # ● Can Charge Command
  1894.   #--------------------------------------------------------------------------      
  1895.   def can_charge_command?
  1896.       return false if $game_system.command_enable == false
  1897.       return false if self.battler.cast_action[4] > 0
  1898.       return false if self.battler.shield      
  1899.       return true
  1900.   end  
  1901.  
  1902.   #--------------------------------------------------------------------------
  1903.   # ● Can Use Change Leader Command?
  1904.   #--------------------------------------------------------------------------      
  1905.   def can_use_change_leader_command?
  1906.       return false unless ENABLE_CHANGE_LEADER_BUTTON
  1907.       return false if self.battler.shield    
  1908.       return false if self.battler.cast_action[4] > 0
  1909.       return false if self.battler.x_charge_action[2] > 0
  1910.       return false if $game_temp.change_leader_wait_time > 0
  1911.       return true
  1912.   end
  1913.  
  1914.   #--------------------------------------------------------------------------
  1915.   # ● State_Seal Command
  1916.   #--------------------------------------------------------------------------        
  1917.   def state_seal_command?(type)
  1918.       seal = false
  1919.       case type  
  1920.          when 0
  1921.             seal = true if self.battler.state_mute
  1922.             seal = true if self.battler.state_seal_attack
  1923.          when 1
  1924.             seal = true if self.battler.state_mute
  1925.             seal = true if self.battler.state_seal_attack
  1926.          when 2
  1927.             seal = true if self.battler.state_mute
  1928.             seal = true if self.battler.state_seal_skill
  1929.          when 3  
  1930.             seal = true if self.battler.state_mute  
  1931.             seal = true if self.battler.state_seal_item
  1932.       end
  1933.       if seal
  1934.          seal_effect
  1935.          return true
  1936.       end  
  1937.       return false      
  1938.   end  
  1939.  
  1940.   #--------------------------------------------------------------------------
  1941.   # ● Check Equipped Action
  1942.   #--------------------------------------------------------------------------    
  1943.   def check_equipped_action(command_type)
  1944.       case command_type
  1945.          when 0 # Weapon 1
  1946.             weapon = self.battler.equips[0]
  1947.             if weapon == nil
  1948.                self.battler.x_action1_id = 0
  1949.                return
  1950.             end
  1951.             weapon.note =~ /<Action ID = (\d+)>/  
  1952.             action_id =  $1.to_i
  1953.             action_id = 0 if action_id == nil
  1954.             self.battler.x_action1_id = action_id
  1955.          when 1 # Weapon 2
  1956.             weapon = self.battler.equips[1]
  1957.             if weapon == nil
  1958.                self.battler.x_action2_id = 0
  1959.                return
  1960.             end  
  1961.             weapon.note =~ /<Action ID = (\d+)>/
  1962.             action_id =  $1.to_i
  1963.             action_id = 0 if action_id == nil            
  1964.             self.battler.x_action2_id = action_id
  1965.          when 2 # Skill  
  1966.            
  1967.          when 3 # Item
  1968.             item_id = $data_items[self.battler.item_id]
  1969.             if item_id == nil            
  1970.                self.battler.x_item_id =  0
  1971.                return
  1972.             end  
  1973.             item_id.note =~ /<Action ID = (\d+)>/
  1974.             action_id =  $1.to_i
  1975.             action_id = 0 if action_id == nil    
  1976.             self.battler.x_item_id = action_id
  1977.       end    
  1978.   end
  1979.    
  1980.   #--------------------------------------------------------------------------
  1981.   # ● Execute Combo
  1982.   #--------------------------------------------------------------------------        
  1983.   def execute_combo?(type)  
  1984.       if type == self.battler.x_combo[1] and self.battler.x_combo[0] != 0
  1985.          return if state_seal_command?(type)        
  1986.          self.shoot(self.battler.x_combo[0])
  1987.          self.battler.x_combo[1] = type
  1988.          return true
  1989.       end  
  1990.       self.battler.x_combo[0] = 0
  1991.       self.battler.x_combo[1] = type
  1992.       self.battler.x_combo[2] = 0
  1993.       return false
  1994.   end
  1995.  
  1996.   #--------------------------------------------------------------------------
  1997.   # ● Update Change Leader Button
  1998.   #--------------------------------------------------------------------------        
  1999.   def update_change_leader_button
  2000.       if Input.trigger?(CHANGE_LEADER_BUTTON)
  2001.          return unless can_use_change_leader_command?
  2002.          change_leader    
  2003.       end
  2004.   end
  2005.  
  2006.   #--------------------------------------------------------------------------
  2007.   # ● Update Action 1 Button
  2008.   #--------------------------------------------------------------------------      
  2009.   def update_action_1_button
  2010.       if Input.trigger?(ACTION_1_BUTTON)
  2011.          type = 0
  2012.          return unless can_use_weapon_command?
  2013.          return if execute_combo?(type)
  2014.          check_equipped_action(type)
  2015.          action_id = self.battler.x_action1_id
  2016.          return if action_id == 0
  2017.          return if state_seal_command?(type)
  2018.          self.shoot(action_id)
  2019.       end    
  2020.   end
  2021.    
  2022.   #--------------------------------------------------------------------------
  2023.   # ● Update Action 2 Button
  2024.   #--------------------------------------------------------------------------    
  2025.   def update_action_2_button
  2026.       if Input.trigger?(ACTION_2_BUTTON)
  2027.          if self.battler.equips[1].is_a?(RPG::Weapon)
  2028.             type = 1
  2029.             return unless can_use_weapon_command?
  2030.             return if execute_combo?(type)
  2031.             check_equipped_action(type)
  2032.             action_id = self.battler.x_action2_id
  2033.             return if action_id == 0
  2034.             return if state_seal_command?(type)            
  2035.             self.shoot(action_id)
  2036.             return
  2037.          end  
  2038.       end        
  2039.       update_shield_button
  2040.   end
  2041.  
  2042.   #--------------------------------------------------------------------------
  2043.   # ● Update Shield Button
  2044.   #--------------------------------------------------------------------------        
  2045.   def update_shield_button
  2046.       if Input.press?(ACTION_2_BUTTON)
  2047.          if can_use_shield_command?
  2048.             unless self.battler.shield  
  2049.                 shield = self.battler.equips[1]
  2050.                 if shield.note =~ /<Action>/
  2051.                    if shield.note =~ /<Pose = (\w+)>/
  2052.                       make_pose($1.to_s, 2)
  2053.                    end
  2054.                 else  
  2055.                    self.battler.shield = false
  2056.                    return
  2057.                 end
  2058.             end
  2059.             self.x_pose_duration = 2
  2060.             self.battler.shield = true
  2061.             update_shield_diretion_button
  2062.          else
  2063.             self.battler.shield = false
  2064.          end  
  2065.       else  
  2066.          self.battler.shield = false
  2067.       end      
  2068.   end
  2069.  
  2070.   #--------------------------------------------------------------------------
  2071.   # ● update_shield_direction_button
  2072.   #--------------------------------------------------------------------------          
  2073.   def update_shield_diretion_button
  2074.       return if @direction_fix
  2075.       case Input.dir4
  2076.          when 2;  set_direction(2)  
  2077.          when 4;  set_direction(4)  
  2078.          when 6;  set_direction(6)  
  2079.          when 8;  set_direction(8)  
  2080.       end
  2081.   end
  2082.  
  2083.   #--------------------------------------------------------------------------
  2084.   # ● Update Skill Button
  2085.   #--------------------------------------------------------------------------      
  2086.   def update_skill_button
  2087.       if Input.trigger?(SKILL_BUTTON)
  2088.          type = 2
  2089.          return unless can_use_skill_command?
  2090.          return if execute_combo?(type)
  2091.          check_equipped_action(type)
  2092.          action_id = self.battler.skill_id
  2093.          return if action_id == 0
  2094.          return if state_seal_command?(type)        
  2095.          self.shoot(action_id)
  2096.       end    
  2097.   end
  2098.  
  2099.   #--------------------------------------------------------------------------
  2100.   # ● Update Item Button
  2101.   #--------------------------------------------------------------------------      
  2102.   def update_item_button
  2103.       if Input.trigger?(ITEM_BUTTON)
  2104.          type = 3        
  2105.          return unless can_use_item_command?
  2106.          return if execute_combo?(type)
  2107.          check_equipped_action(type)
  2108.          action_id = self.battler.x_item_id
  2109.          return if action_id == 0
  2110.          return if state_seal_command?(type)        
  2111.          self.shoot(action_id)
  2112.       end  
  2113.   end
  2114.  
  2115.   #--------------------------------------------------------------------------
  2116.   # ● Update Auto Target Shoot
  2117.   #--------------------------------------------------------------------------
  2118.   def update_auto_target_shoot
  2119.       return if $game_temp.xas_target_time == 0
  2120.       return if $game_temp.xas_target_shoot_id == 0
  2121.       return if $game_temp.xas_target_x == 0 and $game_temp.xas_target_y == 0  
  2122.       $game_temp.xas_target_time -= 1
  2123.       if $game_temp.xas_target_time == 0
  2124.          self.shoot($game_temp.xas_target_shoot_id)
  2125.          $game_temp.xas_target_shoot_id = 0
  2126.       end  
  2127.   end  
  2128.  
  2129.  #--------------------------------------------------------------------------
  2130.  # ● Dash?
  2131.  #--------------------------------------------------------------------------            
  2132.  alias x_dash dash?
  2133.  def dash?  
  2134.      return false if XAS_SYSTEM::DASH_SYSTEM
  2135.      x_dash
  2136.  end
  2137.  
  2138.  #--------------------------------------------------------------------------
  2139.  # ● Can Dash?
  2140.  #--------------------------------------------------------------------------              
  2141.  def can_dash?
  2142.    return false if @backdash_cooldown
  2143.      return false unless XAS_BUTTON::ENABLE_DASH_BUTTON
  2144.      return false if self.battler.shield
  2145.      return true if Input.press?(XAS_BUTTON::DASH_BUTTON)
  2146.      @dash_active = false
  2147.      return false
  2148.  end
  2149.  
  2150.  #--------------------------------------------------------------------------
  2151.  # ● Update Dash Command
  2152.  #--------------------------------------------------------------------------            
  2153.  def update_dash_button
  2154.      return unless can_dash?
  2155.      @dash_active = true
  2156.      @anime_count -= 0.5 if moving?
  2157.      update_dash_sprite_name
  2158.  end  
  2159.  
  2160.  #--------------------------------------------------------------------------
  2161.  # ● Update Dash Sprite Name
  2162.  #--------------------------------------------------------------------------              
  2163.  def update_dash_sprite_name
  2164.      make_pose("_Dash", 2)
  2165.  end
  2166.  
  2167. end
  2168.  
  2169.  
  2170. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  2171. #■ TOOL - INITIALIZE
  2172. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  2173.  
  2174.  
  2175. #===============================================================================
  2176. # ■ Game_Map
  2177. #===============================================================================
  2178. class Game_Map
  2179.  
  2180.   attr_accessor :need_refresh_token
  2181.  
  2182.   #--------------------------------------------------------------------------
  2183.   # ● need_add_tokens
  2184.   #--------------------------------------------------------------------------  
  2185.   def need_add_tokens
  2186.       @need_add_tokens = [] if @need_add_tokens == nil
  2187.       return @need_add_tokens
  2188.   end
  2189.  
  2190.   #--------------------------------------------------------------------------
  2191.   # ● need_remove_tokens
  2192.   #--------------------------------------------------------------------------
  2193.   def need_remove_tokens
  2194.       @need_remove_tokens = [] if @need_remove_tokens == nil
  2195.       return @need_remove_tokens
  2196.   end
  2197.  
  2198.   #--------------------------------------------------------------------------
  2199.   # ● add_token
  2200.   #--------------------------------------------------------------------------
  2201.   def add_token(token_event)
  2202.       $game_temp.tool_event = [] if $game_temp.tool_event == nil
  2203.       $game_temp.tool_event.push(token_event)
  2204.       self.need_add_tokens.push(token_event)
  2205.       self.need_refresh_token = true
  2206.   end
  2207.  
  2208.   #--------------------------------------------------------------------------
  2209.   # ● remove_token
  2210.   #--------------------------------------------------------------------------
  2211.   def remove_token(token_event)
  2212.       @events.delete(token_event.id)
  2213.       self.need_remove_tokens.push(token_event)
  2214.       self.need_refresh_token = true
  2215.   end
  2216.  
  2217.   #--------------------------------------------------------------------------
  2218.   # ● clear_tokens
  2219.   #--------------------------------------------------------------------------
  2220.   def clear_tokens
  2221.       $game_system.tools_on_map.clear
  2222.       $game_system.tools_on_map = []
  2223.       for event in @events.values.dup
  2224.           remove_token(event) if event.is_a?(Token_Event)
  2225.       end
  2226.       channels = ["A", "B", "C", "D"]
  2227.       for id in 1001..(token_id_shift - 1)
  2228.           for a in channels
  2229.               key = [self.map_id, id, a]
  2230.               $game_self_switches.delete(key)
  2231.           end
  2232.       end
  2233.       clear_token_id
  2234.   end
  2235.    
  2236.   #--------------------------------------------------------------------------
  2237.   # ● Update
  2238.   #--------------------------------------------------------------------------      
  2239.   alias x_temp_tool_hash_update update
  2240.   def update(main = false)
  2241.       x_temp_tool_hash_update(main)
  2242.       update_add_tool_hash
  2243.   end
  2244.  
  2245.   #--------------------------------------------------------------------------
  2246.   # ● Update Add Toll Hash
  2247.   #--------------------------------------------------------------------------      
  2248.   def update_add_tool_hash  
  2249.       return if $game_temp.tool_event == nil
  2250.       for i in $game_temp.tool_event
  2251.           $game_map.events[i.id] = i
  2252.           execute_tool_effects_hash(i)
  2253.       end  
  2254.       $game_temp.tool_event.clear
  2255.       $game_temp.tool_event = nil
  2256.   end
  2257.    
  2258.   #--------------------------------------------------------------------------
  2259.   # ● Execute Toll Effects Hash
  2260.   #--------------------------------------------------------------------------        
  2261.   def execute_tool_effects_hash(i)
  2262.      
  2263.   end  
  2264. end
  2265.  
  2266. #===============================================================================
  2267. # ■ Game_SelfSwitches  
  2268. #===============================================================================
  2269. class Game_SelfSwitches
  2270.   def delete(key)
  2271.       @data.delete(key)
  2272.   end
  2273. end
  2274.  
  2275. #===============================================================================
  2276. # ■ Game_Map  
  2277. #===============================================================================
  2278. class Game_Map
  2279.    
  2280.   attr_accessor :token_id
  2281.  
  2282.   #--------------------------------------------------------------------------
  2283.   # ● token_id_shift
  2284.   #--------------------------------------------------------------------------  
  2285.   def token_id_shift
  2286.       @token_id  = 1000 if @token_id == nil
  2287.       @token_id += 1
  2288.       return @token_id
  2289.   end
  2290.  
  2291.   #--------------------------------------------------------------------------
  2292.   # ● clear_token_id
  2293.   #--------------------------------------------------------------------------  
  2294.   def clear_token_id
  2295.       @token_id = nil
  2296.   end
  2297. end
  2298.  
  2299. #===============================================================================
  2300. # ■ XRXS_CTS_RefreshToken
  2301. #===============================================================================
  2302. module XRXS_CTS_RefreshToken
  2303.  
  2304.   #--------------------------------------------------------------------------
  2305.   # ● refresh_token
  2306.   #--------------------------------------------------------------------------  
  2307.   def refresh_token
  2308.       for event in $game_map.need_add_tokens
  2309.           @character_sprites.push(Sprite_Character.new(@viewport1, event))
  2310.       end
  2311.       $game_map.need_add_tokens.clear
  2312.       for sprite in @character_sprites.dup
  2313.           if $game_map.need_remove_tokens.empty?
  2314.              break
  2315.           end
  2316.           if $game_map.need_remove_tokens.delete(sprite.character)
  2317.              @character_sprites.delete(sprite)
  2318.              sprite.dispose
  2319.           end
  2320.       end
  2321.       $game_map.need_refresh_token = false
  2322.   end
  2323. end
  2324.  
  2325. #===============================================================================
  2326. # ■  Spriteset_Map
  2327. #===============================================================================
  2328. class Spriteset_Map
  2329.   include XRXS_CTS_RefreshToken
  2330.  
  2331.   #--------------------------------------------------------------------------
  2332.   # ● Initialize
  2333.   #--------------------------------------------------------------------------    
  2334.   alias x_smap_initialize initialize
  2335.   def initialize
  2336.       setup_start
  2337.       x_smap_initialize
  2338.   end
  2339.  
  2340.   #--------------------------------------------------------------------------
  2341.   # ● Setup Start
  2342.   #--------------------------------------------------------------------------      
  2343.   def setup_start
  2344.       $game_player.reset_old_level(true)
  2345.   end
  2346.  
  2347. end
  2348.  
  2349. #===============================================================================
  2350. # ■ Game_Player
  2351. #===============================================================================
  2352. class Game_Player < Game_Character
  2353.  
  2354.   #--------------------------------------------------------------------------
  2355.   # ● x_reserve_transfer
  2356.   #--------------------------------------------------------------------------    
  2357.   alias x_reserve_transfer reserve_transfer
  2358.   def reserve_transfer(map_id, x, y, direction)
  2359.       $game_map.clear_tokens
  2360.       if $game_temp.tool_event != nil
  2361.          $game_temp.tool_event.clear
  2362.          $game_temp.tool_event = nil
  2363.       end  
  2364.       x_reserve_transfer(map_id, x, y, direction)
  2365.   end
  2366.  
  2367. end
  2368.  
  2369. #===============================================================================
  2370. # ■ Token_Event
  2371. #===============================================================================
  2372. class Token_Event < Game_Event
  2373.  
  2374.   #--------------------------------------------------------------------------
  2375.   # ● Token_Event
  2376.   #--------------------------------------------------------------------------
  2377.   def initialize(map_id, event)
  2378.       event.id = $game_map.token_id_shift
  2379.       super
  2380.   end
  2381.  
  2382.   #--------------------------------------------------------------------------
  2383.   # ● erase
  2384.   #--------------------------------------------------------------------------
  2385.   def erase
  2386.       super
  2387.       $game_map.remove_token(self)
  2388.   end
  2389. end
  2390.  
  2391.  
  2392. #===============================================================================
  2393. # ■  XRXS_ActionTemplate
  2394. #===============================================================================
  2395. module XRXS_ActionTemplate
  2396.   map_id = XAS_SYSTEM::ACTION_TEMPLATE_MAP_ID
  2397.   map = load_data(sprintf("Data/Map%03d.rvdata2", map_id))
  2398.   @@events = map.events
  2399. end
  2400.  
  2401. #===============================================================================
  2402. # ■  Token_Event
  2403. #===============================================================================
  2404. class Token_Event < Game_Event
  2405.   include XRXS_ActionTemplate
  2406. end
  2407.  
  2408. #===============================================================================
  2409. # ■  Game_Temp
  2410. #===============================================================================
  2411. class Game_Temp
  2412.   attr_accessor :active_token
  2413. end
  2414.  
  2415.  
  2416.  
  2417. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  2418. #■ TOOL - SHOOT COMMAND
  2419. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  2420.  
  2421.  
  2422. #===============================================================================
  2423. # ■ XAS ACTION
  2424. #===============================================================================
  2425. module XAS_ACTION
  2426.   attr_reader   :action
  2427.   attr_reader   :erased
  2428.  
  2429.   #--------------------------------------------------------------------------
  2430.   # ● shoot
  2431.   #--------------------------------------------------------------------------
  2432.   def shoot(action_id = 0)
  2433.       return if action_id == 0
  2434.       skill = $data_skills[action_id]
  2435.       return unless can_shoot?(skill)
  2436.       execute_user_effects(skill)
  2437.       execute_call_event(action_id)      
  2438.       self.action_attachment(action_id)
  2439.       execute_set_pose(action_id)
  2440.   end
  2441.  
  2442.   #--------------------------------------------------------------------------
  2443.   # ● Can Shoot
  2444.   #--------------------------------------------------------------------------    
  2445.   def can_shoot?(skill)
  2446.       if self.battler == nil and self.tool_id > 0
  2447.          @battler = self.action.user.battler
  2448.       end  
  2449.       return false if self.battler == nil
  2450.       return false if skill == nil
  2451.       return true if ignore_can_shoot?(skill)
  2452.       enough_cost = true
  2453.       return false if tools_on_map?(skill.id)      
  2454.       if self.battler.state_mute  
  2455.          seal_effect
  2456.          return false
  2457.       end  
  2458.       if self.battler.cast_action[4].between?(1,self.battler.cast_action[1] -1)
  2459.          return false
  2460.       end
  2461.       return false if check_cast_action?(skill)
  2462.       return false if check_auto_target_select?(skill)
  2463.       unless enough_skill_cost?(skill)
  2464.          Audio.se_play("Audio/SE/" + XAS_SOUND::ACTION_COST , 100, 100)
  2465.          return false
  2466.       end
  2467.       return true
  2468.   end
  2469.  
  2470.   #--------------------------------------------------------------------------
  2471.   # ● Ignore Can Shoot?    
  2472.   #--------------------------------------------------------------------------                
  2473.   def ignore_can_shoot?(skill)
  2474.       return false
  2475.   end
  2476.  
  2477.   #--------------------------------------------------------------------------
  2478.   # ● Tools on Map
  2479.   #--------------------------------------------------------------------------              
  2480.   def tools_on_map?(skill_id)
  2481.       return true if $game_system.tools_on_map.include?(skill_id)
  2482.       return false
  2483.   end  
  2484.  
  2485.   #--------------------------------------------------------------------------
  2486.   # ● Check Cast Action
  2487.   #--------------------------------------------------------------------------            
  2488.   def check_cast_action?(skill)
  2489.       if self.battler.cast_action[0] != 0
  2490.          self.battler.cast_action[0] = 0
  2491.          self.battler.cast_action[1] = 0
  2492.          self.battler.cast_action[2] = 0
  2493.          self.battler.cast_action[3] = 0
  2494.          self.battler.cast_action[4] = 0
  2495.          return false
  2496.       end  
  2497.       if skill.note =~ /<Cast Time = (\d+)>/ and
  2498.          $game_temp.xas_target_shoot_id == 0 and
  2499.          self.force_action_times == 0
  2500.          self.battler.cast_action[0] = skill.id
  2501.          self.battler.cast_action[1] = $1.to_i rescue 0
  2502.          self.battler.cast_action[2] = XAS_ANIMATION::CAST_TIME_ANIMATION_ID
  2503.          self.battler.cast_action[3] = 0
  2504.          self.battler.cast_action[4] = 0
  2505.          self.animation_id = self.battler.cast_action[2]
  2506.          return true
  2507.       end      
  2508.       return false
  2509.   end
  2510.  
  2511.   #--------------------------------------------------------------------------
  2512.   # ● Check Auto Target Select
  2513.   #--------------------------------------------------------------------------          
  2514.   def check_auto_target_select?(skill)
  2515.       return false if self.is_a?(Game_Event)
  2516.       if skill.note =~ /<Auto Target>/
  2517.          if $game_temp.xas_target_shoot_id == 0
  2518.             $game_temp.xas_target_shoot_id = skill.id
  2519.             $game_map.check_events_on_screen
  2520.             SceneManager.call(Scene_Target_Select)
  2521.             return true
  2522.          end          
  2523.       end  
  2524.       return false
  2525.   end
  2526.  
  2527.   #--------------------------------------------------------------------------
  2528.   # ● enough_skill_cost?
  2529.   #--------------------------------------------------------------------------          
  2530.   def enough_skill_cost?(skill)
  2531.       return false unless enough_mp_cost?(skill)        
  2532.       return false unless enough_item_cost?(skill)      
  2533.       return true
  2534.   end
  2535.    
  2536.   #--------------------------------------------------------------------------
  2537.   # ● Enough MP Cost
  2538.   #--------------------------------------------------------------------------        
  2539.   def enough_mp_cost?(skill)  
  2540.       if @force_action_times > 0
  2541.          return true if @force_action == "All Shoot"
  2542.          return true if @force_action == "Four Shoot"  
  2543.          return true if @force_action == "Three Shoot"
  2544.          return true if @force_action == "Two Shoot"
  2545.       end
  2546.       if self.battler.mp < skill.mp_cost
  2547.          self.battler.damage = XAS_WORD::NO_MP
  2548.          self.battler.damage_pop = true
  2549.          return false
  2550.       else  
  2551.          self.battler.mp -= skill.mp_cost
  2552.          return true
  2553.       end
  2554.       return true
  2555.   end  
  2556.  
  2557.   #--------------------------------------------------------------------------
  2558.   # ● Enough MP Cost
  2559.   #--------------------------------------------------------------------------      
  2560.   def enough_item_cost?(skill)
  2561.       return true if self.battler.is_a?(Game_Enemy)
  2562.       if @force_action_times > 0
  2563.          return true if @force_action == "All Shoot"
  2564.          return true if @force_action == "Four Shoot"
  2565.          return true if @force_action == "Three Shoot"
  2566.          return true if @force_action == "Two Shoot"
  2567.       end      
  2568.       skill.note =~ /<Item Cost = (\d+)>/
  2569.       item_id = $1.to_i
  2570.       if item_id != nil and item_id != 0
  2571.          item_cost = $data_items[item_id]
  2572.          number = $game_party.item_number(item_cost)
  2573.          if number == 0 or number == nil
  2574.             self.battler.damage = XAS_WORD::NO_ITEM
  2575.             self.battler.damage_pop = true
  2576.             return false
  2577.          else
  2578.             $game_party.lose_item(item_cost, 1, false)
  2579.             return true
  2580.          end            
  2581.       end    
  2582.       return true
  2583.   end    
  2584.  
  2585.   #--------------------------------------------------------------------------
  2586.   # ● Execute User Effects
  2587.   #--------------------------------------------------------------------------  
  2588.   def execute_user_effects(skill)
  2589.       self.battler.shield = false
  2590.       #Animation
  2591.       if skill.note =~ /<Cast Ani = (\d+)>/
  2592.          ani_id = $1.to_i    
  2593.          if ani_id != nil
  2594.             self.animation_id = ani_id
  2595.          end  
  2596.       end
  2597.       unless @force_action_times > 0
  2598.           #All Directions
  2599.           if skill.note =~ /<All Directions>/
  2600.              @force_action = "All Shoot"
  2601.              @force_action_times = 8        
  2602.           elsif skill.note =~ /<Four Directions>/
  2603.              @force_action = "Four Shoot"
  2604.              @force_action_times = 4      
  2605.           elsif skill.note =~ /<Three Directions>/
  2606.              @force_action = "Three Shoot"
  2607.              @force_action_times = 3        
  2608.           elsif skill.note =~ /<Two Directions>/
  2609.              @force_action = "Two Shoot"
  2610.              @force_action_times = 2        
  2611.           end  
  2612.       end  
  2613.   end
  2614.    
  2615.   #--------------------------------------------------------------------------
  2616.   # ● Execute Set Pose
  2617.   #--------------------------------------------------------------------------      
  2618.   def execute_set_pose(action_id)
  2619.       @action.duration = @action.sunflag
  2620.       make_pose(@action.self_motion, @action.sunflag )
  2621.       @pattern = 0
  2622.       @pattern_count  = 0
  2623.       @step_anime = true
  2624.       @self_motion = nil      
  2625.       self.need_refresh = true if self.is_a?(Game_Player)
  2626.   end  
  2627.    
  2628.   #--------------------------------------------------------------------------
  2629.   # ● execute_call_event
  2630.   #--------------------------------------------------------------------------  
  2631.   def execute_call_event(action_id)
  2632.       bullet_token = Token_Bullet.new(self, action_id)
  2633.       $game_map.add_token(bullet_token)
  2634.       return bullet_token
  2635.   end
  2636.      
  2637.   #--------------------------------------------------------------------------
  2638.   # ● action_attachment
  2639.   #--------------------------------------------------------------------------
  2640.   def action_attachment(action_id)
  2641.       @action = Game_Action_XAS.new(self, action_id)
  2642.       @action.attachment(action_id)
  2643.   end
  2644.  
  2645. end  
  2646.  
  2647.  
  2648. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  2649. #■ TOOL - SHOOT SETTING
  2650. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  2651.  
  2652.  
  2653. #===============================================================================
  2654. # ■ Game_Action_XAS
  2655. #===============================================================================
  2656. class Game_Action_XAS
  2657.  
  2658.   attr_accessor   :user
  2659.   attr_accessor   :id                    
  2660.   attr_accessor   :attack_id            
  2661.   attr_accessor   :attack_range
  2662.   attr_accessor   :attack_range_type
  2663.   attr_accessor   :hit_events
  2664.   attr_accessor   :now_count
  2665.   attr_accessor   :pre_now_count
  2666.   attr_accessor   :duration
  2667.   attr_accessor   :blow_power
  2668.   attr_accessor   :piercing
  2669.   attr_accessor   :ignore_knockback_invincible
  2670.   attr_accessor   :target_invunerable_duration
  2671.   attr_accessor   :multi_hit
  2672.   attr_accessor   :ally_damage
  2673.   attr_accessor   :all_damage
  2674.   attr_accessor   :sunflag
  2675.   attr_accessor   :self_motion
  2676.   attr_accessor   :second_animation_id
  2677.   attr_accessor   :third_animation_id
  2678.   attr_accessor   :attack_range_type
  2679.   attr_accessor   :attack_range_plan
  2680.   attr_accessor   :blow_power
  2681.   attr_accessor   :ignore_guard
  2682.   attr_accessor   :user_invincible  
  2683.   attr_accessor   :short_range
  2684.   attr_accessor   :first_impact_time
  2685.   attr_accessor   :animation_time
  2686.   attr_accessor   :duration
  2687.   attr_accessor   :item_cost
  2688.   attr_accessor   :hit_shake
  2689.   attr_accessor   :hit_hold_target
  2690.   attr_accessor   :hit_bounce
  2691.   attr_accessor   :sticky
  2692.   attr_accessor   :reflectable
  2693.   attr_accessor   :can_reflect
  2694.   attr_accessor   :attack_id_plan
  2695.   attr_accessor   :hit_action
  2696.   attr_accessor   :fake_id
  2697.   attr_accessor   :impact
  2698.  
  2699.   #--------------------------------------------------------------------------
  2700.   # ● initialize
  2701.   #--------------------------------------------------------------------------
  2702.   def initialize(user, action_id)
  2703.       @user        = user
  2704.       @id          = action_id
  2705.       @now_count   = 0
  2706.       @duration    = nil
  2707.       @attack_id   = 0
  2708.       @attack_range = 0
  2709.       @hit_events  = []
  2710.       @blow_power  = 0
  2711.       @skill = $data_skills[action_id]
  2712.       @ignore_knockback_invincible = false
  2713.       @multi_hit = false
  2714.       @piercing = false
  2715.       @all_damage = false
  2716.       @ally_damage = false
  2717.       @ignore_guard = false
  2718.       @sunflag = 10
  2719.       @duration = 10
  2720.       @self_motion = ""
  2721.       @attack_range_type = 1
  2722.       @attack_range_plan = 1
  2723.       @blow_power = 1
  2724.       @first_impact_time  = 0
  2725.       @animation_time = []
  2726.       @target_invunerable_duration = 10
  2727.       @second_animation_id = 0
  2728.       @third_animation_id = 0
  2729.       @user_invincible = false
  2730.       @short_range = false
  2731.       @item_cost = 0
  2732.       @hit_shake = false
  2733.       @hit_hold_target = false
  2734.       @hit_bounce = false
  2735.       @sticky = false
  2736.       @reflectable = false
  2737.       @can_reflect = false
  2738.       @hit_action = 0
  2739.       @fake_id = false
  2740.       @impact = true
  2741.   end
  2742.  
  2743.   #--------------------------------------------------------------------------
  2744.   # ● attachment
  2745.   #--------------------------------------------------------------------------
  2746.   def attachment(action_id)
  2747.       @attack_id_plan = [action_id]
  2748.       if @skill.note =~ /<Sunflag = (\d+)>/
  2749.          @sunflag = $1.to_i
  2750.       end
  2751.       if @skill.note =~ /<Duration = (\d+)>/  
  2752.          @duration = $1.to_i
  2753.       end
  2754.       if @skill.note =~ /<Pose = (\S+)>/  
  2755.          @self_motion = $1.to_s
  2756.       end
  2757.       if @skill.note =~ /<Area = (\w+)>/
  2758.          case $1
  2759.             when "CROSS"  
  2760.                area = 7
  2761.             when "WALL"
  2762.                area = 6        
  2763.             when "FRONTRHOMBUS"  
  2764.                area = 5
  2765.             when "FRONTSQUARE"
  2766.                area = 4
  2767.             when "LINE"
  2768.                area = 3
  2769.             when "SQUARE"
  2770.                area = 2              
  2771.             else  
  2772.                area = 1
  2773.          end    
  2774.          @attack_range_type = area
  2775.        end
  2776.       if @skill.note =~ /<Range = (\d+)>/  
  2777.          @attack_range_plan = [$1.to_i]
  2778.       end
  2779.       if @skill.note =~ /<Blow Power = (\d+)>/  
  2780.          @blow_power = $1.to_i
  2781.       end  
  2782.       if @skill.note =~ /<Impact Time  = (\d+)>/  
  2783.          @first_impact_time = $1.to_i
  2784.  
  2785.        end  
  2786.       if @skill.note =~ /<Animation Time  = (\d+) - (\d+)>/  
  2787.          @animation_time[0] = $1.to_i
  2788.          @animation_time[1] = $2.to_i
  2789.       end
  2790.       if @skill.note =~ /<Target Invunerable = (\d+)>/
  2791.          @target_invunerable_duration = $1.to_i
  2792.       end  
  2793.       if @skill.note =~ /<Tool Hit Ani = (\d+)>/      
  2794.          @second_animation_id = $1.to_i
  2795.       end        
  2796.       if @skill.note =~ /<User Hit Ani = (\d+)>/      
  2797.          @third_animation_id = $1.to_i
  2798.       end  
  2799.       if @skill.note =~ /<Item Cost = (\d+)>/    
  2800.          @item_cost = $1.to_i
  2801.       end        
  2802.       if @skill.note =~ /<Link Action ID = (\d+)>/    
  2803.          if user.battler != nil
  2804.             user.battler.x_combo[0] = $1.to_i
  2805.             user.battler.x_combo[2] = @sunflag + 20
  2806.          end
  2807.       else    
  2808.          if user.battler != nil
  2809.             user.battler.x_combo[0] = 0
  2810.             user.battler.x_combo[1] = 0
  2811.             user.battler.x_combo[2] = 0
  2812.          end            
  2813.       end  
  2814.       if @skill.note =~ /<Hit Action ID = (\d+)>/
  2815.          @hit_action = $1.to_i
  2816.       end
  2817.       if @skill.note =~ /<Ignore Knockback>/
  2818.          @ignore_knockback_invincible = true
  2819.       end      
  2820.       if @skill.note =~ /<Multi Hit>/
  2821.          @multi_hit = true  
  2822.       end        
  2823.       if @skill.note =~ /<Piercing>/
  2824.          @piercing = true
  2825.       end
  2826.       if @skill.note =~ /<All Damage>/
  2827.          @all_damage = true
  2828.       end
  2829.       if @skill.note =~ /<Ally Damage>/
  2830.          @ally_damage = true
  2831.       end      
  2832.       if @skill.note =~ /<User Invincible>/
  2833.          @user_invincible = true
  2834.       end      
  2835.       if @skill.note =~ /<Ignore Guard>/
  2836.          @ignore_guard = true
  2837.       end      
  2838.       if @skill.note =~ /<One Action>/
  2839.          unless $game_system.tools_on_map.include?(action_id)  
  2840.                 $game_system.tools_on_map.push(action_id)
  2841.          end
  2842.       end      
  2843.       if @skill.note =~ /<Shake>/
  2844.          @hit_shake = true
  2845.       end
  2846.       if @skill.note =~ /<User Range>/
  2847.          @short_range = true
  2848.       end      
  2849.       if @skill.note =~ /<Hit Hold Target>/
  2850.          @hit_hold_target = true
  2851.       end        
  2852.       if @skill.note =~ /<Hit Sticky Target>/
  2853.          @sticky = true
  2854.       end        
  2855.       if @skill.note =~ /<Hit Bounce Direction>/
  2856.          @hit_bounce = true
  2857.       end  
  2858.       if @skill.note =~ /<Reflectable>/
  2859.          @reflectable = true
  2860.       end        
  2861.       if @skill.note =~ /<Can Reflect>/
  2862.          @can_reflect = true
  2863.       end  
  2864.       if @skill.note =~ /<Disable Hit>/
  2865.          @impact = false
  2866.       end
  2867.       @sunflag = 1 if @sunflag <= 0
  2868.   end
  2869.  
  2870.   #--------------------------------------------------------------------------
  2871.   # ● update
  2872.   #--------------------------------------------------------------------------
  2873.   def update
  2874.       @first_impact_time -= 1 if @first_impact_time > 0
  2875.       if @attack_id_plan != nil
  2876.          id = @attack_id_plan[@now_count]
  2877.          unless id.nil?
  2878.            @attack_id = id
  2879.            @hit_events.clear
  2880.            @hit_events.push(self.user) unless @all_damage or @ally_damage
  2881.          end
  2882.       end
  2883.       if @attack_range_plan != nil
  2884.          range = @attack_range_plan[@now_count]
  2885.          @attack_range = range unless range.nil?
  2886.       end
  2887.       @now_count += 1
  2888.   end  
  2889.  
  2890.   #--------------------------------------------------------------------------
  2891.   # ● done?
  2892.   #--------------------------------------------------------------------------
  2893.   def done?
  2894.       return (self.duration.to_i > 0 and self.now_count >= self.duration)
  2895.   end
  2896. end
  2897.  
  2898. #===============================================================================
  2899. # ■ Token_Bullet  
  2900. #===============================================================================
  2901. class Token_Bullet < Token_Event
  2902. include XRXS_ActionTemplate
  2903.   #--------------------------------------------------------------------------
  2904.   # ● initialize
  2905.   #--------------------------------------------------------------------------
  2906.   def initialize(user, action_id)
  2907.       event_id = action_id
  2908.       skill = $data_skills[action_id]
  2909.       if skill.note =~ /<Event ID = (\d+)>/
  2910.          event_id = $1.to_i
  2911.       end  
  2912.       original_event = @@events[event_id]
  2913.       if original_event == nil
  2914.          msgbox("There's no Event ID " + event_id.to_s + " on Tool Map!")
  2915.          SceneManager.exit
  2916.          return
  2917.       end  
  2918.       event = original_event.dup
  2919.      if user.is_a?(Game_Event)
  2920.     event.x = user.x
  2921.      event.y = user.y
  2922. else
  2923.  
  2924.  
  2925.   event.x = user.float_x
  2926.   event.y = user.float_y
  2927. end
  2928.       pre_direction = event.pages[0].graphic.direction
  2929.       event.pages[0].graphic.direction = user.direction
  2930.       @character_name = event.pages[0].graphic
  2931.       super($game_map.map_id, event)
  2932.       self.action_attachment(action_id)
  2933.       self.tool_id = action_id
  2934.       self.diagonal = false
  2935.       self.diagonal_direction = 0
  2936.       self.sprite_angle_enable = false
  2937.       @action.user = user
  2938.       @remain_for_an_act = @action.duration.is_a?(Numeric)
  2939.       check_tool_effects(user,skill,pre_direction)
  2940.   end
  2941.  
  2942.   #--------------------------------------------------------------------------
  2943.   # ● update
  2944.   #--------------------------------------------------------------------------
  2945.   def update
  2946.       super
  2947.       if @action == nil and @remain_for_an_act
  2948.          erase
  2949.          $game_system.tools_on_map.delete(self.tool_id)
  2950.       end
  2951.       check_event_trigger_attack
  2952.   end
  2953. end
  2954.  
  2955. #===============================================================================
  2956. # ■ Game Player
  2957. #===============================================================================
  2958. class Game_Player < Game_Character
  2959.   attr_accessor :need_refresh
  2960. end
  2961.  
  2962. #===============================================================================
  2963. # ■ Token_Bullet  
  2964. #===============================================================================
  2965. class Token_Bullet < Token_Event
  2966.  
  2967.   #--------------------------------------------------------------------------
  2968.   # ● Check Tool Effects
  2969.   #--------------------------------------------------------------------------
  2970.   def check_tool_effects(user,skill,pre_direction)
  2971.       if @action.ally_damage or @action.all_damage    
  2972.          user.battler.invunerable_duration = 0
  2973.       end
  2974.      # Force Update Out Screen
  2975.      if user.battler.sensor_range >= 15 or
  2976.         skill.note =~ /<Update Out Screen>/
  2977.         self.force_update = true
  2978.      end  
  2979.      #Diagonal Effect
  2980.      if skill.note =~ /<Diagonal>/ or
  2981.         skill.note =~ /<All Direction>/ or
  2982.         skill.note =~ /<Three Direction>/
  2983.         self.diagonal = true
  2984.         self.diagonal_direction = user.diagonal_direction
  2985.         self.sprite_angle_enable = true
  2986.         user.diagonal_time = XAS_BA::DIAGONAL_DURATION if user.diagonal_direction != 0
  2987.         user.diagonal = true if user.tool_id > 0        
  2988.      end
  2989.      #Auto Target
  2990.      if skill.note =~ /<Auto Target>/
  2991.         if user.is_a?(Game_Event)
  2992.            self.moveto($game_player.x, $game_player.y)
  2993.         else  
  2994.            moveto($game_temp.xas_target_x, $game_temp.xas_target_y)
  2995.            $game_temp.xas_target_x = 0
  2996.            $game_temp.xas_target_y = 0      
  2997.            $game_temp.xas_target_time = 0
  2998.            $game_temp.xas_target_shoot_id = 0
  2999.         end  
  3000.      end
  3001.      #Barrier
  3002.      if skill.note =~ /<Barrier>/
  3003.         self.tool_effect = "Barrier"
  3004.      end
  3005.      #Boomerang
  3006.      if skill.note =~ /<Boomerang = (\d+)>/
  3007.         self.tool_effect = "Boomerang"
  3008.         self.action.duration = 100
  3009.         self.diagonal = true
  3010.         self.diagonal_direction = user.diagonal_direction
  3011.         self.force_update = true
  3012.         @move_frequency = 6
  3013.         @move_speed = 5
  3014.         @direction_fix = false
  3015.         @walk_anime = true
  3016.         @step_anime = true
  3017.         @force_action = "Forward"
  3018.         @force_action_times = $1.to_i
  3019.      end    
  3020.      
  3021.    end
  3022. end
  3023.  
  3024.  
  3025.  
  3026. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  3027. #■ TOOL - AREA
  3028. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  3029.  
  3030.  
  3031. #===============================================================================
  3032. # ■ XAS ACTION
  3033. #===============================================================================
  3034. module XAS_ACTION
  3035.  
  3036.   #--------------------------------------------------------------------------
  3037.   # ● action_update
  3038.   #--------------------------------------------------------------------------
  3039.   def action_update
  3040.       return unless @action.is_a?(Game_Action_XAS)
  3041.       if @action.animation_time != [] and
  3042.          @action.animation_time[0] == @action.now_count
  3043.          animation_id = @action.animation_time[1]
  3044.          unless self.is_a?(Game_Player) or self.tool_id == 0
  3045.              self.animation_id = animation_id
  3046.          end
  3047.       end
  3048.       @action.update
  3049.   end
  3050.    
  3051.   #--------------------------------------------------------------------------
  3052.   # ● Can Impact Target
  3053.   #--------------------------------------------------------------------------  
  3054.   def can_impact_target?
  3055.       return false if @action.nil?
  3056.       return false if @action.attack_id == 0
  3057.       return false if @action.first_impact_time > 0
  3058.       return false if @action.impact == false
  3059.       return false if self.jumping?
  3060.       return true
  3061.   end  
  3062.  
  3063.   #--------------------------------------------------------------------------
  3064.   # ● check_event_trigger_attack
  3065.   #--------------------------------------------------------------------------
  3066.   def check_event_trigger_attack()
  3067.       return unless can_impact_target?
  3068.       hit_check = false
  3069.       range = @action.attack_range
  3070.       hit = []
  3071.       targets = [$game_player] + $game_map.events.values
  3072.       for event in targets
  3073.         next if event == self or
  3074.                 @action.hit_events.include?(event) or event.erased
  3075.         body_size      = event.body_size
  3076.         event_center_x = event.x
  3077.         event_center_y = event.y - body_size
  3078.         if @action.short_range
  3079.            dx = event_center_x - $game_player.x
  3080.            dy = event_center_y - $game_player.y
  3081.         else
  3082.            dx = event_center_x - self.x
  3083.            dy = event_center_y - self.y
  3084.          end
  3085.         dx = (dx >= 0 ? [dx - body_size, 0].max : [dx + body_size, 0].min)
  3086.         dy = (dy >= 0 ? [dy - body_size, 0].max : [dy + body_size, 0].min)
  3087.         hit_check = true if in_range?(dx,dy,event,range)
  3088.         hit.push(event) if hit_check
  3089.         hit_check = false
  3090.       end
  3091.       for event in hit
  3092.           if event.action_effect(self, self.action.attack_id)
  3093.              hit_check = true
  3094.           end
  3095.           if event.action_effect_page(self, self.action.attack_id)
  3096.              hit_check = true
  3097.          end        
  3098.          @action.hit_events.push(event) unless @action.multi_hit
  3099.          end
  3100.       if hit_check
  3101.          $game_temp.active_token = self
  3102.       end
  3103.   end
  3104.  
  3105.   #--------------------------------------------------------------------------
  3106.   # ● In Range?
  3107.   #--------------------------------------------------------------------------  
  3108.   def in_range?(dx,dy,event,range)
  3109.       case @action.attack_range_type
  3110.             when 1 #RHOMBUS
  3111.               return true if (dx.abs + dy.abs <= range)
  3112.             when 2 #SQUARE
  3113.               return true if (dx.abs <= range and dy.abs <= range)
  3114.             when 3 #LINE
  3115.               case self.direction
  3116.                   when 2
  3117.                     return true if (dx == 0 and dy >= 0 and dy <= range)
  3118.                   when 8
  3119.                     return true if (dx == 0 and dy <= 0 and dy >= -range)
  3120.                   when 6
  3121.                     return true if (dy == 0 and dx >= 0 and dx <= range)
  3122.                   when 4
  3123.                     return true if (dy == 0 and dx <= 0 and dx >= -range)
  3124.               end
  3125.             when 4  #FRONT SQUARE  
  3126.               case self.direction
  3127.                  when 2
  3128.                     return true if (dx.abs <= range and dy >= 0 and dy.abs <= range)
  3129.                  when 4
  3130.                     return true if (dx.abs <= range and dx <= 0 and dy.abs <= range)  
  3131.                  when 6
  3132.                     return true if (dx.abs <= range and dx >= 0 and dy.abs <= range)
  3133.                  when 8
  3134.                     return true if (dx.abs <= range and dy <= 0 and dy.abs <= range)
  3135.               end              
  3136.             when 5  #FRONT RHOMBUS    
  3137.               case self.direction
  3138.                   when 2
  3139.                     return true if (dx.abs + dy.abs <= range and dy >= 0)
  3140.                   when 8
  3141.                     return true if (dx.abs + dy.abs <= range and dy <= 0)
  3142.                   when 6
  3143.                     return true if (dx.abs + dy.abs <= range and dx >= 0)
  3144.                   when 4
  3145.                     return true if (dx.abs + dy.abs <= range and dx <= 0)
  3146.               end          
  3147.             when 6  #WALL
  3148.               case self.direction
  3149.                  when 2
  3150.                     return true if (dx.abs <= range and dy == 0 )
  3151.                  when 4
  3152.                     return true if (dy.abs <= range and dx == 0)  
  3153.                  when 6
  3154.                     return true if (dy.abs <= range and dx == 0)
  3155.                  when 8
  3156.                     return true if (dx.abs <= range and dy == 0)
  3157.                end  
  3158.             when 7 #CROSS
  3159.                  return true if (dx.abs <= range and dy == 0)
  3160.                  return true if (dy.abs <= range and dx == 0)  
  3161.             end
  3162.      return false      
  3163.   end      
  3164.  
  3165.   #--------------------------------------------------------------------------
  3166.   # ●  action_effect Page
  3167.   #--------------------------------------------------------------------------
  3168.   def action_effect_page(attacker, attack_id)
  3169.       return false unless self.is_a?(Game_Event)
  3170.       return false if attacker.action.fake_id
  3171.       if attacker.action != nil
  3172.          check_auto_effect_page(attacker, attack_id)
  3173.          check_reflectable_skills(attacker, attack_id)
  3174.       end
  3175.       for page in @event.pages
  3176.           if page.condition.variable_valid and
  3177.              page.condition.variable_id == XAS_SYSTEM::HIT_ID and
  3178.              page.condition.variable_value == attack_id
  3179.              self.reaction_valid_attack_id = attack_id
  3180.              self.refresh
  3181.              @trigger = 0
  3182.              self.start
  3183.              return true
  3184.           end
  3185.       end
  3186.       return false
  3187.   end
  3188.  
  3189.   #--------------------------------------------------------------------------
  3190.   # ● Check Reflectable Skills
  3191.   #--------------------------------------------------------------------------    
  3192.   def check_reflectable_skills(attacker, attack_id)
  3193.       return if self.tool_id == 0
  3194.       return unless self.action.reflectable
  3195.       return unless attacker.action.can_reflect
  3196.       self.action.user = attacker.action.user
  3197.       self.action.hit_events = []  
  3198.       self.turn_back
  3199.   end  
  3200.  
  3201.   #--------------------------------------------------------------------------
  3202.   # ● Check Auto Effect Page
  3203.   #--------------------------------------------------------------------------  
  3204.   def check_auto_effect_page(attacker, attack_id)
  3205.       if self.treasure_time > 0
  3206.          if can_hit_take_treasure?(attacker, attack_id)
  3207.             execute_take_treasure(attacker, attack_id)
  3208.          elsif self.temp_id == 0 and can_hold_treasure?(attacker, attack_id)  
  3209.             execute_hold_treasure(attacker, attack_id)
  3210.          end  
  3211.       end
  3212.   end
  3213.  
  3214.   #--------------------------------------------------------------------------
  3215.   # ● Can Hit Take Treasure
  3216.   #--------------------------------------------------------------------------      
  3217.   def can_hit_take_treasure?(attacker, attack_id)
  3218.       return true if attacker.action.short_range
  3219.       return false
  3220.   end
  3221.  
  3222.   #--------------------------------------------------------------------------
  3223.   # ● Can Hold Treasure?
  3224.   #--------------------------------------------------------------------------        
  3225.   def can_hold_treasure?(attacker, attack_id)
  3226.       return true if attacker.tool_effect == "Boomerang"  
  3227.       return false
  3228.   end  
  3229.  
  3230.   #--------------------------------------------------------------------------
  3231.   # ● Execute Hold Treasure
  3232.   #--------------------------------------------------------------------------      
  3233.   def execute_hold_treasure(attacker, attack_id)
  3234.       tr_time = (100 + XAS_BA::TREASURE_ERASE_TIME * 60) - 20
  3235.       return if self.treasure_time > tr_time
  3236.       self.temp_id = attacker.id    
  3237.   end  
  3238.  
  3239.   #--------------------------------------------------------------------------
  3240.   # ● Execute Take Treasure
  3241.   #--------------------------------------------------------------------------      
  3242.   def execute_take_treasure(attacker, attack_id)
  3243.       tr_time = (100 + XAS_BA::TREASURE_ERASE_TIME * 60) - 20
  3244.       return if self.treasure_time > tr_time
  3245.       self.x = $game_player.x
  3246.       self.y = $game_player.y
  3247.   end
  3248.  
  3249.   #--------------------------------------------------------------------------
  3250.   # ● body_size
  3251.   #--------------------------------------------------------------------------
  3252.   def body_size
  3253.       return 0
  3254.   end
  3255.  
  3256.   #--------------------------------------------------------------------------
  3257.   # ● action_clear
  3258.   #--------------------------------------------------------------------------
  3259.   def action_clear
  3260.       @action = nil
  3261.       @step_anime = false
  3262.   end
  3263. end
  3264.  
  3265. #===============================================================================
  3266. # ■ Game_Character
  3267. #===============================================================================
  3268. class Game_Character < Game_CharacterBase
  3269.     include XAS_ACTION
  3270. end
  3271.  
  3272. #===============================================================================
  3273. # ■  Game_Event
  3274. #===============================================================================
  3275. class Game_Event < Game_Character
  3276.  
  3277.   #--------------------------------------------------------------------------
  3278.   # * Refresh
  3279.   #--------------------------------------------------------------------------
  3280.   alias x_conditions_met conditions_met?
  3281.   def conditions_met?(page)
  3282.       c = page.condition
  3283.       if c.variable_valid
  3284.          if c.variable_id == XAS_SYSTEM::HIT_ID and
  3285.             c.variable_value == self.reaction_valid_attack_id
  3286.             return true
  3287.          end
  3288.        end
  3289.       x_conditions_met(page)
  3290.   end
  3291.  
  3292. end  
  3293.  
  3294. #===============================================================================
  3295. # ■  XAS_Dispose
  3296. #===============================================================================
  3297. module XAS_Dispose
  3298.  
  3299.   #--------------------------------------------------------------------------
  3300.   # ● update
  3301.   #--------------------------------------------------------------------------  
  3302.   def update
  3303.       action_update
  3304.       super
  3305.       if @action.is_a?(Game_Action_XAS) and @action.done?
  3306.          self.action_clear
  3307.       end
  3308.   end
  3309. end
  3310.  
  3311. #===============================================================================
  3312. # ■  Game_Player
  3313. #===============================================================================
  3314. class Game_Player < Game_Character
  3315.   include XAS_Dispose
  3316. end
  3317.  
  3318. #===============================================================================
  3319. # ■  Game_Event
  3320. #===============================================================================
  3321. class Game_Event < Game_Character
  3322.   include XAS_Dispose
  3323. end
  3324.  
  3325. #===============================================================================
  3326. # ■ XAS_StopToAction
  3327. #===============================================================================
  3328. module XAS_StopToAction
  3329.  
  3330.   #--------------------------------------------------------------------------
  3331.   # ● acting?
  3332.   #--------------------------------------------------------------------------  
  3333.   def acting?
  3334.       return false if self.battler == nil
  3335.       return true if self.battler.shield
  3336.       return true if self.action != nil
  3337.       return false
  3338.   end
  3339.  
  3340.   #--------------------------------------------------------------------------
  3341.   # ● moving?
  3342.   #--------------------------------------------------------------------------  
  3343.   def moving?
  3344.       return (super or self.acting? or self.stop)
  3345.   end
  3346.    
  3347. end
  3348.  
  3349. #===============================================================================
  3350. # ■ Game_Player  
  3351. #===============================================================================
  3352. class Game_Player < Game_Character
  3353.   include XAS_StopToAction
  3354. end
  3355.  
  3356. #===============================================================================
  3357. # ■ Game_Event  
  3358. #===============================================================================
  3359. class Game_Event < Game_Character
  3360.   attr_accessor :reaction_valid_attack_id
  3361. end
  3362.  
  3363.  
  3364. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  3365. #■ TOOL - HIT EFFECT
  3366. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  3367.  
  3368.  
  3369. #===============================================================================
  3370. # ■ XRXS_BattlerAttachment
  3371. #==============================================================================
  3372. module XRXS_BattlerAttachment
  3373.  
  3374.   #--------------------------------------------------------------------------
  3375.   # ● Can Hit Base?
  3376.   #--------------------------------------------------------------------------    
  3377.   def can_hit_base?(bullet, action_id)
  3378.       return false unless $game_system.xas_battle
  3379.       return false if self.battler == nil
  3380.       return false if bullet == nil
  3381.       return false if action_id == nil or action_id <= 0
  3382.       return false if self.can_update == false
  3383.       return true
  3384.   end  
  3385.  
  3386.   #--------------------------------------------------------------------------
  3387.   # ● Action Effect
  3388.   #--------------------------------------------------------------------------  
  3389.   def action_effect(bullet, action_id)
  3390.       return unless can_hit_base?(bullet, action_id)
  3391.       skill = $data_skills[action_id]
  3392.       user = bullet.action.user
  3393.       attacker = (user == nil ? nil : user.battler)    
  3394.       tar_invu = bullet.action.target_invunerable_duration
  3395.       #CAN HIT?
  3396.       return unless action_can_hit_target?(bullet, user, skill,tar_invu)
  3397.       #REFLECT STATE
  3398.       return if reflect_state?(bullet, skill)
  3399.       #SHIELD
  3400.       if target_shield_enabled?(attacker, skill, bullet)
  3401.          execute_guard_effect(user, skill, bullet, tar_invu)
  3402.          return
  3403.       end
  3404.       #INVUNERABLE ACTIONS
  3405.       if target_invunerable_actions?(user, skill, bullet)
  3406.          execute_guard_effect(user, skill, bullet, tar_invu, false)
  3407.          return
  3408.       end  
  3409.       #GUARD DIRECTIONS
  3410.       if target_guard_directions?(user, skill, bullet)
  3411.          execute_guard_effect(user, skill, bullet, tar_invu)
  3412.          return        
  3413.       end  
  3414.       execute_hit_effect(attacker,skill, bullet , user, tar_invu )
  3415.       if self.is_a?(Game_Player)
  3416.          self.need_refresh = true
  3417.       end
  3418.   end
  3419.  
  3420.   #--------------------------------------------------------------------------
  3421.   # ● Reflect State?
  3422.   #--------------------------------------------------------------------------                
  3423.   def reflect_state?(bullet, skill)
  3424.       if  bullet.action.reflectable and self.battler.state_reflect
  3425.           if skill.note =~ /<Auto Target>/
  3426.              bullet.moveto(bullet.action.user.x,bullet.action.user.y)
  3427.           else  
  3428.              bullet.turn_back
  3429.           end  
  3430.           bullet.action.user = self
  3431.           bullet.action.hit_events = []          
  3432.           bullet.turn_back
  3433. #          bullet.jump(0,0)
  3434.           bullet.turn_back
  3435.           self.battler.damage = XAS_WORD::REFLECT
  3436.           self.battler.damage_pop = true
  3437.           self.animation_id = XAS_ANIMATION::REFLECT_ANIMATION_ID
  3438.           self.battler.invunerable_duration = 20
  3439.          return true
  3440.      end
  3441.      return false    
  3442.   end
  3443.  
  3444.  #--------------------------------------------------------------------------
  3445.  # ● Target Guard Directions?
  3446.  #--------------------------------------------------------------------------    
  3447.  def target_guard_directions?(user, skill, bullet)
  3448.      return false if self.battler.guard == false
  3449.      return false if bullet.action.ignore_guard
  3450.      if self.battler.guard_directions.include?(2) and
  3451.         ((self.direction == 2 and bullet.direction == 8) or
  3452.          (self.direction == 8 and bullet.direction == 2) or
  3453.          (self.direction == 6 and bullet.direction == 4) or
  3454.          (self.direction == 4 and bullet.direction == 6))
  3455.          return true
  3456.      elsif self.battler.guard_directions.include?(8) and
  3457.         ((self.direction == 8 and bullet.direction == 8) or
  3458.          (self.direction == 2 and bullet.direction == 2) or
  3459.          (self.direction == 6 and bullet.direction == 6) or
  3460.          (self.direction == 4 and bullet.direction == 4))
  3461.          return true
  3462.      elsif self.battler.guard_directions.include?(4) and
  3463.         ((self.direction == 2 and bullet.direction == 4) or
  3464.          (self.direction == 8 and bullet.direction == 6) or
  3465.          (self.direction == 6 and bullet.direction == 2) or
  3466.          (self.direction == 4 and bullet.direction == 8))
  3467.          return true        
  3468.      elsif self.battler.guard_directions.include?(6) and
  3469.         ((self.direction == 2 and bullet.direction == 6) or
  3470.          (self.direction == 8 and bullet.direction == 4) or
  3471.          (self.direction == 6 and bullet.direction == 8) or
  3472.          (self.direction == 4 and bullet.direction == 2))
  3473.          return true
  3474.      end      
  3475.      return false
  3476.   end
  3477.      
  3478.   #--------------------------------------------------------------------------
  3479.   # ● Target Invunerable Actions?
  3480.   #--------------------------------------------------------------------------            
  3481.   def target_invunerable_actions?(user, skill, bullet)
  3482.       return true if self.battler.invunerable_actions.include?(skill.id)
  3483.       return false
  3484.   end
  3485.  
  3486.   #--------------------------------------------------------------------------
  3487.   # ● Shoot Target Shield
  3488.   #--------------------------------------------------------------------------          
  3489.   def shoot_target_shield?(bullet,user, skill)
  3490.       return false unless self.battler.shield
  3491.       return false if bullet.action.ignore_guard
  3492.       return true if face_direction?(bullet)
  3493.       return false
  3494.   end
  3495.  
  3496.   #--------------------------------------------------------------------------
  3497.   # ● Action can hit target?
  3498.   #--------------------------------------------------------------------------        
  3499.   def action_can_hit_target?(bullet, user, skill,tar_invu)
  3500.       if user == nil
  3501.          return false
  3502.       end  
  3503.       if self.battler.invunerable
  3504.          return false
  3505.       end  
  3506.       if self.battler.dead?
  3507.          return false
  3508.       end  
  3509.       if self.battler.invunerable_duration > 0
  3510.          return false
  3511.       end  
  3512.       if @knock_back_duration != nil
  3513.          return false unless bullet.action.ignore_knockback_invincible
  3514.       end
  3515.       if bullet.action.first_impact_time > 0
  3516.          return false
  3517.       end
  3518.       if self.action != nil and self.action.user_invincible
  3519.          unless self.action.ally_damage and bullet.action.user == self.action.user
  3520.              return false
  3521.          end
  3522.       end  
  3523.       unless bullet.action.all_damage
  3524.              if bullet.action.ally_damage
  3525.                 if user.battler.is_a?(Game_Actor)
  3526.                    return false if self.battler.is_a?(Game_Enemy)
  3527.                 elsif user.battler.is_a?(Game_Enemy)
  3528.                    return false if self.battler.is_a?(Game_Actor)
  3529.                 end
  3530.              else    
  3531.                 if user.battler.is_a?(Game_Actor)
  3532.                    return false if self.battler.is_a?(Game_Actor)
  3533.                 elsif user.battler.is_a?(Game_Enemy)
  3534.                    return false if self.battler.is_a?(Game_Enemy)
  3535.                 end                
  3536.              end              
  3537.       end
  3538.       return false if target_state_invunerable?(tar_invu)
  3539.       #return false if target_reflect_action?(bullet, user)
  3540.       return true
  3541.   end
  3542.  
  3543.   #--------------------------------------------------------------------------
  3544.   # ● Target Relfect Action
  3545.   #--------------------------------------------------------------------------          
  3546.   def target_reflect_action?(bullet, user)
  3547.       return false unless bullet.action.reflectable
  3548.       for i in $game_map.events.values
  3549.           if i.tool_id > 0 and i.action.can_reflect and
  3550.              i.tool_effect == "Barrier"# and i.action.user.battler.is_a?(self.battler)
  3551.              bullet.action.user = self
  3552.              bullet.action.hit_events = []  
  3553.              bullet.turn_back
  3554.              return true
  3555.              break
  3556.           end  
  3557.       end
  3558.       return false  
  3559.   end
  3560.  
  3561.   #--------------------------------------------------------------------------
  3562.   # ● Target State Invunerable
  3563.   #--------------------------------------------------------------------------        
  3564.   def target_state_invunerable?(tar_invu)
  3565.       if self.battler.state_invunerable
  3566.          self.battler.damage = XAS_WORD::INVINCIBLE
  3567.          self.battler.damage_pop = true
  3568.          self.animation_id = XAS_ANIMATION::INVINCIBLE_ANIMATION_ID
  3569.          self.battler.invunerable_duration = tar_invu
  3570.          return true
  3571.       end
  3572.       return false
  3573.   end
  3574.  
  3575.   #--------------------------------------------------------------------------
  3576.   # ● Execute Hit Effect
  3577.   #--------------------------------------------------------------------------      
  3578.   def execute_hit_effect(attacker,skill, bullet , user, tar_invu)
  3579.       shoot_effect_before_damage(skill, bullet, user)
  3580.       execute_battler_skill_effect(attacker ,skill, user)
  3581.       if target_missed?(attacker)
  3582.          self.battler.invunerable_duration = 30
  3583.          return
  3584.       end            
  3585.       execute_damage_pop(attacker,skill)
  3586.       shoot_effect_after_damage(skill, bullet, user) if can_damage_after_effect?
  3587.       execute_state_effect(skill, user,  bullet)    
  3588.       bullet.action.duration = 1 if remove_tool_after_hit?(skill, bullet, user)
  3589.       self.battler.invunerable_duration = tar_invu
  3590.       execute_blow_effect(skill,bullet) if can_blow_effect?
  3591.       execute_animation(skill, bullet, user)
  3592.       execute_tool_effects(skill, bullet , user)
  3593.   end
  3594.  
  3595.   #--------------------------------------------------------------------------
  3596.   # ● Execute Tool Effects
  3597.   #--------------------------------------------------------------------------              
  3598.   def execute_tool_effects(skill, bullet , user)
  3599.       execute_sticky_effect(skill, bullet, user)
  3600.       execute_bounce_effect(skill, bullet, user)
  3601.       execute_hit_action_effect(skill, bullet, user)
  3602.   end
  3603.    
  3604.   #--------------------------------------------------------------------------
  3605.   # ● Remove Tool After Hit?
  3606.   #--------------------------------------------------------------------------            
  3607.   def remove_tool_after_hit?(skill, bullet, user)
  3608.       return true if bullet.action.piercing == false
  3609.       return false
  3610.   end  
  3611.  
  3612.   #--------------------------------------------------------------------------
  3613.   # ● Execute Battler Skill Effect
  3614.   #--------------------------------------------------------------------------          
  3615.   def execute_battler_skill_effect(attacker ,skill, user)
  3616.       self.battler.item_apply(attacker, skill)
  3617.   end
  3618.  
  3619.   #--------------------------------------------------------------------------
  3620.   # ● Target Missed?
  3621.   #--------------------------------------------------------------------------        
  3622.   def target_missed?(attacker)
  3623.       if self.battler.result.missed
  3624.          self.battler.damage = XAS_WORD::MISSED
  3625.          self.battler.damage_pop = true        
  3626.          return true
  3627.       end    
  3628.       if self.battler.result.evaded
  3629.          self.battler.damage = XAS_WORD::EVADED
  3630.          self.battler.damage_pop = true            
  3631.          return true
  3632.       end  
  3633.       return false
  3634.   end  
  3635.   #--------------------------------------------------------------------------
  3636.   # ● Shoot Effect Before Damage
  3637.   #--------------------------------------------------------------------------        
  3638.   def shoot_effect_before_damage(skill, bullet, user)
  3639.   end
  3640.  
  3641.   #--------------------------------------------------------------------------
  3642.   # ● Shoot Effect After Damage
  3643.   #--------------------------------------------------------------------------          
  3644.   def shoot_effect_after_damage(skill, bullet, user)
  3645.       check_counter_attack(skill)
  3646.       self.battler.passive = false
  3647.   end
  3648.  
  3649.   #--------------------------------------------------------------------------
  3650.   # ● Shoot Effect After Damage
  3651.   #--------------------------------------------------------------------------            
  3652.   def check_counter_attack(skill)
  3653.       return if self.battler.is_a?(Game_Actor)
  3654.       return if self.battler.counter_action[2] == false
  3655.       return if self.battler.counter_action[1] > 0
  3656.       counter = XAS_BA_ENEMY::COUNTER_ATTACK[self.battler.enemy_id]
  3657.       if counter != nil
  3658.          counter_action_id = counter[rand(counter.size)]
  3659.          self.battler.counter_action[0] = counter_action_id
  3660.          self.battler.counter_action[1] = 15
  3661.       end  
  3662.   end  
  3663.  
  3664.   #--------------------------------------------------------------------------
  3665.   # ● Execute Bounce Effect
  3666.   #--------------------------------------------------------------------------            
  3667.   def execute_bounce_effect(skill, bullet, user)
  3668.       return false if bullet.action.hit_bounce == false
  3669.       bullet.bounce_direction
  3670.   end
  3671.  
  3672.   #--------------------------------------------------------------------------
  3673.   # ● Execute Stick Effect
  3674.   #--------------------------------------------------------------------------          
  3675.   def execute_sticky_effect(skill, bullet, user)
  3676.       return unless bullet.action.sticky
  3677.       return if bullet.temp_id !=  0
  3678.       bullet.pre_move_speed = bullet.move_speed
  3679.       bullet.temp_id = self.id
  3680.   end
  3681.  
  3682.   #--------------------------------------------------------------------------
  3683.   # ● Execute Hit Action Effect
  3684.   #--------------------------------------------------------------------------            
  3685.   def execute_hit_action_effect(skill, bullet, user)
  3686.       return if bullet.action.hit_action == 0
  3687.       self.battler.invunerable_duration = 1
  3688.       bullet.shoot(bullet.action.hit_action)
  3689.       bullet.action.duration = 9
  3690.       bullet.action.multi_hit = false
  3691.       bullet.character_name = ""
  3692.       bullet.x_pose_duration = 0
  3693.       bullet.x_pose_name = ""
  3694.       bullet.x_pose_original_name = ""      
  3695.   end
  3696.  
  3697.   #--------------------------------------------------------------------------
  3698.   # ● Can Damage Effect
  3699.   #--------------------------------------------------------------------------          
  3700.   def can_damage_after_effect?
  3701.       return false if self.battler.damage == nil
  3702.       return false unless self.battler.damage.is_a?(Numeric)
  3703.       return true
  3704.   end  
  3705.  
  3706.   #--------------------------------------------------------------------------
  3707.   # ● Execute State Effect
  3708.   #--------------------------------------------------------------------------        
  3709.   def execute_state_effect(skill, user,  bullet)  
  3710.       if user.battler.states.size != 0
  3711.          for i in user.battler.states
  3712.              execute_state_effect_user(skill, user, bullet,i)
  3713.          end    
  3714.       end
  3715.       if self.battler.states.size != 0
  3716.          for i in self.battler.states
  3717.              execute_state_effect_target(skill, user, bullet,i)
  3718.          end    
  3719.       end
  3720.   end
  3721.  
  3722.   #--------------------------------------------------------------------------
  3723.   # ● Execute State Effect User
  3724.   #--------------------------------------------------------------------------          
  3725.   def execute_state_effect_user(skill, user, bullet,i)
  3726.  
  3727.   end
  3728.  
  3729.   #--------------------------------------------------------------------------
  3730.   # ● Execute State Target
  3731.   #--------------------------------------------------------------------------          
  3732.   def execute_state_effect_target(skill, user, bullet,i)
  3733.       #Sleep
  3734.       if self.battler.damage.is_a?(Numeric) and self.battler.damage > 0
  3735.          if i.note =~ /<Sleep>/  
  3736.             self.battler.remove_state(i.id)
  3737.          end
  3738.       end  
  3739.   end  
  3740.  
  3741.   #--------------------------------------------------------------------------
  3742.   # ● Execute Blow Effect
  3743.   #--------------------------------------------------------------------------      
  3744.   def execute_blow_effect(skill,bullet)
  3745.       if bullet.action.hit_hold_target and self.temp_id == 0    
  3746.          self.temp_id = bullet.id
  3747.          self.pre_move_speed = self.move_speed        
  3748.          self.moveto(bullet.x, bullet.y)
  3749.       end  
  3750.       $game_map.screen.start_shake(5, 5, 60) if bullet.action.hit_shake
  3751.       p = bullet.action.blow_power.to_i  
  3752.       d = bullet.direction    
  3753.       return if self.battler.damage.to_i <= 0
  3754.       return if p < 0
  3755.       self.blow(d, p)  
  3756.   end
  3757.    
  3758.   #--------------------------------------------------------------------------
  3759.   # ● Execute Animation
  3760.   #--------------------------------------------------------------------------        
  3761.   def execute_animation(skill, bullet, user)    
  3762.       self.animation_id = skill.animation_id
  3763.       tool_animation = bullet.action.second_animation_id
  3764.       user_animation = bullet.action.third_animation_id
  3765.       bullet.animation_id = tool_animation if tool_animation != 0
  3766.       user.animation_id = user_animation if user_animation != 0
  3767.   end  
  3768.    
  3769.   #--------------------------------------------------------------------------
  3770.   # ● Knock Back Disable
  3771.   #--------------------------------------------------------------------------      
  3772.   def knock_back_disable
  3773.     return false
  3774.   end
  3775.  
  3776.   #--------------------------------------------------------------------------
  3777.   # ● Dead?
  3778.   #--------------------------------------------------------------------------          
  3779.   def dead?
  3780.     return self.battler == nil ? false : self.battler.dead?
  3781.   end
  3782.  
  3783. end
  3784.  
  3785.  
  3786. #===============================================================================
  3787. # ■ XRXS_BattlerAttachment
  3788. #==============================================================================
  3789. module XRXS_BattlerAttachment
  3790.  
  3791.   #--------------------------------------------------------------------------
  3792.   # ● Shoot Target Shield
  3793.   #--------------------------------------------------------------------------          
  3794.   def target_shield_enabled?(attacker, skill, bullet)
  3795.       return false unless self.battler.shield
  3796.       if bullet != nil
  3797.          return false if bullet.action.ignore_guard
  3798.          return true if face_direction?(bullet)        
  3799.       else  
  3800.          return false if attacker.battler.ignore_guard
  3801.          return true if face_direction?(attacker)        
  3802.       end  
  3803.       return false
  3804.   end  
  3805.  
  3806.   #--------------------------------------------------------------------------
  3807.   # ● Can Blow Effect
  3808.   #--------------------------------------------------------------------------        
  3809.   def can_blow_effect?
  3810.       return false if self.battler.no_knockback
  3811.       return false if $game_map.interpreter.running?
  3812.       return true
  3813.   end  
  3814.  
  3815.  #--------------------------------------------------------------------------
  3816.  # ● Execute Guard Effect
  3817.  #--------------------------------------------------------------------------      
  3818.  def execute_guard_effect(attacker, skill, bullet, inv, erase_bullet = true)
  3819.      self.battler.invunerable_duration = inv
  3820.      damage_pop(XAS_WORD::GUARD)
  3821.      guard_animation_id = XAS_ANIMATION::GUARD_ANIMATION_ID
  3822.      self.animation_id = guard_animation_id if guard_animation_id != 0  
  3823.      if bullet != nil
  3824.         bullet.erase if erase_bullet
  3825.      else  
  3826.         blow_reverse(attacker) unless attacker.battler.no_knockback
  3827.      end  
  3828.  end
  3829.    
  3830.  #--------------------------------------------------------------------------
  3831.  # ● Blow Reverse
  3832.  #--------------------------------------------------------------------------      
  3833.  def blow_reverse(attacker)
  3834.      return if attacker.battler.no_knockback
  3835.      case attacker.direction
  3836.         when 2
  3837.            d = 8
  3838.         when 4
  3839.            d = 6
  3840.         when 6
  3841.            d = 4
  3842.         when 8  
  3843.            d = 2
  3844.      end
  3845.      attacker.jump(0,0)  
  3846.      attacker.blow(d,1)
  3847.  end
  3848.  
  3849.  #--------------------------------------------------------------------------
  3850.  # ● Can Attack Effect
  3851.  #--------------------------------------------------------------------------      
  3852.  def damage_pop(text)
  3853.      return unless XAS_WORD::ENABLE_WORD
  3854.      self.battler.damage = text
  3855.      self.battler.damage_pop = true
  3856.  end
  3857.  
  3858.  #--------------------------------------------------------------------------
  3859.  # ● Shd Direction?
  3860.  #--------------------------------------------------------------------------      
  3861.  def face_direction?(attacker)
  3862.      target = self.direction  
  3863.      case target
  3864.           when 2
  3865.              return true if attacker.direction == 8
  3866.           when 4
  3867.              return true if attacker.direction == 6
  3868.           when 6
  3869.              return true if attacker.direction == 4
  3870.           when 8  
  3871.              return true if attacker.direction == 2    
  3872.      end
  3873.      return false
  3874.  end  
  3875.  
  3876.  #--------------------------------------------------------------------------
  3877.  # ● Execute Damage Pop
  3878.  #--------------------------------------------------------------------------      
  3879.  def execute_damage_pop(attacker,skill = nil)
  3880.      if skill != nil
  3881.         return if skill.note =~ /<No Damage Pop>/
  3882.         if skill.damage.to_mp?
  3883.            dam = self.battler.result.mp_damage
  3884.            self.battler.damage_type = "Mp"      
  3885.         elsif skill.damage.to_hp?
  3886.            dam = self.battler.result.hp_damage
  3887.            self.battler.damage_type = "Critical"  if self.battler.result.critical
  3888.         end  
  3889.         if dam != nil
  3890.            if skill.damage.drain? or skill.damage.drain?
  3891.               attacker.damage = -dam
  3892.               attacker.damage_type = self.battler.damage_type
  3893.               attacker.damage_pop = true
  3894.            end  
  3895.            self.battler.damage = dam
  3896.            self.battler.damage_pop = true
  3897.         end
  3898.      else
  3899.         if self.battler.result.hp_damage != nil
  3900.            self.battler.damage = self.battler.result.hp_damage
  3901.            self.battler.damage_type = "Critical" if self.battler.result.critical  
  3902.            self.battler.damage_pop = true      
  3903.         end  
  3904.      end  
  3905.  end  
  3906.  
  3907. end  
  3908.  
  3909.  
  3910.  
  3911. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  3912. #■ TOOL - EQUIP
  3913. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  3914.  
  3915.  
  3916. #==============================================================================
  3917. # ■ Window Skill List
  3918. #==============================================================================
  3919. class Window_SkillList < Window_Selectable
  3920.  
  3921.   #--------------------------------------------------------------------------
  3922.   # ● Process OK
  3923.   #--------------------------------------------------------------------------                  
  3924.   alias x_skill_process_ok process_ok
  3925.   def process_ok
  3926.       return if can_equip_skill_action?
  3927.       x_skill_process_ok
  3928.   end
  3929.  
  3930.   #--------------------------------------------------------------------------
  3931.   # ● Can Equip Skill Action
  3932.   #--------------------------------------------------------------------------                    
  3933.   def can_equip_skill_action?
  3934.       return false if $game_party.in_battle
  3935.       skill = @data[index]
  3936.       if skill != nil and skill.note =~ /<Duration = (\d+)>/
  3937.          @actor.skill_id = skill.id
  3938.          Sound.play_equip
  3939.          return true        
  3940.       end
  3941.       return false
  3942.   end
  3943.  
  3944. end
  3945.  
  3946. #==============================================================================
  3947. # ■ Window Item List
  3948. #==============================================================================
  3949. class Window_ItemList < Window_Selectable
  3950.  
  3951.   #--------------------------------------------------------------------------
  3952.   # ● Process OK
  3953.   #--------------------------------------------------------------------------                  
  3954.   alias x_item_process_ok process_ok
  3955.   def process_ok
  3956.       return if can_equip_item_action?
  3957.       x_item_process_ok
  3958.   end
  3959.  
  3960.   #--------------------------------------------------------------------------
  3961.   # ● Can Equip Item Action
  3962.   #--------------------------------------------------------------------------                    
  3963.   def can_equip_item_action?
  3964.       return false if $game_party.in_battle
  3965.       item = @data[index]
  3966.       if item != nil and item.is_a?(RPG::Item) and
  3967.          item.note =~ /<Action ID = (\d+)>/
  3968.          actor = $game_party.members[0]
  3969.          actor.item_id = item.id
  3970.          Sound.play_equip
  3971.          return true        
  3972.       end
  3973.       return false
  3974.   end
  3975.  
  3976. end
  3977.  
  3978.  
  3979.  
  3980. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  3981. #■ BATTLER - INITIALIZE
  3982. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  3983.  
  3984.  
  3985. #===============================================================================
  3986. # ■ Game Character
  3987. #==============================================================================
  3988. class Game_Character < Game_CharacterBase
  3989.  
  3990.   #--------------------------------------------------------------------------
  3991.   # ● Update Battler
  3992.   #--------------------------------------------------------------------------      
  3993.   def update_battler
  3994.       update_battler_pose
  3995.       update_battler_parameters
  3996.       update_battler_stop_movement
  3997.       update_battler_knockbacking
  3998.       update_battler_counter_action
  3999.       unless self.battler.hp == 0
  4000.           update_battler_cast_action    
  4001.           update_battler_move_speed if can_update_battler_move_speed?
  4002.           update_battler_states_effect
  4003.           update_battler_attacking
  4004.       else
  4005.           update_battler_defeat_process
  4006.       end
  4007.   end  
  4008.  
  4009. end
  4010.  
  4011. #===============================================================================
  4012. # ■ Game Player
  4013. #===============================================================================
  4014. class Game_Player < Game_Character
  4015.   include XRXS_BattlerAttachment
  4016.  
  4017.   #--------------------------------------------------------------------------
  4018.   # ● Battler
  4019.   #--------------------------------------------------------------------------  
  4020.   def battler
  4021.       return $game_party.members[0]
  4022.   end
  4023.  
  4024.   #--------------------------------------------------------------------------
  4025.   # ● Refresh Interpreter Effect
  4026.   #--------------------------------------------------------------------------        
  4027.   def refresh_interpreter_effect
  4028.       $game_system.old_interpreter_running = $game_map.interpreter.running?
  4029.       if $game_system.old_interpreter_running
  4030.          $game_temp.reset_battler_time = 60 * 4
  4031.       end  
  4032.       reset_battler_setting  
  4033.   end  
  4034.  
  4035.   #--------------------------------------------------------------------------
  4036.   # ● Update Battler Setting Time
  4037.   #--------------------------------------------------------------------------          
  4038.   def update_reset_battler_setting_time
  4039.       return if $game_temp.reset_battler_time == 0
  4040.       $game_temp.reset_battler_time -= 1
  4041.       reset_battler_setting_running if $game_temp.reset_battler_time == 0
  4042.   end
  4043.  
  4044.   #--------------------------------------------------------------------------
  4045.   # ● Update Battler Setting
  4046.   #--------------------------------------------------------------------------        
  4047.   def reset_battler_setting
  4048.       reset_player_parameters
  4049.       for ally in $game_party.members
  4050.          reset_members_parameters(ally)
  4051.       end
  4052.       for enemy in $game_map.events.values
  4053.           reset_enemies_parameters(enemy) if enemy.battler != nil
  4054.       end    
  4055.       $game_map.need_refresh = true  
  4056.   end  
  4057.  
  4058.   #--------------------------------------------------------------------------
  4059.   # ● Update Battler Setting Running
  4060.   #--------------------------------------------------------------------------        
  4061.   def reset_battler_setting_running
  4062.       reset_player_parameters_running
  4063.       for ally in $game_party.members
  4064.          reset_members_parameters_running(ally)
  4065.       end
  4066.       for enemy in $game_map.events.values
  4067.           reset_enemies_parameters(enemy) if enemy.battler != nil
  4068.       end    
  4069.       $game_map.need_refresh = true  
  4070.   end    
  4071.  
  4072.   #--------------------------------------------------------------------------
  4073.   # ● Reset Enemies Parameters
  4074.   #--------------------------------------------------------------------------          
  4075.   def reset_enemies_parameters(enemy)
  4076.       enemy.battler.cast_action[0] = 0
  4077.       enemy.battler.cast_action[1] = 0
  4078.       enemy.battler.cast_action[2] = 0
  4079.       enemy.battler.cast_action[3] = 0  
  4080.       enemy.battler.cast_action[4] = 0
  4081.       enemy.battler.counter_action[0] = 0
  4082.       enemy.battler.counter_action[1] = 0
  4083.       enemy.battler.counter_action[2] = true
  4084.       enemy.battler.invunerable_duration = 0
  4085.       enemy.knock_back_duration = nil
  4086.   end  
  4087.  
  4088.   #--------------------------------------------------------------------------
  4089.   # ● Reset Members Parameters
  4090.   #--------------------------------------------------------------------------          
  4091.   def reset_members_parameters(ally)
  4092.       ally.old_level = ally.level
  4093.       ally.shield = false
  4094.       ally.x_charge_action[0] = 0
  4095.       ally.x_charge_action[1] = 0
  4096.       ally.x_charge_action[2] = 0
  4097.       ally.x_charge_action[3] = 0
  4098.       ally.cast_action[0] = 0
  4099.       ally.cast_action[1] = 0
  4100.       ally.cast_action[2] = 0
  4101.       ally.cast_action[3] = 0  
  4102.       ally.cast_action[4] = 0
  4103.       ally.counter_action[0] = 0
  4104.       ally.counter_action[1] = 0
  4105.       ally.counter_action[2] = true
  4106.       ally.invunerable_duration = 0
  4107.   end
  4108.  
  4109.   #--------------------------------------------------------------------------
  4110.   # ● Reset Player Parameters
  4111.   #--------------------------------------------------------------------------          
  4112.   def reset_player_parameters
  4113.       make_pose("", 1) unless $game_player.action != nil
  4114.       $game_temp.xas_target_time = 0
  4115.       $game_temp.xas_target_shoot_id = 0
  4116.       $game_temp.xas_target_x = 0      
  4117.       @knock_back_duration = nil
  4118.       @dash_active = false
  4119.   end
  4120.    
  4121.  
  4122.   #--------------------------------------------------------------------------
  4123.   # ● Reset Members Parameters Running
  4124.   #--------------------------------------------------------------------------          
  4125.   def reset_members_parameters_running(ally)
  4126.       ally.old_level = ally.level
  4127.       ally.shield = false
  4128.       unless ally.x_charge_action[1] > 0
  4129.       ally.x_charge_action[0] = 0
  4130.       ally.x_charge_action[1] = 0
  4131.       ally.x_charge_action[2] = 0
  4132.       ally.x_charge_action[3] = 0
  4133.       end
  4134.       unless ally.cast_action[1] > 0
  4135.          ally.cast_action[0] = 0
  4136.          ally.cast_action[1] = 0
  4137.          ally.cast_action[2] = 0
  4138.          ally.cast_action[3] = 0  
  4139.          ally.cast_action[4] = 0
  4140.       end
  4141.       ally.counter_action[0] = 0
  4142.       ally.counter_action[1] = 0
  4143.       ally.counter_action[2] = true
  4144.       ally.invunerable_duration = 0
  4145.   end
  4146.  
  4147.   #--------------------------------------------------------------------------
  4148.   # ● Reset Player Parameters Running
  4149.   #--------------------------------------------------------------------------          
  4150.   def reset_player_parameters_running
  4151.       $game_temp.xas_target_time = 0
  4152.       $game_temp.xas_target_shoot_id = 0
  4153.       $game_temp.xas_target_x = 0      
  4154.       @knock_back_duration = nil
  4155.       @dash_active = false
  4156.   end
  4157.  
  4158. end
  4159.  
  4160. #===============================================================================
  4161. # ■ Game Follower
  4162. #===============================================================================
  4163. class Game_Follower < Game_Character
  4164.   include XRXS_BattlerAttachment
  4165.  
  4166.   #--------------------------------------------------------------------------
  4167.   # ● Battler
  4168.   #--------------------------------------------------------------------------    
  4169.   def battler
  4170.       return $game_party.members[@member_index]
  4171.   end
  4172. end
  4173.  
  4174. #===============================================================================
  4175. # ■ Game Follower
  4176. #===============================================================================
  4177. class Game_Followers
  4178.   include XRXS_BattlerAttachment
  4179.  
  4180.   #--------------------------------------------------------------------------
  4181.   # ● Battler
  4182.   #--------------------------------------------------------------------------    
  4183.   def battler
  4184.       return $game_party.members[@member_index]
  4185.   end
  4186. end
  4187. #===============================================================================
  4188. # ■ Game_Vehicle
  4189. #===============================================================================
  4190. class Game_Vehicle < Game_Character
  4191.   include XRXS_BattlerAttachment
  4192.   attr_reader   :collision_attack
  4193.  
  4194.   #--------------------------------------------------------------------------
  4195.   # ● Battler
  4196.   #--------------------------------------------------------------------------      
  4197.   def battler
  4198.      return @battler
  4199.   end  
  4200. end  
  4201.  
  4202. #===============================================================================
  4203. # ■ Game Event
  4204. #===============================================================================
  4205. class Game_Event < Game_Character
  4206.  
  4207.   include XRXS_BattlerAttachment
  4208.  
  4209.   #--------------------------------------------------------------------------
  4210.   # ● Battler
  4211.   #--------------------------------------------------------------------------    
  4212.   def battler
  4213.     return @battler
  4214.   end
  4215.  
  4216.  #--------------------------------------------------------------------------
  4217.  # ● Battler?
  4218.  #--------------------------------------------------------------------------          
  4219.  def battler?
  4220.      return false if self.erased
  4221.      return false if self.battler == nil
  4222.      return false if self.dead?
  4223.      return false if self.battler.no_damage_pop
  4224.      return false if self.battler.invunerable
  4225.      return true
  4226.  end  
  4227.  
  4228.   #--------------------------------------------------------------------------
  4229.   # ● Refresh
  4230.   #--------------------------------------------------------------------------    
  4231.   alias xrxs64c_refresh refresh
  4232.   def refresh
  4233.       xrxs64c_refresh
  4234.       self.battler_recheck
  4235.   end
  4236.    
  4237.   #--------------------------------------------------------------------------
  4238.   # ● Battler Recheck
  4239.   #--------------------------------------------------------------------------    
  4240.   def battler_recheck
  4241.       return if @battler != nil
  4242.       return if @page == nil
  4243.       if self.name =~ /<Actor>/      
  4244.          actor = $game_party.members[0]
  4245.          @battler = Game_Actor.new(actor.id)
  4246.          return
  4247.       else
  4248.          @enemy_id = 0
  4249.          if self.name =~ /<Enemy(\d+)>/i
  4250.             @enemy_id = $1.to_i    
  4251.          end          
  4252.          return if @enemy_id <= 0
  4253.          @battler = Game_Enemy.new(1, @enemy_id)
  4254.          self.force_update = true if self.battler.sensor_range >= 15        
  4255.       end  
  4256.   end
  4257.    
  4258.   #--------------------------------------------------------------------------
  4259.   # ● Battler Recheck
  4260.   #--------------------------------------------------------------------------      
  4261.   def enemy_id
  4262.       return @enemy_id
  4263.   end
  4264.  
  4265.   #--------------------------------------------------------------------------
  4266.   # ● body_size
  4267.   #--------------------------------------------------------------------------        
  4268.   def body_size
  4269.       if self.battler != nil
  4270.          return self.battler.body_size
  4271.       else
  4272.          return 0
  4273.       end  
  4274.   end
  4275.  
  4276. end
  4277.  
  4278.  
  4279. #===============================================================================
  4280. # ■ Game_Battler
  4281. #===============================================================================
  4282. class Game_Battler
  4283.   attr_accessor :sensor_range
  4284.   attr_accessor :body_size
  4285.   attr_accessor :breath_effect
  4286.   attr_accessor :breath_duration
  4287.   attr_accessor :fast_breath_effect
  4288.   attr_accessor :no_knockback
  4289.   attr_accessor :passive  
  4290.   attr_accessor :attack_animation_id
  4291.   attr_accessor :ignore_guard
  4292.   attr_accessor :no_damage_pop
  4293.  
  4294.   #--------------------------------------------------------------------------
  4295.   # ● Initialize
  4296.   #--------------------------------------------------------------------------      
  4297.   alias x_e_initialize initialize
  4298.   def initialize  
  4299.       x_e_initialize
  4300.       @sensor_range = 4
  4301.       @body_size = 0
  4302.       @breath_effect = false
  4303.       @breath_duration = 0
  4304.       @fast_breath_effect = false
  4305.       @no_knockback = false
  4306.       @passive = false    
  4307.       @attack_animation_id = 0
  4308.       @ignore_guard = false
  4309.       @no_damage_pop = false
  4310.   end  
  4311. end
  4312.  
  4313. #===============================================================================
  4314. # ■ Game_Enemy
  4315. #===============================================================================
  4316. class Game_Enemy < Game_Battler
  4317.    
  4318.   #--------------------------------------------------------------------------
  4319.   # ● Initialize
  4320.   #--------------------------------------------------------------------------      
  4321.   alias x_e2_initialize initialize
  4322.   def initialize(index, enemy_id)
  4323.       x_e2_initialize(index, enemy_id)
  4324.       enemy = $data_enemies[@enemy_id]
  4325.       setup_enemy_note(enemy)
  4326.   end  
  4327.  
  4328.   #--------------------------------------------------------------------------
  4329.   # ● Setup X Note Elements
  4330.   #--------------------------------------------------------------------------          
  4331.   def setup_enemy_note(enemy)
  4332.       if enemy.note =~ /<Sensor Range = (\d+)>/
  4333.          @sensor_range = $1.to_i
  4334.       end  
  4335.       if enemy.note =~ /<Body Size = (\d+)>/
  4336.          @body_size = $1.to_i
  4337.       end
  4338.       if enemy.note =~ /<Attack Animation = (\d+)>/
  4339.          @attack_animation_id = $1.to_i
  4340.       end  
  4341.       if enemy.note =~ /<Death Zoom = (\d+)>/
  4342.          @death_zoom_effect = $1.to_i
  4343.       end
  4344.       if enemy.note =~ /<Knockback Duration = (\d+)>/
  4345.          @knockback_duration = $1.to_i
  4346.       end      
  4347.       if enemy.note =~ /<Ignore Guard>/
  4348.          @ignore_shield = true
  4349.       end
  4350.       if enemy.note =~ /<Invunerable>/
  4351.          @invunerable = true
  4352.       end
  4353.       if enemy.note =~ /<Breath Effect>/  
  4354.          @breath_effect = true
  4355.       end
  4356.       if enemy.note =~ /<Knockback Disable>/        
  4357.          @no_knockback = true
  4358.       end
  4359.       if enemy.note =~ /<Passive>/  
  4360.          @passive = true
  4361.       end
  4362.       if enemy.note =~ /<No Damage Pop>/  
  4363.          @no_damage_pop = true
  4364.       end  
  4365.       invunerable_actions_ids = XAS_BA_ENEMY::INVUNERABLE_ACTIONS[@enemy_id]
  4366.       if invunerable_actions_ids != nil
  4367.          @invunerable_actions = invunerable_actions_ids
  4368.       end  
  4369.       guard_directions_ids = XAS_BA_ENEMY::GUARD_DIRECTIONS[@enemy_id]
  4370.       if guard_directions_ids != nil
  4371.          @guard_directions = guard_directions_ids
  4372.       end          
  4373.   end
  4374.  
  4375.  
  4376. end  
  4377.  
  4378.  
  4379. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  4380. #■ BATTLER - EVENT SENSOR
  4381. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  4382.  
  4383.  
  4384. #===============================================================================
  4385. # ■ XRXS_Enemy_Sensor
  4386. #===============================================================================
  4387. module XRXS_EnemySensor
  4388.  
  4389.   #--------------------------------------------------------------------------
  4390.   # ● Update Sensor
  4391.   #--------------------------------------------------------------------------        
  4392.   def update_sensor
  4393.       if self.battler != nil and self.battler.sensor_range > 0  
  4394.          sensor_area = self.battler.sensor_range
  4395.       else  
  4396.          sensor_area = $game_variables[XAS_BA::DEFAULT_SENSOR_RANGE_VARIABLE_ID]
  4397.       end
  4398.       sensor_area = -1 if cancel_sensor?
  4399.       distance = ($game_player.x - self.x).abs + ($game_player.y - self.y).abs
  4400.       enable   = (distance <= sensor_area)
  4401.       key = [$game_map.map_id, self.id, XAS_BA::SENSOR_SELF_SWITCH]
  4402.       last_enable = $game_self_switches[key]
  4403.       last_enable = false if last_enable == nil
  4404.       if enable != last_enable
  4405.          touch_attack(false)
  4406.          @collision_attack = false
  4407.          @pattern = 0
  4408.          @pattern_count = 0              
  4409.          $game_self_switches[key] = enable
  4410.          self.refresh
  4411.       end
  4412.   end
  4413.  
  4414.   #--------------------------------------------------------------------------
  4415.   # ● Can Update Sensor
  4416.   #--------------------------------------------------------------------------            
  4417.   def can_update_sensor?
  4418.       return false if @sensor_enable == false
  4419.       return false if self.dead?
  4420.       return false if self.erased
  4421.       return false if self.stop
  4422.       return false if self.knockbacking?
  4423.       return true
  4424.   end
  4425.  
  4426.   #--------------------------------------------------------------------------
  4427.   # ● refresh_sensor
  4428.   #--------------------------------------------------------------------------          
  4429.   def refresh_sensor
  4430.       touch_attack(false)
  4431.       key = [$game_map.map_id, self.id, XAS_BA::SENSOR_SELF_SWITCH]
  4432.       $game_self_switches[key] = false
  4433.       @pattern = 0
  4434.       @pattern_count  = 0        
  4435.       self.refresh        
  4436.   end  
  4437.  
  4438.   #--------------------------------------------------------------------------
  4439.   # ● Cancel Sensor
  4440.   #--------------------------------------------------------------------------          
  4441.   def cancel_sensor?  
  4442.       return false if self.battler == nil
  4443.       return true if self.battler.passive
  4444.       return false
  4445.   end
  4446.  
  4447. end
  4448.  
  4449. #===============================================================================
  4450. # ■  Game Event
  4451. #===============================================================================
  4452. class Game_Event < Game_Character
  4453.  
  4454.   attr_accessor :sensor_enable
  4455.  
  4456.   #--------------------------------------------------------------------------
  4457.   # ● Initialize
  4458.   #--------------------------------------------------------------------------            
  4459.   alias x_sensor_initialize initialize
  4460.   def initialize(map_id, event)
  4461.       @sensor_enable = false
  4462.       x_sensor_initialize(map_id, event)
  4463.   end  
  4464.  
  4465.   #--------------------------------------------------------------------------
  4466.   # ● Conditions Met
  4467.   #--------------------------------------------------------------------------
  4468.   alias x_sensor_conditions_met conditions_met?
  4469.   def conditions_met?(page)
  4470.       c = page.condition
  4471.       if c.self_switch_ch == XAS_BA::SENSOR_SELF_SWITCH
  4472.          @sensor_enable = true
  4473.       end
  4474.       x_sensor_conditions_met(page)    
  4475.   end
  4476. end
  4477.  
  4478. #===============================================================================
  4479. # ■  Game Event
  4480. #===============================================================================
  4481. class Game_Character < Game_CharacterBase
  4482.       include XRXS_EnemySensor
  4483. end
  4484.  
  4485. #===============================================================================
  4486. # ■  Game Character
  4487. #===============================================================================
  4488. class Game_Character < Game_CharacterBase
  4489.       attr_writer   :opacity
  4490. end
  4491.  
  4492.  
  4493.  
  4494. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  4495. #■ BATTLER - ACTION
  4496. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  4497.  
  4498.  
  4499. #===============================================================================
  4500. # ■ Game Character
  4501. #==============================================================================
  4502. class Game_Character < Game_CharacterBase
  4503.  
  4504.   #--------------------------------------------------------------------------
  4505.   # ● Can Update Battler Move Speed
  4506.   #--------------------------------------------------------------------------                  
  4507.   def can_update_battler_move_speed?
  4508.       return false if @temp_id > 0
  4509.       return false if moving?    
  4510.       return true
  4511.   end  
  4512.  
  4513.   #--------------------------------------------------------------------------
  4514.   # ● Can Update Battler?
  4515.   #--------------------------------------------------------------------------                
  4516.   def can_update_battler?
  4517.       return false unless $game_system.xas_battle
  4518.       return false if self.battler == nil
  4519.       return false unless party_system?
  4520.       return true
  4521.   end  
  4522.  
  4523.   #--------------------------------------------------------------------------
  4524.   # ● Party System
  4525.   #--------------------------------------------------------------------------                  
  4526.   def party_system?
  4527.       return false if self.battler == nil
  4528.       if $xas_party_system == nil and self.battler.is_a?(Game_Actor)
  4529.          return false if self.battler.actor_id != $game_party.members[0].actor_id
  4530.       end
  4531.       return true
  4532.   end
  4533.  
  4534.   #--------------------------------------------------------------------------
  4535.   # ● Reset Battler Temp
  4536.   #--------------------------------------------------------------------------                  
  4537.   def reset_battler_temp
  4538.       reset_cast_temp  
  4539.       reset_charge_temp
  4540.   end  
  4541.  
  4542.   #--------------------------------------------------------------------------
  4543.   # ● Reset Charge Temp
  4544.   #--------------------------------------------------------------------------                    
  4545.   def reset_charge_temp  
  4546.       return if self.battler == nil
  4547.       return if self.battler.is_a?(Game_Enemy)
  4548.       self.battler.x_charge_action[0] = 0
  4549.       self.battler.x_charge_action[1] = 0
  4550.       self.battler.x_charge_action[2] = 0
  4551.       self.battler.x_charge_action[3] = 0
  4552.   end
  4553.  
  4554.   #--------------------------------------------------------------------------
  4555.   # ● Reset Battler Temp
  4556.   #--------------------------------------------------------------------------                    
  4557.   def reset_cast_temp  
  4558.       return if self.battler == nil
  4559.       self.battler.cast_action[0] = 0
  4560.       self.battler.cast_action[1] = 0
  4561.       self.battler.cast_action[2] = 0
  4562.       self.battler.cast_action[3] = 0  
  4563.       self.battler.cast_action[4] = 0
  4564.   end
  4565.    
  4566.   #--------------------------------------------------------------------------
  4567.   # ● update_battler_parameters
  4568.   #--------------------------------------------------------------------------    
  4569.   def update_battler_parameters
  4570.       @stop_count = -1 if can_stop_battler?
  4571.       self.battler.invunerable_duration -= 1 if self.battler.invunerable_duration > 0
  4572.       unless @stop
  4573.          @knock_back_duration = 30 if @temp_id > 0
  4574.       end  
  4575.   end    
  4576.  
  4577.   #--------------------------------------------------------------------------
  4578.   # ● Can Stop Battler
  4579.   #--------------------------------------------------------------------------      
  4580.   def can_stop_battler?
  4581.       return false if self.is_a?(Game_Player)
  4582.       return true if self.knockbacking?
  4583.       return true if self.dead?
  4584.       return true if self.stop
  4585.       return false
  4586.   end
  4587.  
  4588.   #--------------------------------------------------------------------------
  4589.   # ● Update Battler Counter Action
  4590.   #--------------------------------------------------------------------------                    
  4591.   def update_battler_counter_action
  4592.       return if self.battler.counter_action[1] == 0
  4593.       self.battler.counter_action[1] -= 1
  4594.       if self.battler.counter_action[1] == 0
  4595.          turn_toward_player
  4596.          self.battler.damage = XAS_WORD::COUNTER
  4597.          self.battler.damage_pop = true
  4598.          self.shoot(self.battler.counter_action[0])
  4599.          self.battler.counter_action[0] = 0
  4600.       end  
  4601.   end  
  4602.  
  4603.   #--------------------------------------------------------------------------
  4604.   # ● Update Cast Action
  4605.   #--------------------------------------------------------------------------          
  4606.   def update_battler_cast_action    
  4607.       return unless can_update_cast_action?
  4608.       self.battler.cast_action[3] += 1
  4609.       if self.battler.cast_action[3] > XAS_ANIMATION::LOOP_ANIMATIONS_SPEED
  4610.          self.battler.cast_action[3] = 0
  4611.          self.animation_id =  self.battler.cast_action[2]
  4612.       end  
  4613.       self.battler.cast_action[4] += 1
  4614.       if self.battler.cast_action[4] >= self.battler.cast_action[1]
  4615.           self.shoot(self.battler.cast_action[0])
  4616.       end
  4617.   end  
  4618.  
  4619.   #--------------------------------------------------------------------------
  4620.   # ● Can Update Cast Action
  4621.   #--------------------------------------------------------------------------            
  4622.   def can_update_cast_action?
  4623.       return false if self.battler.cast_action[1] == 0    
  4624.       return false if @stop
  4625.       return true
  4626.   end
  4627.  
  4628.   #--------------------------------------------------------------------------
  4629.   # ● Can Blow Effect
  4630.   #--------------------------------------------------------------------------              
  4631.   def can_blow?
  4632.       return false if self.stop and not self.battler.state_sleep
  4633.       return false if self.battler.no_knockback    
  4634.       return false if self.is_a?(Game_Player) and self.action != nil
  4635.       return true
  4636.   end  
  4637.    
  4638.   #--------------------------------------------------------------------------
  4639.   # ● Blow Effect
  4640.   #--------------------------------------------------------------------------        
  4641.   def blow(d, power = 1)
  4642.       return unless can_blow?
  4643.       jump(0,0)
  4644.       self.battler.invunerable_duration = 30 if self.battler.invunerable_duration <= 0
  4645.       if self.is_a?(Game_Event)
  4646.          @collision_attack = false  
  4647.       end
  4648.       @knock_back_duration = self.battler.knockback_duration
  4649.       refresh_sensor if self.is_a?(Game_Event)
  4650.       pre_direction = self.direction
  4651.       pre_direction_fix = self.direction_fix
  4652.       self.turn_reverse(d)      
  4653.       self.direction_fix = true
  4654.       power.times do
  4655.         case d
  4656.            when 2; @y += 1 if passable?(@x, @y, d)
  4657.            when 4; @x -= 1 if passable?(@x, @y, d)
  4658.            when 6; @x += 1 if passable?(@x, @y, d)
  4659.            when 8; @y -= 1 if passable?(@x, @y, d)
  4660.         end
  4661.       end
  4662.       self.direction_fix = pre_direction_fix
  4663.       self.direction = pre_direction
  4664.   end
  4665.  
  4666.   #--------------------------------------------------------------------------
  4667.   # ● Can Stop Battler Movement
  4668.   #--------------------------------------------------------------------------            
  4669.   def can_stop_battler_movement?
  4670.       return false if self.dead?  
  4671.       return true if self.battler.state_sleep
  4672.       return true if self.battler.state_stop
  4673.       return false
  4674.   end  
  4675.  
  4676.   #--------------------------------------------------------------------------
  4677.   # ● Impact
  4678.   #--------------------------------------------------------------------------              
  4679.   def impact(enable = true)
  4680.       return if self.tool_id == 0
  4681.       return if self.action == nil
  4682.       self.action.impact = enable
  4683.   end
  4684.  
  4685.   #--------------------------------------------------------------------------
  4686.   # ● Update Battler Stop Movement
  4687.   #--------------------------------------------------------------------------              
  4688.   def update_battler_stop_movement
  4689.       unless can_stop_battler_movement?
  4690.           @stop = false  
  4691.           return
  4692.       end
  4693.       @knock_back_duration = nil
  4694.       @stop = true      
  4695.       @step_anime = false    
  4696.       reset_battler_temp
  4697.       if self.battler.state_sleep
  4698.          make_pose("_Hit", 2)  
  4699.       else
  4700.          make_pose("", 2)
  4701.       end  
  4702.       if self.is_a?(Game_Event)
  4703.          @collision_attack = false
  4704.       end  
  4705.   end
  4706.    
  4707.   #--------------------------------------------------------------------------
  4708.   # ● Update Attacking
  4709.   #--------------------------------------------------------------------------              
  4710.   def update_battler_attacking
  4711.       return unless can_update_attacking?
  4712.       make_pose("_Atk", 2)
  4713.   end
  4714.  
  4715.   #--------------------------------------------------------------------------
  4716.   # ● Can Update Attacking
  4717.   #--------------------------------------------------------------------------              
  4718.   def can_update_attacking?
  4719.       return false if self.battler.is_a?(Game_Actor)
  4720.       return false if @collision_attack == false  
  4721.       return true
  4722.   end  
  4723.  
  4724.   #--------------------------------------------------------------------------
  4725.   # ● Update Battler Knobacking
  4726.   #--------------------------------------------------------------------------            
  4727.   def update_battler_knockbacking
  4728.        return unless self.knockbacking?
  4729.        @pattern = 0
  4730.        @knock_back_duration -= 1 if can_remove_knockback?
  4731.        make_pose("_Hit", 2)        
  4732.        if self.is_a?(Game_Event)
  4733.           @collision_attack = false
  4734.        end        
  4735.        if @knock_back_duration <= 0
  4736.           @knock_back_duration = nil
  4737.           make_pose("", 0)
  4738.           touch_attack(false) if self.is_a?(Game_Event)
  4739.           @character_name = @x_pose_original_name
  4740.        end
  4741.   end  
  4742.    
  4743.   #--------------------------------------------------------------------------
  4744.   # ● Can Remove Knockback
  4745.   #--------------------------------------------------------------------------              
  4746.   def can_remove_knockback?
  4747.       return true
  4748.   end
  4749.  
  4750.   #--------------------------------------------------------------------------
  4751.   # ● knockbacking?
  4752.   #--------------------------------------------------------------------------            
  4753.   def knockbacking?
  4754.       return false if self.battler == nil
  4755.       return false if @stop
  4756.       return true if @knock_back_duration != nil
  4757.       return false
  4758.   end
  4759.  
  4760.   #--------------------------------------------------------------------------
  4761.   # ● collapsing?
  4762.   #--------------------------------------------------------------------------          
  4763.   def collapsing?
  4764.       return self.collapse_duration.to_i > 0
  4765.   end
  4766.    
  4767.   #--------------------------------------------------------------------------
  4768.   # ● Seal Effect
  4769.   #--------------------------------------------------------------------------          
  4770.   def seal_effect
  4771.       Sound.play_buzzer
  4772.       if XAS_WORD::ENABLE_WORD
  4773.          self.battler.damage = XAS_WORD::SEAL
  4774.          self.battler.damage_pop = true
  4775.       end  
  4776.   end    
  4777.  
  4778. end
  4779.  
  4780. #===============================================================================
  4781. # ■ XAS_DamageStop
  4782. #===============================================================================
  4783. module XAS_DamageStop
  4784.  
  4785.   #--------------------------------------------------------------------------
  4786.   # ● Acting
  4787.   #--------------------------------------------------------------------------            
  4788.   def acting?
  4789.       return (super or self.knockbacking? or self.collapsing? or self.stop)
  4790.   end
  4791. end
  4792.  
  4793. #===============================================================================
  4794. # ■ Game_Player
  4795. #===============================================================================
  4796. class Game_Player < Game_Character
  4797.       include XAS_DamageStop
  4798. end
  4799.  
  4800. #===============================================================================
  4801. # ■ Game_Event
  4802. #===============================================================================
  4803. class Game_Event < Game_Character
  4804.       include XAS_DamageStop
  4805. end
  4806.  
  4807.  
  4808.  
  4809. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  4810. #■ BATTLER - TOUCH EFFECT
  4811. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  4812.  
  4813.  
  4814. #===============================================================================
  4815. # ■ XRXS_BattlerAttachment
  4816. #==============================================================================
  4817. module XRXS_BattlerAttachment
  4818.  
  4819.   #--------------------------------------------------------------------------
  4820.   # ● Attack Effect
  4821.   #--------------------------------------------------------------------------    
  4822.   def attack_effect(attacker)
  4823.       return false unless $game_system.xas_battle    
  4824.       return if self.battler == nil or attacker == nil
  4825.       return unless can_attack_effect?(attacker)
  4826.       if target_shield_enabled?(attacker, nil, nil)
  4827.          execute_guard_effect(attacker, nil, nil, 30)
  4828.          return
  4829.       end  
  4830.       execute_attack_effect(attacker)
  4831.  end
  4832.    
  4833.  #--------------------------------------------------------------------------
  4834.  # ● Can Attack Effect
  4835.  #--------------------------------------------------------------------------    
  4836.  def can_attack_effect?(attacker)
  4837.      return false if self.can_update == false
  4838.      return false if @knock_back_duration != nil
  4839.      return false if attacker.stop
  4840.      return false if self.battler.invunerable
  4841.      return false if self.battler.invunerable_duration > 0
  4842.      return false if self.action != nil and self.action.user_invincible
  4843.      return false if seal_attack?(attacker.battler)    
  4844.      return false if target_state_invunerable?(30)
  4845.      return true
  4846.  end  
  4847.  
  4848.  #--------------------------------------------------------------------------
  4849.  # ● Attack Target Shield
  4850.  #--------------------------------------------------------------------------    
  4851.  def attack_target_shield?(attacker)
  4852.      return false if attacker.battler.ignore_shield  
  4853.      return false unless self.battler.shield
  4854.      return true if face_direction?(attacker)
  4855.      return false
  4856.  end  
  4857.  
  4858.  #--------------------------------------------------------------------------
  4859.  # ● Seal Attack?
  4860.  #--------------------------------------------------------------------------              
  4861.  def seal_attack?(attacker)
  4862.      if attacker.state_seal_attack or attacker.state_mute
  4863.         attacker.damage = XAS_WORD::SEAL
  4864.         attacker.damage_pop = true
  4865.         self.battler.invunerable_duration = 30
  4866.         return true
  4867.      end
  4868.      return false
  4869.  end  
  4870.  
  4871.  #--------------------------------------------------------------------------
  4872.  # ● Execute Attack Damage
  4873.  #--------------------------------------------------------------------------      
  4874.  def execute_attack_damage(attacker)
  4875.      #if self.battler.agi > (rand(attacker.battler.agi) * 2)
  4876.      #   self.battler.result.missed = true
  4877.      #   return
  4878.      #end
  4879.      damage = ((attacker.battler.atk * 4) - (self.battler.def * 2)).truncate
  4880.      damage = 0 if damage < 0
  4881.      self.battler.result.hp_damage = damage
  4882.      #self.battler.result.critical  
  4883.      self.battler.hp -= damage.abs
  4884.  end
  4885.  
  4886.  #--------------------------------------------------------------------------
  4887.  # ● Execute Attack Effect
  4888.  #--------------------------------------------------------------------------      
  4889.  def execute_attack_effect(attacker)
  4890.      execute_attack_effect_before_damage(attacker)
  4891.      execute_attack_damage(attacker)
  4892.      if target_missed?(attacker)
  4893.         self.battler.invunerable_duration = 30
  4894.         return
  4895.      end
  4896.      execute_damage_pop(attacker)
  4897.      execute_attack_effect_after_damage(attacker) if can_check_after_attack_effect?(attacker)  
  4898.      execute_state_effect(nil, attacker, nil)    
  4899.      self.battler.invunerable_duration = 20 + XAS_BA::DEFAULT_KNOCK_BACK_DURATION
  4900.      if attacker.battler.attack_animation_id != 0
  4901.         self.animation_id = attacker.battler.attack_animation_id
  4902.      end  
  4903.      if self.battler.damage.to_i > 0
  4904.         self.blow(attacker.direction, 1) if can_blow_effect?
  4905.      end
  4906.      if self.is_a?(Game_Player)
  4907.         self.need_refresh = true
  4908.      end
  4909.  end  
  4910.      
  4911.  #--------------------------------------------------------------------------
  4912.  # ● Can Check After Attack Effect?  
  4913.  #--------------------------------------------------------------------------        
  4914.  def can_check_after_attack_effect?(attacker)  
  4915.      return false unless self.battler.damage.is_a?(Numeric)
  4916.      return true
  4917.  end
  4918.  
  4919.  #--------------------------------------------------------------------------
  4920.  # ● Execute Attack Effect Before Damage
  4921.  #--------------------------------------------------------------------------      
  4922.  def execute_attack_effect_before_damage(attacker)
  4923.  
  4924.  end
  4925.  
  4926.  #--------------------------------------------------------------------------
  4927.  # ● Execute Attack Effect After Damage
  4928.  #--------------------------------------------------------------------------      
  4929.  def execute_attack_effect_after_damage(attacker)
  4930.  
  4931.  end
  4932.  
  4933. end
  4934.  
  4935. #===============================================================================
  4936. # ■ Game Player
  4937. #===============================================================================
  4938. class Game_Player < Game_Character  
  4939.   #--------------------------------------------------------------------------
  4940.   # ● Check Event Trigger Touch
  4941.   #--------------------------------------------------------------------------            
  4942.   alias xrxs64c_check_event_trigger_touch check_event_trigger_touch
  4943.   def check_event_trigger_touch(x, y)
  4944.       xrxs64c_check_event_trigger_touch(x, y)
  4945.       if $game_map.interpreter.running?
  4946.          return
  4947.       end
  4948.       for event in $game_map.events.values
  4949.           next unless event.collision_attack
  4950.           unless [1,2].include?(event.trigger)
  4951.              if event.battler != nil and event.x == x and event.y == y
  4952.                 $game_player.attack_effect(event)
  4953.              end
  4954.           end
  4955.       end
  4956.   end
  4957. end
  4958.  
  4959. #===============================================================================
  4960. # ■ Game Event
  4961. #===============================================================================
  4962. class Game_Event < Game_Character
  4963.  
  4964.   #--------------------------------------------------------------------------
  4965.   # ● Check Event Trigger Touch
  4966.   #--------------------------------------------------------------------------            
  4967.   alias xrxs64c_check_event_trigger_touch check_event_trigger_touch
  4968.   def check_event_trigger_touch(x, y)
  4969.     xrxs64c_check_event_trigger_touch(x, y)
  4970.     if $game_map.interpreter.running?
  4971.        return
  4972.     end
  4973.     return unless self.collision_attack
  4974.     if self.battler != nil and x == $game_player.x and y == $game_player.y
  4975.        $game_player.attack_effect(self)
  4976.     end
  4977.   end
  4978. end
  4979.  
  4980.  
  4981.  
  4982. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  4983. #■ BATTLER - MOVE SPEED
  4984. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  4985.  
  4986.  
  4987. #==============================================================================
  4988. # ■ Game_Character
  4989. #==============================================================================
  4990. class Game_Character < Game_CharacterBase
  4991.  
  4992.   include XAS_BA
  4993.   attr_accessor :base_move_speed
  4994.   attr_accessor :dash_move_speed
  4995.   attr_accessor :move_speed
  4996.  
  4997.  #--------------------------------------------------------------------------
  4998.  # ● Initialize
  4999.  #--------------------------------------------------------------------------  
  5000.   alias x_move_speed_initialize initialize
  5001.   def initialize
  5002.       @base_move_speed = BASE_MOVE_SPEED
  5003.       @dash_move_speed = 0
  5004.       x_move_speed_initialize
  5005.   end  
  5006.  
  5007.  #--------------------------------------------------------------------------
  5008.  # ● update_battler_move_speed
  5009.  #--------------------------------------------------------------------------
  5010.   def update_battler_move_speed
  5011.       @dash_move_speed = @dash_active ? DASH_MOVE_SPEED : 0
  5012.       sp1 = @base_move_speed
  5013.       sp2 = @dash_move_speed
  5014.       sp3 = self.battler.state_move_speed
  5015.       @move_speed = (sp1 + sp2 + sp3)
  5016.   end
  5017.  
  5018.  #--------------------------------------------------------------------------
  5019.  # ● Update Animation
  5020.  #--------------------------------------------------------------------------      
  5021.   def update_animation
  5022.       super
  5023.       update_force_move_routine_move
  5024.   end
  5025.    
  5026.  #--------------------------------------------------------------------------
  5027.  # ● Update Force Move Routine Move
  5028.  #--------------------------------------------------------------------------        
  5029.   def update_force_move_routine_move
  5030.       return if @force_action == ""
  5031.       return if @move_route == nil
  5032.       command = @move_route.list[@move_route_index]
  5033.       return if command == nil
  5034.       if command.code == ROUTE_PLAY_SE    
  5035.          params = command.parameters
  5036.          params[0].play
  5037.          advance_move_route_index
  5038.       end  
  5039.   end
  5040.  
  5041.  #--------------------------------------------------------------------------
  5042.  # ● Update Routine Move
  5043.  #--------------------------------------------------------------------------      
  5044.  alias x_update_routine_move update_routine_move
  5045.  def update_routine_move
  5046.      return if @force_action_times > 0
  5047.      x_update_routine_move
  5048.  end
  5049.  
  5050.  #--------------------------------------------------------------------------
  5051.  # ● Can Cancel Move Type Custom
  5052.  #--------------------------------------------------------------------------    
  5053.   alias x_move_speed_process_move_command process_move_command
  5054.   def process_move_command(command)
  5055.       return if can_cancel_move_type_custom?(command)
  5056.       params = command.parameters
  5057.       x_move_speed_process_move_command(command)
  5058.       if command.code == ROUTE_CHANGE_SPEED and @battler != nil and
  5059.          self.is_a?(Game_Event)
  5060.          @base_move_speed = params[0]
  5061.       end        
  5062.   end
  5063.  
  5064.  #--------------------------------------------------------------------------
  5065.  # ● Can Cancel Move Type Custom
  5066.  #--------------------------------------------------------------------------    
  5067.   def can_cancel_move_type_custom?(command)
  5068.       return true if command == nil
  5069.       return true if @force_action_times > 0
  5070.       return false
  5071.   end  
  5072.  
  5073. end  
  5074.  
  5075.  
  5076. #==============================================================================
  5077. # ■ Game_Event
  5078. #==============================================================================
  5079. class Game_Event < Game_Character  
  5080.  
  5081.  #--------------------------------------------------------------------------
  5082.  # ● Initialize
  5083.  #--------------------------------------------------------------------------              
  5084.  alias x_move_speed_event_initialize initialize
  5085.  def initialize(map_id, event)
  5086.      x_move_speed_event_initialize(map_id, event)
  5087.      refresh_move_speed
  5088.  end  
  5089.  
  5090.   #--------------------------------------------------------------------------
  5091.   # ● Refresh Move Speed
  5092.   #--------------------------------------------------------------------------
  5093.   def refresh_move_speed
  5094.       return if @page == nil
  5095.       @base_move_speed = @page.move_speed
  5096.   end
  5097.  
  5098.  #--------------------------------------------------------------------------
  5099.  # ● Setup Page
  5100.  #--------------------------------------------------------------------------              
  5101.  alias x_move_speed_setup_page setup_page
  5102.  def setup_page(new_page)
  5103.      x_move_speed_setup_page(new_page)
  5104.      refresh_move_speed
  5105.  end
  5106.  
  5107. end
  5108.  
  5109.  
  5110. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  5111. #■ BATTLER - STATES
  5112. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  5113.  
  5114.  
  5115. #==============================================================================
  5116. # ■ Game_Battler
  5117. #==============================================================================
  5118. class Game_Battler
  5119.  
  5120.   attr_accessor :state_move_speed
  5121.   attr_accessor :state_stop
  5122.   attr_accessor :state_loop_effect_time
  5123.   attr_accessor :state_loop_speed
  5124.   attr_accessor :state_duration
  5125.   attr_accessor :state_string
  5126.   attr_accessor :state_string_time
  5127.   attr_accessor :state_stop
  5128.   attr_accessor :state_slow
  5129.   attr_accessor :state_sleep
  5130.   attr_accessor :state_invunerable
  5131.   attr_accessor :state_fast
  5132.   attr_accessor :state_mute
  5133.   attr_accessor :state_seal_attack
  5134.   attr_accessor :state_seal_skill
  5135.   attr_accessor :state_seal_item
  5136.   attr_accessor :state_reflect
  5137.  
  5138.  #--------------------------------------------------------------------------
  5139.  # ● Initialize
  5140.  #--------------------------------------------------------------------------  
  5141.   alias x_state_initialize initialize
  5142.   def initialize
  5143.       @state_move_speed = 0
  5144.       @state_duration = []
  5145.       @state_loop_effect_time = []
  5146.       @state_loop_speed = []
  5147.       @state_string = ""
  5148.       @state_string_time = 0
  5149.       @state_stop = false
  5150.       @state_sleep = false
  5151.       @state_invunerable = false
  5152.       @state_slow = false
  5153.       @state_fast = false
  5154.       @state_mute = false
  5155.       @state_seal_attack = false
  5156.       @state_seal_skill = false
  5157.       @state_seal_item = false
  5158.       @state_reflect = false
  5159.       x_state_initialize
  5160.   end
  5161.    
  5162.  #--------------------------------------------------------------------------
  5163.  # ● Add State
  5164.  #--------------------------------------------------------------------------    
  5165.   alias x_add_state add_state
  5166.   def add_state(state_id)
  5167.       unless @states.include?(state_id)
  5168.           state = $data_states[state_id]
  5169.           xas_add_state(state)
  5170.       end        
  5171.       x_add_state(state_id)
  5172.   end
  5173.  
  5174.  #--------------------------------------------------------------------------
  5175.  # ● Xas Add State
  5176.  #--------------------------------------------------------------------------      
  5177.   def xas_add_state(state)
  5178.       @state_duration[state.id] = 60 * $data_states[state.id].min_turns
  5179.       @state_loop_effect_time[state.id] = 0
  5180.       @state_loop_speed[state.id] = $data_states[state.id].max_turns
  5181.       execute_damage_state(state,0)
  5182.   end      
  5183.  
  5184.  #--------------------------------------------------------------------------
  5185.  # ● Remove State
  5186.  #--------------------------------------------------------------------------        
  5187.   alias x_remove_state remove_state
  5188.   def remove_state(state_id)
  5189.       if state?(state_id)
  5190.          state = $data_states[state_id]
  5191.          xas_remove_state(state)
  5192.       end  
  5193.       x_remove_state(state_id)      
  5194.   end    
  5195.    
  5196.  #--------------------------------------------------------------------------
  5197.  # ● XAS Remove State
  5198.  #--------------------------------------------------------------------------        
  5199.   def xas_remove_state(state)
  5200.       @state_duration.delete(state.id)  
  5201.       @state_loop_effect_time.delete(state.id)  
  5202.       @state_loop_speed.delete(state.id)
  5203.       execute_damage_state(state,1)
  5204.   end  
  5205.  
  5206.  #--------------------------------------------------------------------------
  5207.  # ● Execute_Damage_State
  5208.  #--------------------------------------------------------------------------          
  5209.   def execute_damage_state(state,type)
  5210.       return unless XAS_DAMAGE_POP::DAMAGE_STATE_POP
  5211.       return unless XAS_WORD::ENABLE_WORD
  5212.       return if state == nil or state.id == 1
  5213.       case type
  5214.          when 0
  5215.              damage = "+ " + state.name.to_s
  5216.          when 1  
  5217.              damage = "- " + state.name.to_s
  5218.       end
  5219.       @state_string = damage
  5220.       @state_string_time = 30            
  5221.   end  
  5222.  
  5223. end
  5224.  
  5225. #==============================================================================
  5226. # ■ Game_Character
  5227. #==============================================================================
  5228. class Game_Character < Game_CharacterBase
  5229.  
  5230.  #--------------------------------------------------------------------------
  5231.  # ● Update Battler States Effect
  5232.  #--------------------------------------------------------------------------    
  5233.  def update_battler_states_effect
  5234.      return unless XAS_SYSTEM::STATE_SYSTEM
  5235.      update_state_string_pop
  5236.      update_pre_state_setup
  5237.      return unless can_update_states_effect?
  5238.      for i in self.battler.states
  5239.          state = $data_states[i.id]  
  5240.          if state == nil or self.battler.state_duration[state.id] == nil or
  5241.             self.battler.state_loop_effect_time[state.id] == nil or
  5242.             self.battler.state_loop_speed[state.id] == nil
  5243.             self.battler.remove_state(state.id)
  5244.             next
  5245.             return
  5246.          end  
  5247.          update_state_abs_effects(state)
  5248.          update_state_loop(state)
  5249.          update_remove_state(state)
  5250.      end  
  5251.        
  5252.  end  
  5253.  
  5254.  #--------------------------------------------------------------------------
  5255.  # ● Update Pre State Setup
  5256.  #--------------------------------------------------------------------------      
  5257.  def update_pre_state_setup
  5258.      self.battler.state_stop = false
  5259.      self.battler.state_slow = false
  5260.      self.battler.state_fast = false
  5261.      self.battler.state_mute = false
  5262.      self.battler.state_sleep = false
  5263.      self.battler.state_invunerable = false
  5264.      self.battler.state_seal_attack = false
  5265.      self.battler.state_seal_skill = false
  5266.      self.battler.state_seal_item = false
  5267.      self.battler.state_reflect = false
  5268.      self.battler.state_move_speed = 0
  5269.  end  
  5270.  
  5271.  #--------------------------------------------------------------------------
  5272.  # ● Update Pre State Setup
  5273.  #--------------------------------------------------------------------------        
  5274.  def update_state_abs_effects(state)
  5275.      if state.note =~ /<Stop>/
  5276.         self.battler.state_stop = true
  5277.      end
  5278.      if state.note =~ /<Slow>/
  5279.         self.battler.state_slow = true
  5280.         self.battler.state_move_speed = -1.5
  5281.      end  
  5282.      if state.note =~ /<Fast>/  
  5283.         self.battler.state_fast = true
  5284.         self.battler.state_move_speed = 1    
  5285.      end
  5286.      if self.battler.state_fast and
  5287.         self.battler.state_slow
  5288.         self.battler.state_move_speed = 0
  5289.      end
  5290.      if state.note =~ /<Mute>/  
  5291.         self.battler.state_mute = true
  5292.      end
  5293.      if state.note =~ /<Sleep>/  
  5294.         self.battler.state_sleep = true
  5295.      end
  5296.      if state.note =~ /<Invincible>/  
  5297.         self.battler.state_invunerable = true
  5298.      end  
  5299.      if state.note =~ /<Seal Attack>/  
  5300.         self.battler.state_seal_attack = true
  5301.      end
  5302.      if state.note =~ /<Seal Skill>/  
  5303.         self.battler.state_seal_skill = true
  5304.      end      
  5305.      if state.note =~ /<Seal Item>/  
  5306.         self.battler.state_seal_item = true
  5307.       end
  5308.      if state.note =~ /<Reflect>/
  5309.         self.battler.state_reflect = true
  5310.      end        
  5311.  end
  5312.  
  5313.  #--------------------------------------------------------------------------
  5314.  # ● Update State Loop
  5315.  #--------------------------------------------------------------------------      
  5316.  def update_state_loop(state)
  5317.      self.battler.state_loop_effect_time[state.id] += 1
  5318.      if self.battler.state_loop_effect_time[state.id] > self.battler.state_loop_speed[state.id]
  5319.         self.battler.state_loop_effect_time[state.id] = 0
  5320.         if state.note =~ /<Animation ID = (\d+)>/
  5321.            state_anime = $1.to_i
  5322.            if state_anime != nil
  5323.               self.animation_id = state_anime
  5324.            end
  5325.         end    
  5326.         execute_states_effects(state)          
  5327.      end          
  5328.  end
  5329.  
  5330.  #--------------------------------------------------------------------------
  5331.  # ● Execute States Effect
  5332.  #--------------------------------------------------------------------------      
  5333.  def execute_states_effects(state)        
  5334.      if state.note =~ /<Slip Damage = (\S+)>/
  5335.         execute_state_slip_damage($1.to_i)
  5336.      end  
  5337.  end
  5338.  
  5339.  #--------------------------------------------------------------------------
  5340.  # ● Execute States Slip Damage
  5341.  #--------------------------------------------------------------------------        
  5342.  def execute_state_slip_damage(damage)
  5343.      damage = 1 if damage == nil
  5344.      damage_slip = self.battler.mhp * damage / 100
  5345.      self.battler.hp -= damage_slip
  5346.      self.battler.damage = damage_slip
  5347.      self.battler.damage_pop = true
  5348.  end
  5349.  
  5350.  #--------------------------------------------------------------------------
  5351.  # ● Update Remove State
  5352.  #--------------------------------------------------------------------------      
  5353.  def update_remove_state(state)
  5354.      self.battler.state_duration[state.id] -= 1
  5355.      if self.battler.state_duration[state.id] <= 0    
  5356.         self.battler.remove_state(state.id)
  5357.      end          
  5358.  end
  5359.  
  5360.  #--------------------------------------------------------------------------
  5361.  # ● Can Update States Effect
  5362.  #--------------------------------------------------------------------------      
  5363.   def can_update_states_effect?
  5364.       return false if self.dead?
  5365.       return false if self.battler.states == nil
  5366.       return false if self.battler.states.size == 0
  5367.       return false if self.battler.state_duration == []
  5368.       return true
  5369.   end
  5370.  
  5371.  #--------------------------------------------------------------------------
  5372.  # ● Update State String Pop
  5373.  #--------------------------------------------------------------------------      
  5374.   def update_state_string_pop
  5375.       return false if self.battler.state_string_time == 0
  5376.       self.battler.state_string_time -= 1
  5377.       if self.battler.state_string_time == 0
  5378.          self.battler.damage = self.battler.state_string
  5379.          self.battler.damage_pop = true
  5380.          self.battler.state_string = ""
  5381.       end  
  5382.   end  
  5383. end  
  5384.  
  5385. #==============================================================================
  5386. # ■ Game_Party
  5387. #==============================================================================
  5388. class Game_Party < Game_Unit
  5389.  
  5390.  #--------------------------------------------------------------------------
  5391.  # ● On Player Walk
  5392.  #--------------------------------------------------------------------------        
  5393.  alias x_state_on_player_walk on_player_walk
  5394.  def on_player_walk
  5395.      return if XAS_SYSTEM::STATE_SYSTEM
  5396.      x_state_on_player_walk
  5397.  end
  5398.  
  5399. end
  5400.  
  5401.  
  5402.  
  5403. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  5404. #■ BATTLER - EVENT COMMANDS
  5405. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  5406.  
  5407.  
  5408. #===============================================================================
  5409. # ■ Game Event
  5410. #===============================================================================
  5411. class Game_Event < Game_Character
  5412.  
  5413.   #--------------------------------------------------------------------------
  5414.   # ● Shoot Chance
  5415.   #--------------------------------------------------------------------------            
  5416.   def shoot_chance(action_id,perc)
  5417.       return if self.battler == nil
  5418.       if perc >= rand(100)
  5419.          shoot(action_id)
  5420.       end  
  5421.   end  
  5422.  
  5423.   #--------------------------------------------------------------------------
  5424.   # ● Guard
  5425.   #--------------------------------------------------------------------------          
  5426.   def guard(enable)
  5427.       return if self.battler == nil
  5428.       self.battler.guard = enable
  5429.   end  
  5430.  
  5431.   #--------------------------------------------------------------------------
  5432.   # ● Touch Attack
  5433.   #--------------------------------------------------------------------------            
  5434.   def touch_attack(enable)
  5435.       return if self.battler == nil        
  5436.       return if seal_attack?(self.battler)
  5437.       @collision_attack = enable
  5438.       @pattern = 0
  5439.       @pattern_count  = 0      
  5440.   end
  5441.  
  5442.   #--------------------------------------------------------------------------
  5443.   # ● Counter
  5444.   #--------------------------------------------------------------------------            
  5445.   def counter(enable)
  5446.       return if self.battler == nil
  5447.       self.battler.counter_action[2] = enable
  5448.   end    
  5449.  
  5450.   #--------------------------------------------------------------------------
  5451.   # ● Rand Shoot
  5452.   #--------------------------------------------------------------------------            
  5453.   def rand_shoot(random_id = [])
  5454.       return if self.battler == nil
  5455.       return if random_id == []
  5456.       action_id = random_id[rand(random_id.size)]
  5457.       self.shoot(action_id)
  5458.   end      
  5459.  
  5460. end
  5461.  
  5462.  
  5463.  
  5464. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  5465. #■ BATTLER - DEFEAT PROCESS
  5466. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  5467.  
  5468. #===============================================================================
  5469. # ■ Scene Base
  5470. #===============================================================================
  5471. class Scene_Base  
  5472.  
  5473.   #--------------------------------------------------------------------------
  5474.   # ● Check Gameover
  5475.   #--------------------------------------------------------------------------              
  5476.   def check_gameover
  5477.       return unless $game_party.in_battle  
  5478.       SceneManager.goto(Scene_Gameover) if $game_party.all_dead?
  5479.   end
  5480. end  
  5481.  
  5482. #===============================================================================
  5483. # ■ Game Character
  5484. #===============================================================================
  5485. class Game_Character < Game_CharacterBase
  5486.   attr_accessor :collapse_duration
  5487.   attr_accessor :battler_visible
  5488.   attr_writer   :opacity
  5489.  
  5490.   #--------------------------------------------------------------------------
  5491.   # ● Initialize
  5492.   #--------------------------------------------------------------------------            
  5493.   alias x_collapse_initialize initialize
  5494.   def initialize
  5495.       @collapse_duration = 0
  5496.       x_collapse_initialize
  5497.   end  
  5498.  
  5499. end
  5500.  
  5501. #===============================================================================
  5502. # ■ XAS_BA_BATTLEEVENT_NONPREEMPT
  5503. #==============================================================================
  5504. module XAS_BA_BATTLEEVENT_NONPREEMPT
  5505.  
  5506.   #--------------------------------------------------------------------------
  5507.   # ● Update
  5508.   #--------------------------------------------------------------------------            
  5509.   def update
  5510.       return if self.battler != nil and $game_map.interpreter.running?
  5511.       super
  5512.   end
  5513. end
  5514.  
  5515. #===============================================================================
  5516. # ■ Game Event
  5517. #==============================================================================
  5518. class Game_Event < Game_Character
  5519.       include XAS_BA_BATTLEEVENT_NONPREEMPT
  5520. end
  5521.  
  5522. #===============================================================================
  5523. # ■ Game Character
  5524. #===============================================================================
  5525. class Game_Character < Game_CharacterBase
  5526.  
  5527.   #--------------------------------------------------------------------------
  5528.   # ● Update Battler Defeat Process
  5529.   #--------------------------------------------------------------------------      
  5530.    def update_battler_defeat_process
  5531.        execute_enemy_defeated_process if can_check_enemy_defeated?
  5532.        execute_actor_defeated_process if can_check_actor_defeated?
  5533.    end
  5534.    
  5535.   #--------------------------------------------------------------------------
  5536.   # ● Can Check Enemy Defeated?
  5537.   #--------------------------------------------------------------------------            
  5538.   def can_check_enemy_defeated?  
  5539.       return false if self.battler.is_a?(Game_Actor)
  5540.       return false if self.battler.defeated
  5541.       return true
  5542.   end    
  5543.  
  5544.   #--------------------------------------------------------------------------
  5545.   # ● Can Check Actor Defeated?
  5546.   #--------------------------------------------------------------------------              
  5547.   def can_check_actor_defeated?
  5548.       return false if self.battler.is_a?(Game_Enemy)
  5549.       return false if self.battler.defeated
  5550.       return false if $game_party.members[0].hp > 0
  5551.       return false if @collapse_duration > 0
  5552.       return true  
  5553.   end
  5554.  
  5555.   #--------------------------------------------------------------------------
  5556.   # ● Execute Actor Defeated Process
  5557.   #--------------------------------------------------------------------------                
  5558.   def execute_actor_defeated_process
  5559.       erase_actor_tools_on_map
  5560.       if $game_party.all_dead? and not self.battler.defeated
  5561.          self.battler.defeated = true
  5562.          self.collapse_duration = 120
  5563.          self.knock_back_duration = 161
  5564.          reset_battler_temp
  5565.       else  
  5566.          $game_temp.change_leader_wait_time = 0
  5567.          $game_player.change_leader
  5568.       end  
  5569.   end
  5570.  
  5571.   #--------------------------------------------------------------------------
  5572.   # ● Erase Tools on Map
  5573.   #--------------------------------------------------------------------------                  
  5574.   def erase_actor_tools_on_map
  5575.       for event in $game_map.events.values
  5576.           if event.tool_id > 0 and event.action.user.is_a?(Game_Player)
  5577.              event.erase
  5578.           end  
  5579.       end  
  5580.   end
  5581.  
  5582.   #--------------------------------------------------------------------------
  5583.   # ● Execute Enemy Defeaed Process
  5584.   #--------------------------------------------------------------------------        
  5585.    def execute_enemy_defeated_process
  5586.        self.battler.defeated = true
  5587.        self.through = true
  5588.        @knock_back_duration = 121
  5589.        enemy = $data_enemies[self.battler.enemy_id]
  5590.        @collapse_duration = 120
  5591.        execute_gain_exp_gold(enemy)  
  5592.        execute_active_switch(enemy)
  5593.        execute_defeated_animation(enemy)
  5594.        execute_defeated_sound_effect(enemy)
  5595.        execute_final_shoot(enemy)
  5596.    end    
  5597.  
  5598.   #--------------------------------------------------------------------------
  5599.   # ● Execute Defeated Sound Effect
  5600.   #--------------------------------------------------------------------------              
  5601.   def execute_defeated_sound_effect(enemy)
  5602.       return if self.battler.no_damage_pop
  5603.       Sound.play_enemy_collapse  
  5604.   end
  5605.  
  5606.   #--------------------------------------------------------------------------
  5607.   # ● Execute Final Shoot
  5608.   #--------------------------------------------------------------------------            
  5609.   def execute_final_shoot(enemy)
  5610.       enemy.note  =~ /<Final Action ID = (\d+)>/
  5611.       action_id = $1.to_i
  5612.       return if action_id == nil
  5613.       self.shoot(action_id)      
  5614.   end  
  5615.  
  5616.   #--------------------------------------------------------------------------
  5617.   # ● Execute Gain Exp Gold
  5618.   #--------------------------------------------------------------------------          
  5619.   def execute_gain_exp_gold(enemy)  
  5620.       exp = self.battler.exp
  5621.       case XAS_BA::EXP_TYPE
  5622.          when 0
  5623.             actor = $game_party.members[0]
  5624.             actor.gain_exp(exp)
  5625.          when 1
  5626.             for i in 0...$game_party.members.size
  5627.                actor = $game_party.members[i]          
  5628.                actor.gain_exp(exp)
  5629.             end  
  5630.          when 2  
  5631.             exp = exp / $game_party.members.size
  5632.             for i in 0...$game_party.members.size
  5633.                actor = $game_party.members[i]          
  5634.                actor.gain_exp(exp)
  5635.             end              
  5636.       end
  5637.       $game_party.gain_gold(self.battler.gold)
  5638.   end  
  5639.  
  5640.   #--------------------------------------------------------------------------
  5641.   # ● Execute_Active Switch
  5642.   #--------------------------------------------------------------------------          
  5643.   def execute_active_switch(enemy)        
  5644.       enemy.note  =~ /<Active Switch = (\d+)>/      
  5645.       switch_id = $1.to_i  
  5646.       if switch_id != nil
  5647.          $game_switches[switch_id] = true
  5648.          $game_map.need_refresh = true    
  5649.       end
  5650.   end
  5651.  
  5652.   #--------------------------------------------------------------------------
  5653.   # ● Execute Defeated Animation
  5654.   #--------------------------------------------------------------------------            
  5655.   def execute_defeated_animation(enemy)
  5656.       enemy.note  =~ /<Defeated Animation = (\d+)>/      
  5657.       anime_id = $1.to_i      
  5658.       if anime_id != nil
  5659.          self.animation_id = anime_id
  5660.       end  
  5661.   end  
  5662.  
  5663. end  
  5664.  
  5665. #===============================================================================
  5666. # ■ Game Player
  5667. #===============================================================================
  5668. class Game_Player < Game_Character
  5669.  
  5670.   #--------------------------------------------------------------------------
  5671.   # ● Reset Old Level
  5672.   #--------------------------------------------------------------------------            
  5673.   def reset_old_level(trans = false)
  5674.      for actor in $game_party.members
  5675.          actor.old_level = actor.level
  5676.      end    
  5677.   end
  5678.  
  5679.   #--------------------------------------------------------------------------
  5680.   # ● Change Leader
  5681.   #--------------------------------------------------------------------------                  
  5682.   def change_leader
  5683.       return if $game_party.members.size <= 1
  5684.       reset_battler_temp
  5685.       current_leader_id = $game_party.members[0].id
  5686.       for i in 1..$game_party.members.size
  5687.           pre_leader = $game_party.members[0].id
  5688.           $game_party.remove_actor(pre_leader)
  5689.           $game_party.add_actor(pre_leader)  
  5690.           if $game_party.members[0].hp > 0
  5691.              execute_change_leader_effect unless current_leader_id == $game_party.members[0].id
  5692.              break
  5693.           end
  5694.       end
  5695.   end  
  5696.  
  5697.   #--------------------------------------------------------------------------
  5698.   # ● Exeute Change leader Effect
  5699.   #--------------------------------------------------------------------------                    
  5700.   def execute_change_leader_effect
  5701.       actor = $game_party.members[0]
  5702.       actor.invunerable_duration = XAS_BA::CHANGE_LEADER_WAIT_TIME
  5703.       actor.damage = nil
  5704.       actor.damage_pop = false
  5705.       actor.critical = false
  5706.       @knock_back_duration = nil
  5707.       if self.action != nil
  5708.          self.action.duration = 1
  5709.       end
  5710.       @force_action_times = 0
  5711.       @force_action_type = ""        
  5712.       reset_old_level(true)
  5713.       @x_pose_original_name = @character_name
  5714.       update_battler_pose
  5715.       $game_map.need_refresh = true
  5716.       self.animation_id = XAS_ANIMATION::CHANGE_LEADER_ANIMATION_ID
  5717.       $game_temp.change_leader_wait_time = XAS_BA::CHANGE_LEADER_WAIT_TIME  
  5718.   end
  5719.  
  5720.   #--------------------------------------------------------------------------
  5721.   # ● Check Actor Level
  5722.   #--------------------------------------------------------------------------          
  5723.   def check_actor_level
  5724.       return if $game_party.in_battle
  5725.       return if self.battler == nil
  5726.       return if self.battler.old_level == self.battler.level
  5727.       reset_old_level(false)
  5728.       if self.battler.level > 1
  5729.          Audio.se_play("Audio/SE/" + XAS_SOUND::LEVEL_UP , 100, 100)
  5730.          if XAS_WORD::ENABLE_WORD
  5731.             $game_player.battler.damage = XAS_WORD::LEVEL_UP
  5732.             $game_player.battler.damage_pop = true
  5733.          end
  5734.       end
  5735.       $game_player.need_refresh = true
  5736.   end
  5737. end  
  5738.  
  5739. #===============================================================================
  5740. # ■ Game Party
  5741. #===============================================================================
  5742. class Game_Party < Game_Unit
  5743.  
  5744.  #--------------------------------------------------------------------------
  5745.  # ● Setup Starting Members  
  5746.  #--------------------------------------------------------------------------      
  5747.   alias x_old_level_setup_starting_members setup_starting_members  
  5748.   def setup_starting_members  
  5749.       x_old_level_setup_starting_members    
  5750.       for actor in $game_party.members
  5751.           actor.old_level = actor.level
  5752.       end
  5753.   end
  5754.  
  5755. end
  5756.  
  5757. #===============================================================================
  5758. # ■ Sprite Character
  5759. #==============================================================================
  5760. class Sprite_Character < Sprite_Base  
  5761.  
  5762.   #--------------------------------------------------------------------------
  5763.   # ● Update Collapse Effects
  5764.   #--------------------------------------------------------------------------            
  5765.   def update_collaspse_effects
  5766.       update_collapse_duration
  5767.       return unless can_collapse_effects?
  5768.       update_collpase_zoom_effects
  5769.       update_exp_gold_pop
  5770.   end
  5771.    
  5772.   #--------------------------------------------------------------------------
  5773.   # ● Can Collapse Effects
  5774.   #--------------------------------------------------------------------------              
  5775.   def can_collapse_effects?
  5776.       return false if @character.battler.is_a?(Game_Actor)
  5777.       return false unless @character.dead?
  5778.       return false if @character.erased    
  5779.       return true
  5780.   end  
  5781.  
  5782.   #--------------------------------------------------------------------------
  5783.   # ● Update Exp Gold Pop
  5784.   #--------------------------------------------------------------------------              
  5785.   def update_exp_gold_pop
  5786.       return unless XAS_DAMAGE_POP::DAMAGE_EXP_GOLD_POP
  5787.       exp_pop = @character.battler.exp
  5788.       gold_pop =@character.battler.gold
  5789.       case @character.collapse_duration
  5790.            when 110
  5791.                 enemy = $data_enemies[@character.battler.enemy_id]
  5792.                 @character.make_treasure(enemy)      
  5793.            when 80
  5794.              if exp_pop != 0
  5795.                 word = XAS_WORD::EXP
  5796.                 @character.battler.damage = word + " " + exp_pop.to_s
  5797.                 @character.battler.damage_pop = true
  5798.                 @character.battler.damage_type = "Exp"
  5799.              end  
  5800.            when 40
  5801.              if gold_pop != 0
  5802.                 word = $data_system.currency_unit
  5803.                 @character.battler.damage = word + " " + gold_pop.to_s
  5804.                 @character.battler.damage_pop = true
  5805.                 @character.battler.damage_type = "Gold"
  5806.              end              
  5807.       end      
  5808.   end
  5809.  
  5810.   #--------------------------------------------------------------------------
  5811.   # ● Update Collapse Duration
  5812.   #--------------------------------------------------------------------------              
  5813.   def update_collapse_duration
  5814.       @character.collapse_duration -= 1
  5815.       @character.opacity -= 2
  5816.       if @character.collapse_duration <= 0
  5817.          if @character.battler.is_a?(Game_Actor)
  5818.             SceneManager.goto(Scene_Gameover)
  5819.             return
  5820.          end
  5821.          self.visible = false
  5822.          @character.opacity = 0
  5823.          @character.erase
  5824.       end  
  5825.   end  
  5826.  
  5827.   #--------------------------------------------------------------------------
  5828.   # ● Update Collapse Zoom Effects
  5829.   #--------------------------------------------------------------------------                
  5830.   def update_collpase_zoom_effects
  5831.       case @character.battler.death_zoom_effect
  5832.           when 1
  5833.              @character.zoom_y += 0.05
  5834.              @character.zoom_x -= 0.01            
  5835.           when 2  
  5836.              @character.zoom_y -= 0.01
  5837.              @character.zoom_x += 0.03            
  5838.           when 3  
  5839.              @character.zoom_y += 0.03
  5840.              @character.zoom_x += 0.03              
  5841.           when 4  
  5842.              @character.zoom_y -= 0.005
  5843.              @character.zoom_x -= 0.005
  5844.           when 5  
  5845.             case @character.collapse_duration
  5846.                 when 60..120
  5847.                  @character.zoom_y -= 0.01
  5848.                  @character.zoom_x += 0.06                            
  5849.                 when 0..59  
  5850.                  @character.zoom_y += 0.2
  5851.                  @character.zoom_x -= 0.1
  5852.              end
  5853.       end
  5854.   end  
  5855.  
  5856. end
  5857.  
  5858.  
  5859.  
  5860. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  5861. #■ BATTLER - TREASURE
  5862. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  5863.  
  5864.  
  5865. #===============================================================================
  5866. # ■ XAS_BA_Item_Drop
  5867. #==============================================================================
  5868. module XAS_BA_ItemDrop
  5869.  
  5870.   #--------------------------------------------------------------------------
  5871.   # ● Defeat Process
  5872.   #--------------------------------------------------------------------------              
  5873.   def make_treasure(enemy)  
  5874.       treasure = nil      
  5875.       return unless $game_player.passable?(self.x,self.y,5)
  5876.       for di in enemy.drop_items
  5877.            next if di.kind == 0
  5878.            next if rand(di.denominator) != 0
  5879.            if di.kind == 1
  5880.               treasure = $data_items[di.data_id]
  5881.               tr_id = treasure.id
  5882.            elsif di.kind == 2
  5883.               treasure = $data_weapons[di.data_id]
  5884.               tr_id = treasure.id
  5885.            elsif di.kind == 3
  5886.               treasure = $data_armors[di.data_id]
  5887.               tr_id = treasure.id
  5888.            end
  5889.            break if treasure != nil
  5890.        end  
  5891.        if treasure != nil
  5892.           command = RPG::MoveCommand.new
  5893.           command.code = 14
  5894.           command.parameters = [0,0]
  5895.           route = RPG::MoveRoute.new
  5896.           route.repeat = false
  5897.           route.list = [command, RPG::MoveCommand.new]        
  5898.           page = RPG::Event::Page.new
  5899.           page.move_type = 3
  5900.           page.move_route = route
  5901.           page.move_frequency = 6
  5902.           page.priority_type = 1
  5903.           page.trigger = 1
  5904.           page.through = true
  5905.           event = RPG::Event.new(self.x, self.y)
  5906.           event.pages = [page]      
  5907.           event = RPG::Event.new(self.x, self.y)
  5908.           token = Token_Event.new($game_map.map_id, event)
  5909.           token.icon_name = treasure.icon_index
  5910.           token.treasure = [di.kind,tr_id]
  5911.           token.treasure_time = 120 + XAS_BA::TREASURE_ERASE_TIME * 60
  5912.           token.jump_high(0,0,20)
  5913.           token.force_update = true
  5914.           token.move_speed = 6
  5915.           $game_map.add_token(token)
  5916.        end  
  5917.   end  
  5918. end
  5919.  
  5920. #===============================================================================
  5921. # ■ Game Event
  5922. #===============================================================================
  5923. class Game_Event < Game_Character
  5924.   include XAS_BA_ItemDrop
  5925.  
  5926.   #--------------------------------------------------------------------------
  5927.   # ● Update Treasure Duration
  5928.   #--------------------------------------------------------------------------              
  5929.  def update_treasure_duration
  5930.       return if @treasure_time == 0
  5931.       @treasure_time -= 1
  5932.       @hitbox_h_size = 1 if @hitbox_h_size.nil?
  5933.       @hitbox_v_size = 1 if @hitbox_v_size.nil?
  5934.       @hitbox_x_size = -0.5 if @hitbox_x_size == 0
  5935.       @hitbox_y_size = -0.5 if @hitbox_y_size == 0
  5936.       self.erase if @treasure_time == 0
  5937.   end
  5938.  
  5939. end
  5940.  
  5941. #===============================================================================
  5942. # ■ Game Character
  5943. #==============================================================================
  5944. class Game_Character < Game_CharacterBase
  5945.   attr_accessor :icon_name
  5946.   attr_accessor :treasure
  5947. end
  5948.  
  5949. #===============================================================================
  5950. # ■ Game Character
  5951. #==============================================================================
  5952. class Sprite_Character < Sprite_Base
  5953.  
  5954.   #--------------------------------------------------------------------------
  5955.   # ● Update
  5956.   #--------------------------------------------------------------------------            
  5957.   alias xrxs_charactericon_update update
  5958.   def update
  5959.       xrxs_charactericon_update
  5960.       if @character.icon_name != nil
  5961.          self.bitmap = Cache.system("Iconset")
  5962.          self.src_rect.set(@character.icon_name  % 16 * 24, @character.icon_name / 16 * 24, 24, 24)
  5963.          self.ox = 12
  5964.          self.oy = 24
  5965.       end
  5966.   end
  5967. end
  5968.  
  5969. #===============================================================================
  5970. # ■ Game Player
  5971. #==============================================================================
  5972. class Game_Player < Game_Character
  5973.  
  5974.   #--------------------------------------------------------------------------
  5975.   # ● Check Event Trigger Here
  5976.   #--------------------------------------------------------------------------              
  5977.   alias treasure_check_event_trigger_here check_event_trigger_here
  5978.   def check_event_trigger_here(triggers)
  5979.       return false if $game_map.interpreter.running?
  5980.       check_treasure_here        
  5981.       treasure_check_event_trigger_here(triggers)
  5982.   end  
  5983.  
  5984.   #--------------------------------------------------------------------------
  5985.   # ● check_treasure_here  
  5986.   #--------------------------------------------------------------------------                
  5987.   def check_treasure_here  
  5988.      for event in $game_map.events_xy(@x, @y)
  5989.          if event.treasure != nil
  5990.             name_pop = true
  5991.             case event.treasure[0]            
  5992.             when 1
  5993.                   item = $data_items[event.treasure[1]]
  5994.                   if can_execute_field_item_effect?(item)
  5995.                      name_pop = false
  5996.                   else  
  5997.                      $game_party.gain_item(item, 1)
  5998.                   end
  5999.                   $game_map.need_refresh = true
  6000.             when 2  
  6001.                   item = $data_weapons[event.treasure[1]]
  6002.                   $game_party.gain_item($data_weapons[event.treasure[1]], 1,false)
  6003.             when 3
  6004.                   item = $data_armors[event.treasure[1]]
  6005.                   $game_party.gain_item(item, 1,false)
  6006.             end
  6007.             Audio.se_play("Audio/SE/" + XAS_SOUND::ITEM_DROP , 100, 100)  
  6008.             event.erase
  6009.             if item != nil
  6010.                 if item.note =~ /<Drop Animation = (\d+)>/
  6011.                    self.animation_id = $1.to_i
  6012.                 end
  6013.                 if XAS_DAMAGE_POP::DAMAGE_ITEM_POP and name_pop
  6014.                    self.battler.damage = item.name.to_s
  6015.                    self.battler.damage_pop = true
  6016.                    self.battler.damage_type = "Item"
  6017.                 end                      
  6018.             end
  6019.           end            
  6020.      end  
  6021.  end          
  6022.      
  6023.   #--------------------------------------------------------------------------
  6024.   # ● Can Execute Field Item Effect
  6025.   #--------------------------------------------------------------------------                  
  6026.   def can_execute_field_item_effect?(item)
  6027.       if item.note =~ /<Drop HP Damage = (\S+)>/
  6028.          damage = $1.to_i
  6029.          damage2 = damage * self.battler.mhp / 100
  6030.          self.battler.damage = damage2
  6031.          self.battler.damage_pop = true
  6032.          self.battler.hp -= damage2
  6033.          return true
  6034.       end  
  6035.       if item.note =~ /<Drop MP Damage = (\S+)>/
  6036.          damage = $1.to_i
  6037.          damage2 = damage * self.battler.mmp / 100
  6038.          self.battler.mp -= damage2        
  6039.          self.battler.damage_type = "Mp"  
  6040.          self.battler.damage = damage2
  6041.          self.battler.damage_pop = true
  6042.          return true
  6043.       end      
  6044.       if item.note =~ /<Drop Gold = (\d+)>/
  6045.          gold = $1.to_i
  6046.          damage = $data_system.terms.gold + " " + gold.to_s
  6047.          self.battler.damage = damage
  6048.          self.battler.damage_pop = true
  6049.          $game_party.gain_gold(gold)
  6050.          return true
  6051.       end
  6052.       return false  
  6053.   end  
  6054. end
  6055.  
  6056.  
  6057.  
  6058. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  6059. #■ SPRITE - POSE (Character Name)
  6060. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  6061.  
  6062.  
  6063. #===============================================================================
  6064. # ■ Game_Character
  6065. #===============================================================================
  6066. class Game_Character < Game_CharacterBase
  6067.  
  6068.   attr_accessor :x_pose_duration
  6069.   attr_accessor :x_pose_name
  6070.   attr_accessor :x_pose_original_name
  6071.   attr_accessor :character_name
  6072.  
  6073.   #-----------------------------------------------------------------------------
  6074.   # ● Initialize
  6075.   #-----------------------------------------------------------------------------  
  6076.   alias x_pose_initialize initialize
  6077.   def initialize
  6078.       x_pose_initialize
  6079.       @x_pose_duration = 0
  6080.       @x_pose_name = ""
  6081.       @x_pose_original_name = @character_name
  6082.   end
  6083.  
  6084.   #-----------------------------------------------------------------------------
  6085.   # ● Update
  6086.   #-----------------------------------------------------------------------------    
  6087.   def make_pose(sufix, pose_duration)
  6088.       return if @x_pose_original_name == ""
  6089.       @x_pose_name = sufix
  6090.       @x_pose_duration = pose_duration        
  6091.   end    
  6092.  
  6093.   #-----------------------------------------------------------------------------
  6094.   # ● Update Pose
  6095.   #-----------------------------------------------------------------------------    
  6096.   def update_battler_pose
  6097.       return false unless XAS_SYSTEM::CHARACTER_POSE_NAME
  6098.       if @x_pose_duration == 0
  6099.          @x_pose_original_name = @character_name
  6100.          return
  6101.       else    
  6102.          @x_pose_duration -= 1
  6103.          @character_name = @x_pose_original_name + @x_pose_name
  6104.          if @x_pose_duration == 0
  6105.             @character_name = @x_pose_original_name
  6106.             @x_pose_name = ""
  6107.          end
  6108.       end
  6109.       unless jumping?
  6110.          @jump_count = 0
  6111.          @jump_peak = 0
  6112.       end      
  6113.   end
  6114.  
  6115.   #-----------------------------------------------------------------------------
  6116.   # ● Set Graphic
  6117.   #-----------------------------------------------------------------------------      
  6118.   alias x_pose_set_graphic set_graphic
  6119.   def set_graphic(character_name, character_index)
  6120.       x_pose_set_graphic(character_name, character_index)
  6121.       @x_pose_original_name = @character_name
  6122.       @x_pose_duration = 0
  6123.       @x_pose_name = ""      
  6124.   end    
  6125.  
  6126. end
  6127.  
  6128.  
  6129. #===============================================================================
  6130. # ■ Game_Interpreter
  6131. #===============================================================================
  6132. class Game_Interpreter
  6133.  
  6134.   #-----------------------------------------------------------------------------
  6135.   # ● Command_322
  6136.   #-----------------------------------------------------------------------------    
  6137.   alias x_pose_command_322 command_322
  6138.   def command_322
  6139.       x_pose_command_322
  6140.       actor = $game_actors[@params[0]]
  6141.       if actor != nil
  6142.          $game_player.x_pose_duration = 0
  6143.          $game_player.x_pose_original_name =  @params[1]
  6144.       end
  6145.   end
  6146.  
  6147. end  
  6148.  
  6149. #===============================================================================
  6150. # ■ RPG_FileTest
  6151. #===============================================================================
  6152. module RPG_FileTest
  6153.  
  6154.   #--------------------------------------------------------------------------
  6155.   # ● RPG_FileTest.character_exist?
  6156.   #--------------------------------------------------------------------------
  6157.   def RPG_FileTest.character_exist?(filename)
  6158.       return Cache.character(filename) rescue return false
  6159.   end
  6160.  
  6161.   #--------------------------------------------------------------------------
  6162.   # ● RPG_FileTest.system_exist?
  6163.   #--------------------------------------------------------------------------
  6164.   def RPG_FileTest.system_exist?(filename)
  6165.       return Cache.system(filename) rescue return false
  6166.   end  
  6167.  
  6168. end
  6169.  
  6170. #===============================================================================
  6171. # ■ Sprite_Character
  6172. #===============================================================================
  6173. class Sprite_Character < Sprite_Base
  6174.  
  6175.   #--------------------------------------------------------------------------
  6176.   # ● X Pose Update
  6177.   #--------------------------------------------------------------------------  
  6178.   alias x_pose_update_bitmap update_bitmap
  6179.   def update_bitmap
  6180.       check_file_exist
  6181.       x_pose_update_bitmap
  6182.   end
  6183.  
  6184.  #--------------------------------------------------------------------------
  6185.  # ● Check File Exist
  6186.  #--------------------------------------------------------------------------  
  6187.  def check_file_exist
  6188.      return if @character_name == @character.character_name
  6189.      unless RPG_FileTest.character_exist?(@character.character_name)
  6190.             @character.character_name = @character.x_pose_original_name    
  6191.             @character.x_pose_duration = 0
  6192.             @character.x_pose_name = ""
  6193.      end        
  6194.  end  
  6195.  
  6196. end
  6197.  
  6198.  
  6199.  
  6200.  
  6201.  
  6202. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  6203. #■ SPRITE - DAMAGE SPRITE
  6204. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  6205.  
  6206.  
  6207. #===============================================================================
  6208. # ■  XRXS_DAMAGE_OFFSET
  6209. #===============================================================================
  6210. module XRXS_DAMAGE_OFFSET
  6211.  
  6212.   #--------------------------------------------------------------------------
  6213.   # ● Update
  6214.   #--------------------------------------------------------------------------              
  6215.   def update
  6216.       super
  6217.       @damage_sprites   = [] if @damage_sprites.nil?
  6218.       for damage_sprite in @damage_sprites
  6219.           damage_sprite.x = self.x
  6220.           damage_sprite.y = self.y
  6221.       end
  6222.   end
  6223. end
  6224.  
  6225. #===============================================================================
  6226. # ■ Sprite_Character
  6227. #===============================================================================
  6228. class Sprite_Character < Sprite_Base
  6229.       include XRXS_DAMAGE_OFFSET
  6230. end
  6231.  
  6232.  
  6233. #==============================================================================
  6234. # ■ Sprite Base
  6235. #==============================================================================
  6236. class Sprite_Base < Sprite
  6237.   include XAS_DAMAGE_POP
  6238.   #--------------------------------------------------------------------------
  6239.   # ● Initialize
  6240.   #--------------------------------------------------------------------------  
  6241.   alias x_damage_pop_initialize initialize
  6242.   def initialize(viewport = nil)      
  6243.       @_damage_duration = 0
  6244.       x_damage_pop_initialize(viewport)
  6245.   end
  6246.  
  6247.   #--------------------------------------------------------------------------
  6248.   # ● Damage
  6249.   #--------------------------------------------------------------------------    
  6250.   def damage(value, type = "")
  6251.       dispose_damage
  6252.       @damage_ox = 0
  6253.       @damage_type = type
  6254.       # NUMBER PICTURE
  6255.       if value.is_a?(Numeric)
  6256.          bitmap_number_image = Cache.system("XAS_Damage_Number")
  6257.          bitmap_im_cw = bitmap_number_image.width / 10
  6258.          bitmap_im_ch = bitmap_number_image.height / 5          
  6259.          bitmap = Bitmap.new(bitmap_number_image.width,(bitmap_im_ch * 2) + 5)
  6260.          bitmap_number_text = value.to_s.split(//)
  6261.          center_x = (((2 + bitmap_number_text.size) * bitmap_im_cw) / 2)
  6262.          # Damage Color        
  6263.          if value >= 0
  6264.             if @damage_type == "Critical"
  6265.                h = bitmap_im_ch * 2  
  6266.                h2 = bitmap_im_ch * 4
  6267.                $game_map.screen.start_shake(5, 5, 60)
  6268.             elsif @damage_type == "Mp"  
  6269.                h = bitmap_im_ch * 0  
  6270.                h2 = bitmap_im_ch * 3
  6271.             else
  6272.                h = 0
  6273.             end
  6274.             f = 0
  6275.           else # Recover Color  
  6276.             h = bitmap_im_ch  
  6277.             h2 = bitmap_im_ch * 3 if @damage_type == "Mp"    
  6278.             f = 1
  6279.         end  
  6280.         for r in f..bitmap_number_text.size - 1
  6281.             bitmap_number_abs = bitmap_number_text[r].to_i
  6282.             bitmap_src_rect = Rect.new(bitmap_im_cw * bitmap_number_abs, h, bitmap_im_cw, bitmap_im_ch)
  6283.             bitmap.blt(center_x + (bitmap_im_cw  *  r), bitmap_im_ch + 5, bitmap_number_image, bitmap_src_rect)                  
  6284.         end
  6285.         ex = (bitmap_im_cw / 2) * (bitmap_number_text.size + f)
  6286.         @damage_ox = (bitmap_number_image.width - (bitmap_number_image.width / 2) - ex) - center_x
  6287.         # Add Extra String (MP / Critical)
  6288.         if h2 != nil
  6289.            string_x = (center_x - (bitmap_number_image.width / 2) + (bitmap_im_cw / 2) * bitmap_number_text.size)
  6290.            bitmap_src_rect = Rect.new(0, h2,  bitmap_number_image.width, bitmap_im_ch)
  6291.            bitmap.blt(string_x , 0, bitmap_number_image, bitmap_src_rect)  
  6292.         end        
  6293.         bitmap_number_image.dispose  
  6294.       else
  6295.           #TEXT STRING
  6296.           damage_string = value.to_s
  6297.           bitmap = Bitmap.new(160, 48)
  6298.           bitmap.font.name = DAMAGE_FONT_NAME
  6299.           bitmap.font.size = DAMAGE_FONT_SIZE
  6300.           bitmap.font.bold = DAMAGE_FONT_BOLD
  6301.           bitmap.font.italic = DAMAGE_FONT_ITALIC
  6302.           bitmap.font.color = Color.new(0,0,0)
  6303.           bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
  6304.           case @damage_type
  6305.                when "Exp";   string_color = DAMAGE_EXP_FONT_COLOR
  6306.                when "Gold";  string_color = DAMAGE_GOLD_FONT_COLOR
  6307.                when "Item";  string_color = DAMAGE_ITEM_FONT_COLOR
  6308.           else
  6309.              string_color = DAMAGE_DEFAULT_FONT_COLOR
  6310.           end
  6311.           bitmap.font.color = string_color
  6312.           bitmap.draw_text(0, 12, 160, 36, damage_string, 1)              
  6313.       end
  6314.        @_damage_sprite = ::Sprite.new(self.viewport)
  6315.        @_damage_sprite.bitmap = bitmap
  6316.        @_damage_sprite.ox = 80
  6317.        @_damage_sprite.oy = 20
  6318.        @_damage_sprite.x = self.x + @damage_ox
  6319.        @_damage_sprite.y = self.y - self.oy / 2
  6320.        @_damage_sprite.z = 3000
  6321.        @_damage_duration = 60
  6322.    end
  6323.  
  6324.   #--------------------------------------------------------------------------
  6325.   # ● Dispose Damage
  6326.   #--------------------------------------------------------------------------      
  6327.   def dispose_damage
  6328.       if @_damage_sprite != nil
  6329.          @_damage_sprite.bitmap.dispose
  6330.          @_damage_sprite.dispose
  6331.          @_damage_sprite = nil
  6332.          @_damage_duration = 0
  6333.       end
  6334.   end
  6335.  
  6336.   #--------------------------------------------------------------------------
  6337.   # ● Dispose
  6338.   #--------------------------------------------------------------------------        
  6339.   alias x_damage_dispose dispose
  6340.   def dispose
  6341.       dispose_damage
  6342.       x_damage_dispose
  6343.   end
  6344.  
  6345.   #--------------------------------------------------------------------------
  6346.   # ● Update
  6347.   #--------------------------------------------------------------------------          
  6348.   alias x_damage_pop_update update
  6349.   def update
  6350.       if @_damage_duration > 0
  6351.          @_damage_duration -= 1
  6352.          if @_damage_duration == 0
  6353.             dispose_damage
  6354.          end
  6355.        end      
  6356.        x_damage_pop_update
  6357.   end    
  6358.    
  6359. end  
  6360.  
  6361. #===============================================================================
  6362. # ■ XRXS DAMAGE
  6363. #===============================================================================
  6364. module XRXS_DAMAGE
  6365.  
  6366.   #--------------------------------------------------------------------------
  6367.   # ● Damage X Init Velocity
  6368.   #--------------------------------------------------------------------------                            
  6369.   def damage_x_init_velocity
  6370.       return 0.2 * (rand(5) - 2)
  6371.   end
  6372.    
  6373.   #--------------------------------------------------------------------------
  6374.   # ● Damage Y Init Velocity
  6375.   #--------------------------------------------------------------------------                            
  6376.   def damage_y_init_velocity
  6377.       return 9
  6378.   end
  6379.    
  6380.   #--------------------------------------------------------------------------
  6381.   # ● Update
  6382.   #--------------------------------------------------------------------------                              
  6383.   def update
  6384.     super
  6385.     @damage_sprites   = [] if @damage_sprites.nil?
  6386.     @damage_durations = [] if @damage_durations.nil?
  6387.     if @_damage_sprite != nil and @_damage_sprite.visible
  6388.        if @damage_ox != nil
  6389.           dam_ox = @damage_ox
  6390.        else  
  6391.           dam_ox = 0
  6392.        end        
  6393.        if @damage_type != nil
  6394.           dam_type = @damage_type
  6395.        end  
  6396.        x = damage_x_init_velocity
  6397.        y = damage_y_init_velocity
  6398.        d = @_damage_duration
  6399.        @damage_sprites.push(Sprite_Damage.new(@_damage_sprite, x, y, d,dam_ox,dam_type))
  6400.        @_damage_sprite.visible = false
  6401.     end
  6402.     for damage_sprite in @damage_sprites
  6403.         damage_sprite.update
  6404.     end
  6405.     for i in 0...@damage_sprites.size
  6406.         @damage_sprites[i] = nil if @damage_sprites[i].disposed?
  6407.     end
  6408.     @damage_sprites.compact!
  6409.   end
  6410.   def dispose
  6411.     super
  6412.     if @damage_sprites != nil
  6413.        for damage_sprite in @damage_sprites
  6414.            damage_sprite.dispose
  6415.        end
  6416.      end
  6417.   end
  6418. end
  6419.  
  6420. #===============================================================================
  6421. # ■ RPG Sprite
  6422. #===============================================================================
  6423. class Sprite_Base < Sprite
  6424.       include XRXS_DAMAGE
  6425. end
  6426.  
  6427. #===============================================================================
  6428. # ■ Sprite Damage
  6429. #===============================================================================
  6430. class Sprite_Damage < Sprite
  6431.  
  6432.   #--------------------------------------------------------------------------
  6433.   # ● Initialize
  6434.   #--------------------------------------------------------------------------                        
  6435.   def initialize(sprite, init_x_speed, init_y_speed, duration,dam_ox,dam_type = nil)
  6436.       super(nil)
  6437.       self.bitmap = sprite.bitmap.dup unless sprite.bitmap.nil?
  6438.       self.opacity = sprite.opacity
  6439.       self.x = sprite.x
  6440.       self.y = sprite.y
  6441.       self.z = sprite.z
  6442.       self.ox = sprite.ox - dam_ox
  6443.       self.oy = sprite.oy
  6444.       @now_x_speed = init_x_speed
  6445.       @now_y_speed = init_y_speed
  6446.       @potential_x_energy = 0.0
  6447.       @potential_y_energy = 0.0
  6448.       @duration = duration
  6449.       @dam_type = dam_type
  6450.       @dam_type = "" if dam_type == nil
  6451.   end
  6452.  
  6453.   #--------------------------------------------------------------------------
  6454.   # ● Update    
  6455.   #--------------------------------------------------------------------------                      
  6456.   def update
  6457.     super
  6458.     if XAS_DAMAGE_POP::DAMAGE_CRITICAL_ZOOM
  6459.        if @dam_type != "Critical"
  6460.           update_normal_popup
  6461.        else  
  6462.           update_critical_effect  
  6463.        end      
  6464.     else      
  6465.        update_normal_popup
  6466.     end
  6467.     @duration -= 1
  6468.     if @duration == 0
  6469.        self.dispose
  6470.     end
  6471.   end
  6472.  
  6473.   #--------------------------------------------------------------------------
  6474.   # ● update_critical_effect
  6475.   #--------------------------------------------------------------------------                          
  6476.   def update_critical_effect  
  6477.       case @duration
  6478.          when 40..60
  6479.            self.zoom_x += 0.1
  6480.            self.zoom_y += 0.1
  6481.          else  
  6482.            if self.zoom_x > 0.1  
  6483.               self.zoom_x -= 0.1
  6484.               self.zoom_y -= 0.1
  6485.            end
  6486.        end
  6487.   end
  6488.  
  6489.   #--------------------------------------------------------------------------
  6490.   # ● update_normal_popup
  6491.   #--------------------------------------------------------------------------                        
  6492.   def update_normal_popup
  6493.       self.opacity -= 25 if @duration <= 10
  6494.       n = self.oy + @now_y_speed
  6495.       if n <= 0
  6496.          @now_y_speed *= -1
  6497.          @now_y_speed /=  2
  6498.          @now_x_speed /=  2
  6499.       end
  6500.       self.oy  = [n, 0].max    
  6501.       @potential_y_energy += 0.58
  6502.       speed = @potential_y_energy.floor
  6503.       @now_y_speed        -= speed
  6504.       @potential_y_energy -= speed
  6505.       @potential_x_energy += @now_x_speed
  6506.       speed = @potential_x_energy.floor
  6507.       self.ox             += speed
  6508.       @potential_x_energy -= speed  
  6509.     end
  6510.  
  6511. end
  6512.  
  6513.  
  6514.  
  6515. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  6516. #■ SPRITE - SPRITE EFFECTS
  6517. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  6518.  
  6519.  
  6520. #==============================================================================
  6521. # ■ Sprite Base
  6522. #==============================================================================
  6523. class Sprite_Base < Sprite  
  6524.  
  6525.   #--------------------------------------------------------------------------
  6526.   # ● Animation Set Sprite
  6527.   #--------------------------------------------------------------------------
  6528.   def animation_set_sprites(frame)
  6529.       cell_data = frame.cell_data
  6530.       @ani_sprites.each_with_index do |sprite, i|
  6531.         next unless sprite
  6532.         pattern = cell_data[i, 0]
  6533.         if !pattern || pattern < 0
  6534.             sprite.visible = false
  6535.             next
  6536.         end
  6537.         sprite.bitmap = pattern < 100 ? @ani_bitmap1 : @ani_bitmap2
  6538.         sprite.visible = true
  6539.         sprite.src_rect.set(pattern % 5 * 192,
  6540.         pattern % 100 / 5 * 192, 192, 192)
  6541.         if @ani_mirror
  6542.            cx = cell_data[i, 1]
  6543.            sprite.angle = (360 - cell_data[i, 4])
  6544.            sprite.mirror = (cell_data[i, 5] == 0)
  6545.         else
  6546.            cx = cell_data[i, 1]
  6547.            sprite.angle = cell_data[i, 4]
  6548.            sprite.mirror = (cell_data[i, 5] == 1)
  6549.         end
  6550.         cy = cell_data[i, 2]
  6551.         sprite.z = self.z + 300 + i
  6552.         sprite.ox = 96
  6553.         sprite.oy = 96
  6554.         sprite.zoom_x = cell_data[i, 3] / 100.0
  6555.         sprite.zoom_y = cell_data[i, 3] / 100.0
  6556.         sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  6557.         sprite.blend_type = cell_data[i, 7]
  6558.         case @animation.position
  6559.               when 0
  6560.                   sprite.x = self.x + cx
  6561.                   sprite.y = self.y + cy - (height / 2)          
  6562.               when 1
  6563.                   sprite.x = self.x + cx
  6564.                   sprite.y = self.y + cy        
  6565.               when 2
  6566.                   sprite.x = self.x + cx
  6567.                   sprite.y = self.y + cy + (height / 2)
  6568.               when 3  
  6569.                   sprite.x  = (544 / 2) + cx
  6570.                   sprite.y  = (416 / 2) + cy    
  6571.         end        
  6572.        
  6573.        
  6574.     end
  6575.   end  
  6576.  
  6577.   #--------------------------------------------------------------------------
  6578.   # ● Dispose Animation
  6579.   #--------------------------------------------------------------------------
  6580.   def dispose_animation
  6581.       $game_temp.animation_garbage = [] if $game_temp.animation_garbage == nil
  6582.       if @ani_bitmap1
  6583.          @@_reference_count[@ani_bitmap1] -= 1
  6584.         if @@_reference_count[@ani_bitmap1] == 0
  6585.             $game_temp.animation_garbage.push(@ani_bitmap1)
  6586.          end
  6587.       end
  6588.       if @ani_bitmap2
  6589.          @@_reference_count[@ani_bitmap2] -= 1
  6590.          if @@_reference_count[@ani_bitmap2] == 0
  6591.             $game_temp.animation_garbage.push(@ani_bitmap2)
  6592.         end
  6593.      end
  6594.      if @ani_sprites
  6595.         @ani_sprites.each {|sprite| sprite.dispose }
  6596.         @ani_sprites = nil
  6597.         @animation = nil
  6598.      end
  6599.      @ani_bitmap1 = nil
  6600.      @ani_bitmap2 = nil
  6601.   end    
  6602.  
  6603. end
  6604.  
  6605. #==============================================================================
  6606. # ■ Scene_Base
  6607. #==============================================================================
  6608. class Game_Map
  6609.    
  6610.   #--------------------------------------------------------------------------
  6611.   # ● Setup
  6612.   #--------------------------------------------------------------------------    
  6613.   alias animation_garbage_setup setup
  6614.   def setup(map_id)
  6615.       animation_garbage_setup(map_id)
  6616.       dispose_animation_garbage
  6617.   end
  6618.  
  6619.   #--------------------------------------------------------------------------
  6620.   # ● Dispose Animation Garbage
  6621.   #--------------------------------------------------------------------------  
  6622.   def dispose_animation_garbage
  6623.       return if $game_temp.animation_garbage == nil
  6624.       for animation in $game_temp.animation_garbage
  6625.           animation.dispose
  6626.       end  
  6627.       $game_temp.animation_garbage = nil
  6628.   end  
  6629.  
  6630. end  
  6631.  
  6632. #==============================================================================
  6633. # ■ Scene_Base
  6634. #==============================================================================
  6635. class Scene_Base
  6636.  
  6637.   #--------------------------------------------------------------------------
  6638.   # ● Scene Changing?
  6639.   #--------------------------------------------------------------------------    
  6640.   alias animation_garbage_scene_changing scene_changing?
  6641.   def scene_changing?
  6642.       $game_map.dispose_animation_garbage if SceneManager.scene != self
  6643.       animation_garbage_scene_changing
  6644.   end
  6645.  
  6646. end  
  6647.  
  6648. #===============================================================================
  6649. # ■ Sprite_Character
  6650. #===============================================================================
  6651. class Sprite_Character < Sprite_Base
  6652.   include XAS_SYSTEM
  6653.  
  6654.   #--------------------------------------------------------------------------
  6655.   # ● Setup New Effect
  6656.   #--------------------------------------------------------------------------              
  6657.   def setup_new_effect
  6658.       if @character.animation_id > 0
  6659.          animation = $data_animations[@character.animation_id]
  6660.          start_animation(animation)
  6661.          @character.animation_id = 0
  6662.       end
  6663.       if !@balloon_sprite && @character.balloon_id > 0
  6664.          @balloon_id = @character.balloon_id
  6665.          start_balloon
  6666.       end
  6667.   end  
  6668.  
  6669.   #--------------------------------------------------------------------------
  6670.   # ● Can Update X Effects
  6671.   #--------------------------------------------------------------------------                    
  6672.   def can_update_x_effects?
  6673.       return false unless CHARACTER_SPRITE_EFFECTS
  6674.       return false if @character.erased
  6675.       return false if @character.transparent == true
  6676.       return true
  6677.   end  
  6678.   #--------------------------------------------------------------------------
  6679.   # ● Can Damage Pop Base
  6680.   #--------------------------------------------------------------------------                  
  6681.   def can_damage_pop_base?
  6682.       return false unless $game_system.xas_battle
  6683.       return false if XAS_SYSTEM::DAMAGE_POP == false
  6684.       return false if @character.battler == nil
  6685.       return false if @character.battler.no_damage_pop  
  6686.       return false if @character.battler.damage_pop != true
  6687.       return true  
  6688.   end  
  6689.  
  6690.  
  6691.   #--------------------------------------------------------------------------
  6692.   # ● Execute Damage Pop
  6693.   #--------------------------------------------------------------------------              
  6694.   def execute_damage_pop  
  6695.       damage(@character.battler.damage, @character.battler.damage_type)
  6696.       @character.battler.damage = nil
  6697.       @character.battler.critical = false
  6698.       @character.battler.damage_pop = false
  6699.       @character.battler.damage_type = ""
  6700.   end
  6701.    
  6702.   #--------------------------------------------------------------------------
  6703.   # ● Update X Effects
  6704.   #--------------------------------------------------------------------------              
  6705.   def update_x_effects
  6706.       update_collaspse_effects if @character.collapse_duration > 0
  6707.       update_sprite_position
  6708.       update_angle
  6709.       update_zoom
  6710.   end
  6711.    
  6712.   #--------------------------------------------------------------------------
  6713.   # ● Update Angle
  6714.   #--------------------------------------------------------------------------          
  6715.   def update_angle
  6716.       return if @character.angle == self.angle
  6717.       self.angle = @character.angle
  6718.   end
  6719.  
  6720.   #--------------------------------------------------------------------------
  6721.   # ● Update Zoom
  6722.   #--------------------------------------------------------------------------            
  6723.   def update_zoom
  6724.       update_treasure_effect
  6725.       update_breath_effect if can_breath_effect?
  6726.       self.zoom_x = @character.zoom_x
  6727.       self.zoom_y = @character.zoom_y
  6728.   end
  6729.  
  6730.   #--------------------------------------------------------------------------
  6731.   # ● Update Treasure_effect
  6732.   #--------------------------------------------------------------------------                      
  6733.   def update_treasure_effect
  6734.       return if @character.treasure_time == 0
  6735.       update_treasure_fade_effect
  6736.       update_treasure_float_effect
  6737.   end  
  6738.  
  6739.   #--------------------------------------------------------------------------
  6740.   # ● update_treasure_fade_effect
  6741.   #--------------------------------------------------------------------------                        
  6742.   def update_treasure_fade_effect
  6743.       return unless XAS_BA::FADE_TREASURE_SPRITE
  6744.       return if @character.treasure_time > 100
  6745.       return if @character.zoom_x < 0.01      
  6746.       @character.zoom_x -= 0.01
  6747.       if @character.temp_id > 0
  6748.          @character.zoom_x = 1.00
  6749.          @character.treasure_time = 120 + XAS_BA::TREASURE_ERASE_TIME * 60
  6750.       end
  6751.   end  
  6752.  
  6753.   #--------------------------------------------------------------------------
  6754.   # ● Update Treasure Float Effect
  6755.   #--------------------------------------------------------------------------                          
  6756.   def update_treasure_float_effect
  6757.       return unless XAS_BA::FLOAT_TREASURE_SPRITE    
  6758.       return if self.character.jumping?
  6759.       self.character.treasure_float[2] += 1
  6760.       if self.character.treasure_float[2] > 1
  6761.          self.character.treasure_float[2] = 0
  6762.          self.character.treasure_float[1] += 1
  6763.          case self.character.treasure_float[1]
  6764.             when 1..15
  6765.               self.character.treasure_float[0] -= 1
  6766.             when 16..30
  6767.               self.character.treasure_float[0] += 1
  6768.             else
  6769.               self.character.treasure_float[0] = 0
  6770.               self.character.treasure_float[1] = 0
  6771.           end
  6772.       end  
  6773.       self.y +=  self.character.treasure_float[0]
  6774.   end
  6775.  
  6776.   #--------------------------------------------------------------------------
  6777.   # ● Can Breath Effect?
  6778.   #--------------------------------------------------------------------------                    
  6779.   def can_breath_effect?
  6780.       return false if @character.battler == nil
  6781.       return false if @character.battler.breath_effect == false
  6782.       return false if @character.battler.hp == 0
  6783.       return false if @character.stop and not @character.battler.state_sleep
  6784.       return true
  6785.   end  
  6786.  
  6787.   #--------------------------------------------------------------------------
  6788.   # ● Update Breath Effect
  6789.   #--------------------------------------------------------------------------                  
  6790.   def update_breath_effect
  6791.       if @character.battler.fast_breath_effect
  6792.           zoom_speed = 3
  6793.           zoom_power_x = 0.006    
  6794.           zoom_power_y = 0.006        
  6795.       else
  6796.           zoom_speed = 1
  6797.           zoom_power_x = 0    
  6798.           zoom_power_y = 0.002
  6799.       end
  6800.       @character.battler.breath_duration += zoom_speed
  6801.       case @character.battler.breath_duration
  6802.            when 1..30
  6803.                 @character.zoom_x += zoom_power_x
  6804.                 @character.zoom_y += zoom_power_y
  6805.            when 31..60
  6806.                 @character.zoom_x -= zoom_power_x
  6807.                 @character.zoom_y -= zoom_power_y
  6808.            else  
  6809.                 @character.battler.breath_duration = 0
  6810.                 @character.zoom_x = 1.00
  6811.                 @character.zoom_y = 1.00
  6812.       end  
  6813.   end  
  6814.  
  6815.   #--------------------------------------------------------------------------
  6816.   # ● Update Sprite Position
  6817.   #--------------------------------------------------------------------------                  
  6818.   alias x_set_character_bitmap set_character_bitmap
  6819.   def set_character_bitmap
  6820.       @py = nil
  6821.       x_set_character_bitmap
  6822.       if @character_name[/\((\d+)\)/]
  6823.          @py = $1.to_i
  6824.       end            
  6825.   end
  6826.  
  6827.   #--------------------------------------------------------------------------
  6828.   # ● Update Sprite Position
  6829.   #--------------------------------------------------------------------------                
  6830.   def update_sprite_position
  6831.       if @character.tool_id > 0
  6832.          if @character.tool_effect == "Barrier"
  6833.             unless @character.action == nil
  6834.                bullet_user = @character.action.user
  6835.                self.x = bullet_user.screen_x
  6836.                self.y = bullet_user.screen_y
  6837.                @character.x = bullet_user.x
  6838.                @character.y = bullet_user.y
  6839.                @character.direction = bullet_user.direction
  6840.             end
  6841.          end  
  6842.       end  
  6843.       update_hold_target      
  6844.       if @py != nil
  6845.          self.y += @py
  6846.       end
  6847.       if @character.angle == 315 and @cw != nil
  6848.          self.x -= (@cw / 3)
  6849.          self.y -= (@ch / 6)
  6850.       end  
  6851.       if XAS_BA::KNOCKBACKING_SHAKE
  6852.          if self.character.knockbacking?
  6853.             self.x = self.x + rand(5) unless self.character.dead?
  6854.          end  
  6855.       end      
  6856.  end  
  6857.  
  6858.  #--------------------------------------------------------------------------
  6859.  # ● Update X Effects
  6860.  #--------------------------------------------------------------------------                
  6861.  def update_hold_target
  6862.      return if @character.temp_id == 0
  6863.      target = $game_map.events[@character.temp_id]
  6864.      if target == nil or target.erased
  6865.         @character.temp_id = 0
  6866.         @character.move_speed = @character.pre_move_speed
  6867.         check_character_above_player(target)
  6868.      else
  6869.         self.x = target.screen_x
  6870.         self.y = target.screen_y
  6871.         self.character.x = target.x
  6872.         self.character.y = target.y
  6873.         self.character.move_speed = target.move_speed
  6874.         self.character.direction = target.direction unless self.character.direction_fix
  6875.         check_character_above_player(target)
  6876.      end  
  6877.  end
  6878.  
  6879.  #--------------------------------------------------------------------------
  6880.  # ● Check Chacracter Above Player
  6881.  #--------------------------------------------------------------------------                  
  6882.  def check_character_above_player(target)
  6883.      return if @character.is_a?(Game_Player)
  6884.      return if @character.battler == nil
  6885.      if (@character.x == $game_player.x and
  6886.          @character.y == $game_player.y) or
  6887.           not @character.passable_temp_id?(@character.x,@character.y)
  6888.          @character.temp_id = 0
  6889.          @character.move_speed = @character.pre_move_speed
  6890.          case @character.direction
  6891.             when 2;  @character.y -= 1
  6892.             when 4;  @character.x += 1
  6893.             when 6;  @character.x -= 1
  6894.             when 8;  @character.y += 1  
  6895.          end
  6896.      end  
  6897.    end
  6898.  
  6899.  #--------------------------------------------------------------------------
  6900.  # ● Update_balloon
  6901.  #--------------------------------------------------------------------------
  6902.  if XAS_BA::FIX_BALLOON_POSITION
  6903.  def update_balloon
  6904.      if @balloon_duration > 0
  6905.         @balloon_duration -= 1
  6906.         if @balloon_duration > 0
  6907.            @balloon_sprite.x = x
  6908.            @balloon_sprite.y = y - XAS_BA::BALLOON_HEIGHT
  6909.            @balloon_sprite.z = z + 200
  6910.            sx = balloon_frame_index * 32
  6911.            sy = (@balloon_id - 1) * 32
  6912.            @balloon_sprite.src_rect.set(sx, sy, 32, 32)
  6913.       else
  6914.            end_balloon
  6915.       end
  6916.     end
  6917.   end  
  6918.   end
  6919.  
  6920. end
  6921.  
  6922. #==============================================================================
  6923. # ■ Game_Event
  6924. #==============================================================================
  6925. class Game_Event < Game_Character
  6926.  
  6927.   #--------------------------------------------------------------------------
  6928.   # ● Near The Screen
  6929.   #--------------------------------------------------------------------------  
  6930.   alias x_near_the_screen near_the_screen?
  6931.   def near_the_screen?(dx = 12, dy = 8)
  6932.       return true if can_update_out_screen?
  6933.       x_near_the_screen(dx, dy)
  6934.   end
  6935.  
  6936.  #--------------------------------------------------------------------------
  6937.  # ● Can Update Out Screen
  6938.  #--------------------------------------------------------------------------
  6939.  def can_update_out_screen?
  6940.      return true if self.force_update
  6941.      return false
  6942.  end
  6943.    
  6944. end
  6945.  
  6946. #==============================================================================
  6947. # ■ Spriteset Map
  6948. #==============================================================================
  6949. class Spriteset_Map
  6950.  
  6951.   #--------------------------------------------------------------------------
  6952.   # ● Can Refresh Hud
  6953.   #--------------------------------------------------------------------------    
  6954.   alias x_pre_leader_id_initialize initialize
  6955.   def initialize
  6956.       if $game_party.members[0] != nil
  6957.          $game_system.pre_leader_id = $game_party.members[0].actor_id
  6958.       else  
  6959.          $game_system.pre_leader_id = nil
  6960.       end  
  6961.       x_pre_leader_id_initialize
  6962.   end  
  6963.  
  6964.   #--------------------------------------------------------------------------
  6965.   # ● Can Refresh Hud
  6966.   #--------------------------------------------------------------------------    
  6967.   def can_refresh_hud?
  6968.       if $game_party.members[0] == nil
  6969.          return true if $game_system.pre_leader_id != nil
  6970.       elsif $game_party.members[0] != nil  
  6971.          return true if $game_system.pre_leader_id == nil
  6972.          return true if $game_system.pre_leader_id != $game_party.members[0].actor_id
  6973.       end  
  6974.       return false
  6975.   end  
  6976.  
  6977.   #--------------------------------------------------------------------------
  6978.   # ● update
  6979.   #--------------------------------------------------------------------------    
  6980.   def refresh_hud
  6981.       $game_system.pre_leader_id = $game_party.members[0].actor_id      
  6982.   end
  6983.  
  6984.   #--------------------------------------------------------------------------
  6985.   # ● Update Hud Visible
  6986.   #--------------------------------------------------------------------------      
  6987.   def update_hud_visible
  6988.       if hud_visible?
  6989.          $game_system.enable_hud = true
  6990.       else  
  6991.          $game_system.enable_hud = false
  6992.       end  
  6993.   end  
  6994.    
  6995.   #--------------------------------------------------------------------------
  6996.   # ● Hud Visible?
  6997.   #--------------------------------------------------------------------------        
  6998.   def hud_visible?
  6999.       return false if $game_system.hud_visible == false
  7000.       return false if $game_message.visible
  7001.       return true
  7002.   end    
  7003.  
  7004. end  
  7005.  
  7006.  
  7007.  
  7008. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  7009. #■ MISC - SCENE TARGET SELECT
  7010. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  7011.  
  7012.  
  7013. #==============================================================================
  7014. # ■ Game_Temp
  7015. #==============================================================================
  7016. class Game_Temp
  7017.       attr_accessor :xas_target_x
  7018.       attr_accessor :xas_target_y
  7019.       attr_accessor :xas_target_time
  7020.       attr_accessor :xas_target_shoot_id
  7021.      
  7022. #--------------------------------------------------------------------------
  7023. # ● Initialize
  7024. #--------------------------------------------------------------------------
  7025.   alias xas_target_initialize initialize
  7026.   def initialize
  7027.       xas_target_initialize
  7028.       @xas_target_x = 0
  7029.       @xas_target_y = 0
  7030.       @xas_target_time = 0
  7031.       @xas_target_shoot_id = 0
  7032.   end    
  7033.        
  7034. end
  7035.  
  7036. #==============================================================================
  7037. # ■ Game_Map
  7038. #==============================================================================
  7039. class Game_Map
  7040.  
  7041.  attr_accessor :pre_display_x
  7042.  attr_accessor :pre_display_y
  7043.  attr_accessor :pre_real_display_x
  7044.  attr_accessor :pre_real_display_y
  7045.  
  7046.  #--------------------------------------------------------------------------
  7047.  # * Object Initialization
  7048.  #--------------------------------------------------------------------------
  7049.  alias x_map_initialize initialize
  7050.  def initialize  
  7051.      x_map_initialize
  7052.      @pre_display_x = @display_x - 1
  7053.      @pre_display_y = @display_y - 1    
  7054.  end
  7055.  
  7056.   #--------------------------------------------------------------------------
  7057.   # ● Screen Scrolled?
  7058.   #--------------------------------------------------------------------------        
  7059.   def screen_scrolled?
  7060.       if @pre_display_x != @display_x or
  7061.          @pre_display_y != @display_y
  7062.          @pre_display_x = @display_x
  7063.          @pre_display_y = @display_y
  7064.          return true
  7065.       end  
  7066.       return false
  7067.   end
  7068.  
  7069.  #--------------------------------------------------------------------------
  7070.  # ● Event On Screen
  7071.  #--------------------------------------------------------------------------
  7072.  def event_on_screen?(event)
  7073.      event.target = false
  7074.      px = ($game_map.display_x).truncate
  7075.      py = ($game_map.display_y).truncate    
  7076.      distance_x = event.x - px
  7077.      distance_y = event.y - py
  7078.      if distance_x.between?(0, 16) and
  7079.         distance_y.between?(0, 12)
  7080.         event.target = true
  7081.      end  
  7082.  end      
  7083.  
  7084.  #--------------------------------------------------------------------------
  7085.  # ● Check Event on Screen
  7086.  #--------------------------------------------------------------------------
  7087.  def check_events_on_screen
  7088.       for i in $game_map.events.values
  7089.             event_on_screen?(i)
  7090.       end  
  7091.   end
  7092.  
  7093. end  
  7094. #==============================================================================
  7095. # ■ Scene Target Select
  7096. #==============================================================================
  7097. class Scene_Target_Select
  7098.  
  7099.   #--------------------------------------------------------------------------
  7100.   # ● Main
  7101.   #--------------------------------------------------------------------------        
  7102.   def main    
  7103.       $game_temp.xas_target_x = 0
  7104.       $game_temp.xas_target_y = 0      
  7105.       $game_temp.xas_target_time = 0
  7106.       @new_x = $game_player.screen_x
  7107.       @new_y = $game_player.screen_y
  7108.       @index_max = -1
  7109.       @target_index = 0  
  7110.       @spriteset = Spriteset_Map.new
  7111.       @text_string = ""
  7112.       @fy = 0
  7113.       @fy_time = 0
  7114.       for event in $game_map.events.values
  7115.         if event.target and event.battler?
  7116.            @index_max += 1
  7117.         end  
  7118.       end  
  7119.       Sound.play_equip
  7120.       if @index_max == -1
  7121.          cancel_select
  7122.       else
  7123.          create_layout
  7124.          create_layout_skill
  7125.          create_cusrsor
  7126.          create_text      
  7127.          create_skill_name
  7128.          select_target(0)
  7129.       end
  7130.       Graphics.transition(0)
  7131.       loop do
  7132.            Graphics.update
  7133.            Input.update
  7134.            update
  7135.            break if SceneManager.scene != self
  7136.       end
  7137.       dispose
  7138.  end  
  7139.   #--------------------------------------------------------------------------
  7140.   # ● Create Layout
  7141.   #--------------------------------------------------------------------------      
  7142.   def create_layout
  7143.       @layout_1 = Plane.new
  7144.       @layout_1.bitmap = Cache.system("XAS_Target_Layout1")
  7145.       @layout_1.z = 10100
  7146.       @layout_1.opacity = 255
  7147.   end  
  7148.  
  7149.  #--------------------------------------------------------------------------
  7150.  # ● Create Layout
  7151.  #--------------------------------------------------------------------------      
  7152.  def create_layout_skill
  7153.      @skill_layout = Sprite.new
  7154.      @skill_layout.bitmap = Cache.system("XAS_Active_Help")
  7155.      @skill_layout.z = 10101
  7156.      @skill_layout.x = -100    
  7157.      @skill_layout.y = 32
  7158.      @skill_layout.opacity = 0
  7159.  end
  7160.    
  7161.  #--------------------------------------------------------------------------
  7162.  # ● Create Cursor
  7163.  #--------------------------------------------------------------------------            
  7164.  def create_cusrsor
  7165.      @cursor = Sprite.new
  7166.      @cursor.bitmap = Cache.system("XAS_Cursor")
  7167.      @cursor.z = 10105
  7168.      @cursor.x = @new_x
  7169.      @cursor.y = @new_y
  7170.      @cursor.opacity = 255
  7171.      @cursor.visible = true
  7172.  end
  7173.  
  7174.  #--------------------------------------------------------------------------
  7175.  # ● Create Text
  7176.  #--------------------------------------------------------------------------    
  7177.  def create_text
  7178.      @text = Sprite.new
  7179.      @text.bitmap = Bitmap.new(200,40)
  7180.      @text.z = 10102
  7181.      @text.bitmap.font.size = 20
  7182.      @text.bitmap.font.bold = true
  7183.      @text.bitmap.font.name = "Georgia"  
  7184.      @text.bitmap.draw_text(0, 0, 200, 40, @text_string.to_s,1)
  7185.      @text.opacity = 255
  7186.      @text.x = @new_x
  7187.      @text.y = @new_y    
  7188.  end
  7189.  
  7190.  #--------------------------------------------------------------------------
  7191.  # ● Create Text
  7192.  #--------------------------------------------------------------------------    
  7193.  def create_skill_name
  7194.      @skill_name = Plane.new
  7195.      @skill_name.bitmap = Bitmap.new(640,480)
  7196.      @skill_name.z = 10103
  7197.      @skill_name.bitmap.font.size = 20
  7198.      @skill_name.bitmap.font.bold = true
  7199.      @skill_name.bitmap.font.name = "Georgia"  
  7200.      @skill_name.oy = -40
  7201.      skill = $data_skills[$game_temp.xas_target_shoot_id]
  7202.      skill_text = skill.name.to_s + " - " + skill.description.to_s    
  7203.      @skill_name.bitmap.draw_text(0, 0, 640, 40, skill_text,1)
  7204.      @skill_name.opacity = 0
  7205.  end  
  7206.  
  7207.  #--------------------------------------------------------------------------
  7208.  # ● Dispose
  7209.  #--------------------------------------------------------------------------            
  7210.  def dispose
  7211.      Graphics.freeze
  7212.      @spriteset.dispose
  7213.      if @cursor != nil
  7214.         @cursor.bitmap.dispose
  7215.         @cursor.dispose  
  7216.         @text.bitmap.dispose
  7217.         @text.dispose
  7218.         @skill_layout.bitmap.dispose
  7219.         @skill_layout.dispose
  7220.         @skill_name.bitmap.dispose
  7221.         @skill_name.dispose
  7222.         @layout_1.bitmap.dispose
  7223.         @layout_1.dispose
  7224.      end
  7225.  end
  7226.  
  7227.  #--------------------------------------------------------------------------
  7228.  # ● Update
  7229.  #--------------------------------------------------------------------------          
  7230.  def update
  7231.      return if @index_max == -1
  7232.      @spriteset.update
  7233.      update_cursor_slide
  7234.      update_layout_slide
  7235.      update_targe_select
  7236.  end
  7237.  
  7238.  #--------------------------------------------------------------------------
  7239.  # ● Update Layout Slide
  7240.  #--------------------------------------------------------------------------            
  7241.  def update_layout_slide
  7242.      @layout_1.ox += 3
  7243.      if @skill_layout.x < 0
  7244.         @skill_layout.x += 10
  7245.         @skill_layout.opacity += 25
  7246.         @skill_name.opacity += 25
  7247.      else
  7248.         @skill_layout.x = 0
  7249.         @skill_layout.opacity = 255
  7250.         @skill_name.opacity = 255
  7251.         @skill_name.ox -= 3
  7252.      end  
  7253.  end  
  7254.  
  7255.  #--------------------------------------------------------------------------
  7256.  # ● Refresh Text
  7257.  #--------------------------------------------------------------------------            
  7258.  def refresh_text
  7259.      @text.bitmap.clear
  7260.      @text.bitmap.draw_text(0, 0, 200, 40, @text_string.to_s,1)
  7261.  end
  7262.  
  7263.  #--------------------------------------------------------------------------
  7264.  # ● Update Cursor Slide
  7265.  #--------------------------------------------------------------------------          
  7266.  def update_cursor_slide
  7267.      @speed_x = [[(@cursor.x - @new_x / 60), 1].max, 60].min
  7268.      @speed_y = [[(@cursor.y - @new_y / 60), 1].max, 60].min
  7269.      if @cursor.x > @new_x
  7270.         @cursor.x -= @speed_x.abs
  7271.         @cursor.x = @new_x if @cursor.x < @new_x
  7272.      elsif @cursor.x < @new_x
  7273.         @cursor.x += @speed_x.abs
  7274.         @cursor.x = @new_x if @cursor.x > @new_x
  7275.      end        
  7276.      
  7277.      if @cursor.y > @new_y
  7278.         @cursor.y -= @speed_y.abs
  7279.         @cursor.y = @new_y if @cursor.y < @new_y
  7280.      elsif @cursor.y < @new_y
  7281.         @cursor.y += @speed_y.abs
  7282.         @cursor.y = @new_y if @cursor.y > @new_y
  7283.      end      
  7284.      @text.x = - 85 + @cursor.x
  7285.      @text.y = 20 + @cursor.y
  7286.      if @fy_time > 25
  7287.         @fy += 1
  7288.      elsif @fy_time > 0
  7289.         @fy -= 1
  7290.      else  
  7291.         @fy = 0
  7292.         @fy_time = 50
  7293.      end  
  7294.      @fy_time -= 1
  7295.      @cursor.oy = @fy
  7296.      
  7297.  end
  7298.  
  7299.  #--------------------------------------------------------------------------
  7300.  # ● Select Target(type)
  7301.  #--------------------------------------------------------------------------          
  7302.  def select_target(type)
  7303.      return if  @index_max < 0
  7304.      check_index
  7305.      valor = 0
  7306.      for event in $game_map.events.values
  7307.         if event.target and event.battler?
  7308.            if valor == @target_index
  7309.               @new_x = event.screen_x - 10
  7310.               @new_y = event.screen_y
  7311.               @text_string = event.battler.name
  7312.               $game_temp.xas_target_x = event.x
  7313.               $game_temp.xas_target_y = event.y
  7314.               $game_temp.xas_target_time = 1
  7315.             end
  7316.             valor += 1  
  7317.          end  
  7318.      end  
  7319.      refresh_text  
  7320.   end
  7321.  
  7322.  #--------------------------------------------------------------------------
  7323.  # ● Cancel Select
  7324.  #--------------------------------------------------------------------------              
  7325.  def cancel_select
  7326.      Sound.play_buzzer
  7327.      $game_temp.xas_target_x = 0
  7328.      $game_temp.xas_target_y = 0      
  7329.      $game_temp.xas_target_time = 0
  7330.      $game_temp.xas_target_shoot_id = 0
  7331.      SceneManager.call(Scene_Map)
  7332.  end
  7333.    
  7334.   #--------------------------------------------------------------------------
  7335.   # ● Update Target Select
  7336.   #--------------------------------------------------------------------------            
  7337.   def update_targe_select
  7338.       if Input.trigger?(Input::B)
  7339.          cancel_select
  7340.       elsif Input.trigger?(Input::DOWN) or Input.trigger?(Input::RIGHT)  
  7341.          @target_index += 1
  7342.          select_target(0)
  7343.          Sound.play_cursor
  7344.       elsif Input.trigger?(Input::UP) or Input.trigger?(Input::LEFT)
  7345.          @target_index -= 1
  7346.          select_target(1)
  7347.          Sound.play_cursor
  7348.       elsif Input.trigger?(Input::C)
  7349.          Sound.play_ok
  7350.          SceneManager.call(Scene_Map)
  7351.       end  
  7352.   end
  7353.  
  7354.   #--------------------------------------------------------------------------
  7355.   # ● Check Index
  7356.   #--------------------------------------------------------------------------                
  7357.   def check_index
  7358.       if @target_index > @index_max
  7359.          @target_index = 0
  7360.       end      
  7361.       if @target_index < 0
  7362.          @target_index = @index_max
  7363.       end    
  7364.   end        
  7365.  
  7366. end  
  7367.  
  7368.  
  7369. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  7370. #■ MISC - MAIN UPDATE
  7371. #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  7372.  
  7373. #===============================================================================
  7374. # ■  Spriteset_Map
  7375. #===============================================================================
  7376. class Spriteset_Map
  7377.  
  7378.   #--------------------------------------------------------------------------
  7379.   # ● update
  7380.   #--------------------------------------------------------------------------  
  7381.   alias xas_main_update update
  7382.   def update
  7383.       xas_main_update
  7384.       update_xas_spriteset_map
  7385.   end
  7386.  
  7387.   #--------------------------------------------------------------------------
  7388.   # ● Update XAS Spriteset Map
  7389.   #--------------------------------------------------------------------------      
  7390.   def update_xas_spriteset_map
  7391.       refresh_token if $game_map.need_refresh_token
  7392.       refresh_hud if can_refresh_hud?
  7393.       update_hud_visible
  7394.   end    
  7395. end
  7396.  
  7397.  
  7398. #===============================================================================
  7399. # ■ Sprite_Character
  7400. #===============================================================================
  7401. class Sprite_Character < Sprite_Base
  7402.  
  7403.   #--------------------------------------------------------------------------
  7404.   # ● Update
  7405.   #--------------------------------------------------------------------------            
  7406.   alias x_update update
  7407.   def update
  7408.       x_update
  7409.       execute_damage_pop  if can_damage_pop_base?
  7410.       update_x_effects if can_update_x_effects?
  7411.   end
  7412.    
  7413. end    
  7414.  
  7415. #===============================================================================
  7416. # ■ Game Character
  7417. #===============================================================================
  7418. class Game_Character < Game_CharacterBase
  7419.  
  7420.   #--------------------------------------------------------------------------
  7421.   # ● Update
  7422.   #--------------------------------------------------------------------------    
  7423.   alias x_main_update update
  7424.   def update
  7425.       update_character_before_movement
  7426.       x_main_update
  7427.       update_character_after_movement
  7428.   end  
  7429.  
  7430.   #--------------------------------------------------------------------------
  7431.   # ● Update Character Before Movement
  7432.   #--------------------------------------------------------------------------      
  7433.   def update_character_before_movement
  7434.       check_xy
  7435.       update_force_action if can_force_action?
  7436.   end  
  7437.  
  7438.   #--------------------------------------------------------------------------
  7439.   # ● Update Character After Movement
  7440.   #--------------------------------------------------------------------------      
  7441.   def update_character_after_movement
  7442.       update_battler if can_update_battler?      
  7443.   end      
  7444.  
  7445. end  
  7446.  
  7447. #===============================================================================
  7448. # ■ Game Event
  7449. #===============================================================================
  7450. class Game_Event < Game_Character
  7451.  
  7452.   #--------------------------------------------------------------------------
  7453.   # ● Update
  7454.   #--------------------------------------------------------------------------    
  7455.   alias x_main_event_update update
  7456.   def update
  7457.       update_event_before_movement
  7458.       x_main_event_update
  7459.       update_event_after_movement
  7460.   end  
  7461.  
  7462.   #--------------------------------------------------------------------------
  7463.   # ● Update Event Before Movement
  7464.   #--------------------------------------------------------------------------      
  7465.   def update_event_before_movement
  7466.       update_sensor if can_update_sensor?
  7467.       update_treasure_duration      
  7468.   end  
  7469.  
  7470.   #--------------------------------------------------------------------------
  7471.   # ● Update Event After Movement
  7472.   #--------------------------------------------------------------------------      
  7473.   def update_event_after_movement
  7474.      
  7475.   end    
  7476.  
  7477. end  
  7478.  
  7479. #===============================================================================
  7480. # ■ Game Player
  7481. #===============================================================================
  7482. class Game_Player < Game_Character
  7483.  
  7484.   #--------------------------------------------------------------------------
  7485.   # ● Update
  7486.   #--------------------------------------------------------------------------    
  7487.   alias x_main_player_update update
  7488.   def update
  7489.       update_player_before_movement if party_system?
  7490.       x_main_player_update
  7491.       update_player_after_movement if party_system?
  7492.   end  
  7493.  
  7494.   #--------------------------------------------------------------------------
  7495.   # ● Update Player Before Movement
  7496.   #--------------------------------------------------------------------------      
  7497.   def update_player_before_movement
  7498.       check_actor_level
  7499.       update_reset_battler_setting_time
  7500.       if $game_system.old_interpreter_running != $game_map.interpreter.running?
  7501.          refresh_interpreter_effect
  7502.       end  
  7503.   end  
  7504.  
  7505.   #--------------------------------------------------------------------------
  7506.   # ● Update Player after Movement
  7507.   #--------------------------------------------------------------------------      
  7508.   def update_player_after_movement
  7509.       update_action_command if can_use_command?
  7510.       $game_temp.change_leader_wait_time -= 1 if $game_temp.change_leader_wait_time > 0
  7511.   end      
  7512.  
  7513.  
  7514.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement