RPG Maker Forums

Well, as the title says, I am hoping it is possible to change what happens when the player reaches 0 HP when using Falcaos ABS found here. I am specifically looking for either a switch to be flipped or a variable to be controlled, is this possible?


This script is the meat & potatoes of the whole thing:



Spoiler



#===============================================================================
# * Falcao Pearl ABS script shelf # 1
#
# This script is the Heart of Pearl ABS Liquid, it handles all the character
# management, the tools variables and the input module, enemy registration etc.
#===============================================================================


module PearlKernel
 
  # Default enemy sensor self switch
  Enemy_Sensor = "B"
 
  # Default enemy sensor (distance in tiles the enemy is able to see the Player
  Sensor = 8
 
  # Default enemy knockdown self switch (used to display knockdowned graphic)
  KnockdownSelfW = "C"
 
  # Deafault Enemy collapse
  DefaultCollapse = 'zoom_vertical'
 
  # While in party battle on map, the game player is the manager of the group
  # Which distance the player can see the enemies?, this is used, to determine
  # wheter the follower can start fighting. enemy away from this tiles
  # whil be ignored untill the player is near them
  # distamce measured in tiles
  PlayerRange = 7
 
  # When a follower fail an action this balloon is played, runs out of mana etc.
  FailBalloon = 1
 
  # Start the game with the ABS huds turned on?
  StartWithHud = false
 
  # Do you want to activate the followers dead poses?
  FollowerDeadPose = true
 
  # Do you want to activate the single player mode?
  # this only avoid you accesing the player slection menu and the K key is used
  # to open the quick tool selection menu
  SinglePlayer = true
 
  #-----------------------------------------------------------------------------
  @gaugeback = Color.new(0, 0, 0, 100)
  def self.draw_hp(obj, battler, x, y, w, h, color, name=nil)
    tag = 'Hp' ; c = color
    name = battler.name if !name.nil?
    draw_gauge(obj, battler.hp, battler.mhp, x, y, w, h, c, tag, name)
  end
 
  def self.draw_mp(obj, battler, x, y, w, h, color, name=nil)
    tag = 'Mp' ; c = color
    name = battler.name if !name.nil?
    draw_gauge(obj, battler.mp, battler.mmp, x, y, w, h, c, tag, name)
  end
 
  def self.draw_exp(obj, battler, x, y, w, h, color, name=nil)
    tag = 'Exp' ; c = color
    name = battler.name if !name.nil?
    draw_gauge(obj,battler.exp, battler.next_level_exp, x, y, w, h, c, tag,name)
  end
 
  def self.draw_tp(obj, x, y, actor)
    string = 'Tp ' + (actor.tp).to_i.to_s
    obj.fill_rect(x, y + 10 , string.length * 9, 12, @gaugeback)
    obj.draw_text(x, y, obj.width, 32, string)
  end
 
  def self.draw_gauge(obj, nm, max, x, y, w, h, col, tag, name)
    obj.font.shadow = true
    w2 = w - 2 ; max = 1 if max == 0
    obj.fill_rect(x, y - 1, w, h + 2, @gaugeback)
    obj.fill_rect(x+1, y+1, w2*nm/max, h/2 - 1, col[0])
    obj.fill_rect(x+1, y + h/2, w2*nm/max, h/2 - 1, col[1])
    obj.draw_text(x, y + h - 22, w, 32, nm.to_s, 2)
    obj.draw_text(x + 4, y + h - 22, w, 32, tag)
    obj.draw_text(x, y - 25, w, 32, name, 1) if !name.nil?
  end
 
  # image based bars definition
  def self.image_hp(bitmap, x, y, back, image, battler, name=nil)
    tag = 'Hp'
    name = battler.name if !name.nil?
    draw_i_gauge(bitmap, x, y, back, image, battler.hp, battler.mhp, tag, name)
  end
 
  def self.image_mp(bitmap, x, y, back, image, battler, name=nil)
    tag = 'Mp'
    name = battler.name if !name.nil?
    draw_i_gauge(bitmap, x, y, back, image, battler.mp, battler.mmp, tag, name)
  end
 
  def self.image_exp(bitmap, x, y, back, image, battler, name=nil)
    tag = 'Exp'
    name = battler.name if !name.nil?
    exp, nexte = battler.exp, battler.next_level_exp
    draw_i_gauge(bitmap, x, y, back, image, exp, nexte, tag, name)
  end
 
  def self.draw_i_gauge(bitmap, x, y, back, image, nm, max, tag, name)
    cw = back.width  
    ch = back.height
    max = 1 if max == 0
    src_rect = Rect.new(0, 0, cw, ch)    
    bitmap.blt(x - 10, y - ch + 30,  back, src_rect)
    cw = image.width  * nm / max
    ch = image.height
    src_rect = Rect.new(0, 0, cw, ch)
    bitmap.blt(x - 10, y - ch + 30, image, src_rect)
    bitmap.draw_text(x - 4, y + back.height - 14, back.width, 32, tag)
    bitmap.draw_text(x - 12, y + back.height - 14, back.width, 32, nm.to_s, 2)
    bitmap.draw_text(x - 6, y - 10, back.width, 32, name, 1) if !name.nil?
  end
 
  def self.has_data?
    !user_graphic.nil?
  end
 
  def self.load_item(item)
    @item = item
  end
 
  def self.user_graphic()      @item.tool_data("User Graphic = ", false)    end
  def self.user_animespeed()   @item.tool_data("User Anime Speed = ")       end
  def self.tool_cooldown()     @item.tool_data("Tool Cooldown = ")          end
  def self.tool_graphic()      @item.tool_data("Tool Graphic = ", false)    end
  def self.tool_index()        @item.tool_data("Tool Index = ")             end
  def self.tool_size()         @item.tool_data("Tool Size = ")              end
  def self.tool_distance()     @item.tool_data("Tool Distance = ")          end
  def self.tool_effectdelay()  @item.tool_data("Tool Effect Delay = ")      end
  def self.tool_destroydelay() @item.tool_data("Tool Destroy Delay = ")     end
  def self.tool_speed()         @item.tool_float("Tool Speed = ")            end
  def self.tool_castime()       @item.tool_data("Tool Cast Time = ")         end
  def self.tool_castanimation() @item.tool_data("Tool Cast Animation = ")    end
  def self.tool_blowpower()     @item.tool_data("Tool Blow Power = ")        end
  def self.tool_piercing()      @item.tool_data("Tool Piercing = ", false)   end
  def self.tool_animation() @item.tool_data("Tool Animation When = ", false) end
  def self.tool_anirepeat() @item.tool_data("Tool Animation Repeat = ",false)end
  def self.tool_special() @item.tool_data("Tool Special = ", false)          end
  def self.tool_target() @item.tool_data("Tool Target = ", false)            end
  def self.tool_invoke() @item.tool_data("Tool Invoke Skill = ")             end
  def self.tool_guardrate() @item.tool_data("Tool Guard Rate = ")            end
  def self.tool_knockdown() @item.tool_data("Tool Knockdown Rate = ")        end
  def self.tool_soundse() @item.tool_data("Tool Sound Se = ", false)         end
  def self.tool_itemcost() @item.tool_data("Tool Item Cost = ")              end
  def self.tool_shortjump() @item.tool_data("Tool Short Jump = ", false)     end
  def self.tool_through() @item.tool_data("Tool Through = ", false)          end
  def self.tool_priority() @item.tool_data("Tool Priority = ")               end
  def self.tool_selfdamage() @item.tool_data("Tool Self Damage = ", false)   end
  def self.tool_hitshake() @item.tool_data("Tool Hit Shake = ", false)       end
  def self.tool_combo() @item.tool_data("Tool Combo Tool = ", false)         end
 
  def self.knock_actor(actor)
    a = actor.actor.tool_data("Knockdown Graphic = ", false)
    b = actor.actor.tool_data("Knockdown Index = ")
    c = actor.actor.tool_data("Knockdown pattern = ")
    d = actor.actor.tool_data("Knockdown Direction = ")
    return nil if a.nil?
    return [a, b, c, d]
  end
 
  def self.jump_hit?(target)
    t = target.enemy.tool_data("Hit Jump = ", false) if target.is_a?(Game_Enemy)
    t = target.actor.tool_data("Hit Jump = ", false) if target.is_a?(Game_Actor)
    return true if !t.nil? and t == "true"
    return true if t.nil?
    return false
  end
 
  def self.voices(b)
    voices = b.actor.tool_data("Battler Voices = ",false) if b.is_a?(Game_Actor)
    voices = b.enemy.tool_data("Battler Voices = ",false) if b.is_a?(Game_Enemy)
    voices = voices.split(", ") unless voices.nil?
    voices
  end
 
  def self.hitvoices(b)
    voices = b.actor.tool_data("Hit Voices = ",false) if b.is_a?(Game_Actor)
    voices = b.enemy.tool_data("Hit Voices = ",false) if b.is_a?(Game_Enemy)
    voices = voices.split(", ") unless voices.nil?
    voices
  end
 
  # check for iconset
  def self.check_iconset(item, tag, object)
    data = item.tool_data(tag, false)
    return if data.nil?
    v = [item.icon_index, data.to_sym] if data == "animated" ||
    data == "static" || data == "shielding"
    object.is_a?(Projectile) ? object.pro_iconset = v : object.user_iconset = v
  end
 
  def self.clean_back?
    @clean_back == true
  end
end


($imported ||= {})["Falcao Pearl ABS Liquid"] = true


class RPG::BaseItem
  attr_reader :has_data
  def tool_data(comment, sw=true)
    if @note =~ /#{comment}(.*)/i
      @has_data = true
      return sw ? $1.to_i : $1.to_s.sub("\r","")
    end
  end
 
  def tool_float(comment)
    return  $1.to_f if @note =~ /#{comment}(.*)/i
  end
 
  def cool_enabled?
    @cd_dis = @note.include?("Tool Cooldown Display = true") if @cd_dis.nil?
    @cd_dis
  end
 
  def itemcost
    if @i_cost.nil?
      @note =~ /Tool Item Cost = (.*)/i ? @i_cost = $1.to_i : @i_cost = 0
    end
    @i_cost
  end
end


# Pearl ABS Input module
module PearlKey
 
  # numbers
  N0 = 0x30; N1 = 0x31; N2 = 0x32; N3 = 0x33; N4 = 0x34
  N5 = 0x35; N6 = 0x36; N7 = 0x37; N8 = 0x38; N9 = 0x39
 
  # keys
  A = 0x41; B = 0x42; C = 0x43; D = 0x44; E = 0x45
  F = 0x46; G = 0x47; H = 0x48; I = 0x49; J = 0x4A
  K = 0x4B; L = 0x4C; M = 0x4D; N = 0x4E; O = 0x4F
  P = 0x50; Q = 0x51; R = 0x52; S = 0x53; T = 0x54
  U = 0x55; V = 0x56; W = 0x57; X = 0x58; Y = 0x59; Z = 0x5A


  @unpack_string = 'b'*256
  @last_array = '0'*256
  @press = Array.new(256, false)
  @trigger = Array.new(256, false)
  @release = Array.new(256, false)
  @getKeyboardState = Win32API.new('user32', 'GetKeyboardState', ['P'], 'V')
  @getAsyncKeyState = Win32API.new('user32', 'GetAsyncKeyState', 'i', 'i')
  @getKeyboardState.call(@last_array)
 
  @last_array = @last_array.unpack(@unpack_string)
  for i in 0...@last_array.size
    @press = @getAsyncKeyState.call(i) == 0 ? false : true

  end


 


  def self.update


    @trigger = Array.new(256, false)


    @release = Array.new(256, false)


    array = '0'*256


    @getKeyboardState.call(array)


    array = array.unpack(@unpack_string)


    for i in 0...array.size


      if array
!= @last_array

        @press
= @getAsyncKeyState.call(i) == 0 ? false : true

        if !@press


          @release
= true

        else


          @trigger
= true

        end


      else


        if @press
== true

          @press
= @getAsyncKeyState.call(i) == 0 ? false : true

          @release
= true if !@press

        end


      end


    end


    @last_array = array


  end


 


  def self.press?(key)


    return @press[key]


  end


 


  def self.trigger?(key)


    return @trigger[key]


  end


end





# Input module update engine


class << Input


  alias falcaopearl_abs_cooldown_update update


  def Input.update


    update_pearl_abs_cooldown


    update_popwindow if !$game_temp.nil? and !$game_temp.pop_windowdata.nil?


    update_pearl_abs_respawn


    falcaopearl_abs_cooldown_update


  end


 


 


  def update_pearl_abs_respawn


    $game_map.event_enemies.each do |event|


      if event.respawn_count > 0


        event.respawn_count -= 1


        if event.respawn_count == 0


          event.battler.remove_state(event.battler.death_state_id)


          event.battler.hp = event.battler.mhp


          event.battler.mp = event.battler.mmp


          event.apply_respawn


          event.animation_id = event.respawn_anim


        end


      end


    end


  end


 


  alias falcaopearl_trigger trigger?


  def trigger?(constant)


    return true if constant == :B and PearlKey.trigger?(PearlKey::B)


    falcaopearl_trigger(constant)


  end


 


  # pop window global


  def update_popwindow


    $game_temp.pop_windowdata[0] -= 1 if $game_temp.pop_windowdata[0] > 0


    if @temp_window.nil?


      tag = $game_temp.pop_windowdata[2]


      string = $game_temp.pop_windowdata[1] + tag


      width = (string.length * 9) - 10


      x, y = Graphics.width / 2 - width / 2,  Graphics.height / 2 - 64 / 2


      @temp_window = Window_Base.new(x, y, width, 64)


      @temp_window.contents.font.size = 20


      @temp_window.draw_text(-10, -6, width, 32, tag, 1)


      @temp_window.draw_text(-10, 14, width, 32, $game_temp.pop_windowdata[1],1)


      @current_scene = SceneManager.scene.class


    end


    


    if $game_temp.pop_windowdata[0] == 0 ||


      @current_scene != SceneManager.scene.class


      @temp_window.dispose


      @temp_window = nil


      $game_temp.pop_windowdata = nil


    end


  end


 


  def update_pearl_abs_cooldown


    PearlKey.update


    eval_cooldown($game_party.all_members) if !$game_party.nil?


    eval_cooldown($game_map.enemies) if !$game_map.nil?


  end


 


  # cooldown update


  def eval_cooldown(operand)


    for sub in operand


      sub.skill_cooldown.each {|sid, sv| # skill


      if sub.skill_cooldown[sid] > 0


        sub.skill_cooldown[sid] -= 1


        sub.skill_cooldown.delete(sid) if sub.skill_cooldown[sid] == 0


      end}


      sub.item_cooldown.each {|iid, iv| # item


      if sub.item_cooldown[iid] > 0


        sub.item_cooldown[iid] -= 1


        sub.item_cooldown.delete(iid) if sub.item_cooldown[iid] == 0


      end}


      sub.weapon_cooldown.each {|wid, wv| # weapon


      if sub.weapon_cooldown[wid] > 0


        sub.weapon_cooldown[wid] -= 1


        sub.weapon_cooldown.delete(wid) if sub.weapon_cooldown[wid] == 0


      end}


      sub.armor_cooldown.each {|aid, av| #armor


      if sub.armor_cooldown[aid] > 0


        sub.armor_cooldown[aid] -= 1


        sub.armor_cooldown.delete(aid) if sub.armor_cooldown[aid] == 0


      end}


    end


  end


end





#===============================================================================


#===============================================================================


# Game character





class Game_CharacterBase


  attr_accessor :just_hitted, :anime_speed, :blowpower, :targeting, :x, :y


  attr_accessor :battler_guarding, :knockdown_data, :colapse_time, :opacity


  attr_accessor :zoomfx_x, :zoomfx_y, :targeted_character, :stuck_timer


  attr_accessor :send_dispose_signal, :follower_attacktimer, :stopped_movement


  attr_accessor :hookshoting, :battler_chain, :pattern, :user_move_distance


  attr_accessor :move_speed, :through, :being_grabbed, :making_spiral


  attr_accessor :direction, :direction_fix, :zfx_bol, :buff_pop_stack


  attr_accessor :die_through, :target_index, :using_custom_g, :combodata


  attr_accessor :originalasp, :doingcombo, :angle_fx


  attr_accessor :user_iconset, :pro_iconset, :respawn_count


  alias falcaopearl_abmain_ini initialize


  def initialize


    @zfx_bol = false


    @just_hitted = 0


    @anime_speed = 0


    @respawn_count = 0


    @blowpower = [0, dir=2, dirfix=false, s=4, wait_reset=0]


    @user_casting = [0, nil]


    @send_dispose_signal = false


    @targeting = [false, item=nil, char=nil]


    @colapse_time = 0


    @stopped_movement = 0


    @follower_attacktimer = 0


    set_hook_variables


    @target_index = 0


    @using_custom_g = false


    @combodata = []


    @angle_fx = 0.0


    #--------------


    @zoomfx_x = 1.0


    @zoomfx_y = 1.0


    @stuck_timer = 0


    @battler_guarding = [false, nil]


    @knockdown_data = [0, nil, nil, nil, nil]


    @state_poptimer = [0, 0]


    @making_spiral = false


    @buff_pop_stack = []


    @doingcombo = 0


    @range_view = 2


    @originalasp = 0


    falcaopearl_abmain_ini


  end


 


  def set_hook_variables


    @hookshoting = [on=false, hooking=false, grabing=false, delay=0]


    @battler_chain = []


    @user_move_distance = [steps=0, speed=nil, trought=nil, cor=nil, evmove=nil]


    @being_grabbed = false


  end


 


  # projectiles at nt


  def projectiles_xy_nt(x, y)


    $game_player.projectiles.select {|pro| pro.pos_nt?(x, y) }


  end


 


  # collide with projectiles


  def collide_with_projectiles?(x, y)


    projectiles_xy_nt(x, y).any? do |pro|


      pro.normal_priority? || self.is_a?(Projectile)


    end


  end


 


  def zoom(x, y)


    @zoomfx_x = x


    @zoomfx_y = y


  end


 


  alias falcaopearl_collide_with collide_with_characters?


  def collide_with_characters?(x, y)


    return true if collide_with_projectiles?(x, y)


    falcaopearl_collide_with(x, y)


  end


 


  # follow character straigh and diagonal


  def follow_char(character)


    sx = distance_x_from(character.x)


    sy = distance_y_from(character.y)


    if sx != 0 && sy != 0


      move_diagonal(sx > 0 ? 4 : 6, sy > 0 ? 8 : 2)


    elsif sx != 0


      move_straight(sx > 0 ? 4 : 6)


    elsif sy != 0


      move_straight(sy > 0 ? 8 : 2)


    end


  end


 


  def on_battle_screen?(out = 0)


    max_w = (Graphics.width / 32).to_i - 1


    max_h = (Graphics.height / 32).to_i - 1


    sx = (screen_x / 32).to_i


    sy = (screen_y / 32).to_i


    if sx.between?(0 - out, max_w + out) and sy.between?(0 - out, max_h + out)


      return true


    end


    return false


  end


 


   # jump to specific tiles


  def jumpto_tile(x, y)


    jumpto(0, [x, y])


  end


 


  # jumpto character ( 0 = Game Player, 1 and up event id)


  def jumpto(char_id, tilexy=nil)


    char_id > 0 ? char = $game_map.events[char_id] : char = $game_player


    tilexy.nil? ? condxy = [char.x, char.y] : condxy = [tilexy[0], tilexy[1]]


    jx = + eval_distance(tilexy.nil? ? char : tilexy)[0] if condxy[0] >= @x


    jy = - eval_distance(tilexy.nil? ? char : tilexy)[1] if condxy[1] <= @y


    jx = - eval_distance(tilexy.nil? ? char : tilexy)[0] if condxy[0] <= @x


    jy = - eval_distance(tilexy.nil? ? char : tilexy)[1] if condxy[1] <= @y


    jx = - eval_distance(tilexy.nil? ? char : tilexy)[0] if condxy[0] <= @x


    jy = + eval_distance(tilexy.nil? ? char : tilexy)[1] if condxy[1] >= @y


    jx = + eval_distance(tilexy.nil? ? char : tilexy)[0] if condxy[0] >= @x


    jy = + eval_distance(tilexy.nil? ? char : tilexy)[1] if condxy[1] >= @y


    jump(jx, jy)


  end


 


  # distance


  def eval_distance(target)


    if target.is_a?(Array)


      distance_x = (@x - target[0]).abs


      distance_y = (@y - target[1]).abs


    else


      distance_x = (@x - target.x).abs


      distance_y = (@y - target.y).abs


    end


    return [distance_x, distance_y]


  end


 


  # check if the game player and follower are executing an action


  def battler_acting?


    return true if @user_casting[0] > 0 || @targeting[0]


    return true if @knockdown_data[0] > 0 and battler.deadposing.nil?


    return true if @anime_speed > 0


    return true if @hookshoting[0] || @making_spiral


    if self.is_a?(Game_Player)


      $game_player.followers.each {|f| return true if f.battler_acting?}


    end


    return false


  end





  def battler


  end


 


  #use single tools


  def use_weapon(id)


    return unless tool_can_use?


    process_tool_action($data_weapons[id])


  end


 


  def use_item(id)


    return unless tool_can_use?


    process_tool_action($data_items[id])


  end


 


  def use_skill(id)


    return unless tool_can_use?


    process_tool_action($data_skills[id])


  end


 


  def use_armor(id)


    return unless tool_can_use?


    process_tool_action($data_armors[id])


  end


 


  # use multiple tools


  def rand_weapon(*args)


    return unless tool_can_use?


    process_tool_action($data_weapons[args[rand(args.size)]])


  end


 


  def rand_item(*args)


    return unless tool_can_use?


    process_tool_action($data_items[args[rand(args.size)]])


  end


 


  def rand_skill(*args)


    return unless tool_can_use?


    process_tool_action($data_skills[args[rand(args.size)]])


  end


 


  def rand_armor(*args)


    return unless tool_can_use?


    process_tool_action($data_armors[args[rand(args.size)]])


  end


 


  def tool_can_use?


    return false if @hookshoting[0] || @making_spiral


    return false if @user_casting[0] > 0 || @targeting[0]


    return false if battler.nil?


    return false if battler.dead?


    return false if @doingcombo > 0 || @battler_guarding[0]


    return false if $game_message.busy?


    return true


  end


 


  def load_target_selection(item)


    @targeting[0] = true; @targeting[1] = item


    if self.is_a?(Game_Player)


      $game_player.pearl_menu_call = [:battler, 2]


    elsif self.is_a?(Game_Follower)


      @targeting[2] = @targeted_character


      @targeting = [false, item=nil, char=nil] if @targeting[2].nil?


    elsif self.is_a?(Projectile)


      if user.is_a?(Game_Player)


        user.targeting[0] = true; user.targeting[1] = item


        $game_player.pearl_menu_call = [:battler, 2]


      end


      if user.is_a?(Game_Follower)


        @targeting[2] = user.targeted_character


        @targeting = [false, item=nil, char=nil] if @targeting[2].nil?


      end


    end


  end


 


  def playdead


    @angle_fx = 90


  end


 


  def resetplaydead


    @angle_fx = 0.0


  end





  #action canceling


  def force_cancel_actions


    @user_casting[0] = 0


    @anime_speed = 0


  end


 


  def speed(x)


    @move_speed = x


  end


 


  def anima(x)


    @animation_id = x


  end


 


  # aply melee params


  def apply_weapon_param(weapon, add)


    id = 0


    for param in weapon.params


      add ? battler.add_param(id, param) : battler.add_param(id, -param)


      id += 1


    end


  end


 


  # Short script call for poping damage text


  def pop_damage(custom=nil)


    $game_player.damage_pop.push(DamagePop_Obj.new(self, custom))


  end


 


  #check if target is unable to move


  def force_stopped?


    return true if @anime_speed > 0 || @knockdown_data[0] > 0 ||


    @stopped_movement > 0 || @hookshoting[0] || @angle_fx != 0.0


    return true if @making_spiral


    return false


  end


 


  # sensor


  def obj_size?(target, size)


    return false if size.nil?


    distance = (@x - target.x).abs + (@y - target.y).abs


    enable   = (distance <= size-1)


    return true if enable


    return false


  end


 


  # sensor body


  def body_size?(target, size)


    distance = (@x - target[0]).abs + (@y - target[1]).abs


    enable   = (distance <= size-1)


    return true if enable


    return false


  end


 


  def faceto_face?(target)


    return true if @direction == 2 and target.direction == 8


    return true if @direction == 4 and target.direction == 6


    return true if @direction == 6 and target.direction == 4


    return true if @direction == 8 and target.direction == 2


    return false


  end


 


  def adjustcxy


    push_x, push_y =   0,   1 if @direction == 2


    push_x, push_y = - 1,   0 if @direction == 4


    push_x, push_y =   1,   0 if @direction == 6


    push_x, push_y =   0, - 1 if @direction == 8


    return [push_x, push_y]


  end


 


  def in_frontof?(target)


    return true if @direction == 2 and @x == target.x and (@y+1) == target.y


    return true if @direction == 4 and (@x-1) == target.x and @y == target.y


    return true if @direction == 6 and (@x+1) == target.x and @y == target.y


    return true if @direction == 8 and @x == target.x and (@y-1) == target.y


    return false


  end


 


  # detect map edges ignoring loop maps


  def facing_corners?


    case $game_map.map.scroll_type


    when 1 then return false if @direction == 2 || @direction == 8


    when 2 then return false if @direction == 4 || @direction == 6


    when 3 then return false


    end


    m = $game_map


    unless @x.between?(1, m.width - 2) && @y.between?(1, m.height - 2)


      return true if @x == 0 and @direction == 4


      return true if @y == 0 and @direction == 8


      return true if @x == m.width  - 1  and @direction == 6


      return true if @y == m.height - 1  and @direction == 2


    end


    return false


  end


 


  # item usable test


  def usable_test_passed?(item)


    return true if battler.is_a?(Game_Enemy) && item.is_a?(RPG::Item)


    itemcost = item.tool_data("Tool Item Cost = ")


    invoke = item.tool_data("Tool Invoke Skill = ")


    if battler.is_a?(Game_Actor) and itemcost != nil and itemcost != 0


      return false if !battler.usable?($data_items[itemcost])


    end


    if item.is_a?(RPG::Skill) || item.is_a?(RPG::Item)


      return false if !battler.usable?(item)


    else


      if invoke != nil and invoke != 0


        return false if !battler.usable?($data_skills[invoke])


      else


        return false if !battler.attack_usable?


      end


    end


    return true


  end


 


  # process the tool and verify wheter can be used


  def process_tool_action(item)


    PearlKernel.load_item(item)


    return if !battler.tool_ready?(item)


 


    unless PearlKernel.has_data?


      if item.is_a?(RPG::Weapon) || item.is_a?(RPG::Armor)


        msgbox('Tool data missing') if $DEBUG


        return


      end


      if item.scope.between?(1, 6)


        msgbox('Tool data missing') if $DEBUG


        return


      elsif item.scope == 0


        return


        


      elsif !battler.usable?(item)


        RPG::SE.new("Cursor1", 80).play if self.is_a?(Game_Player)


        return


      end


    end


    


    if PearlKernel.has_data? and not usable_test_passed?(item)


      RPG::SE.new("Cursor1", 80).play if self.is_a?(Game_Player)


      return


    end


    


    @user_casting = [PearlKernel.tool_castime,item] if PearlKernel.has_data?


    if @user_casting[0] > 0


      @animation_id = 0


      @animation_id = PearlKernel.tool_castanimation


    else


      load_abs_tool(item)


    end


  end


 


  # load the abs tool


  def load_abs_tool(item)


    return if @knockdown_data[0] > 0


    PearlKernel.load_item(item)


 


    return if self.is_a?(Game_Follower) and @targeted_character.nil?


    


    if !@targeting[0] and  self.battler.is_a?(Game_Actor)


      if item.is_a?(RPG::Skill) || item.is_a?(RPG::Item)


        # apply target to skills items


        if PearlKernel.tool_target == "true" || item.scope == 7 ||


          item.scope == 9


          load_target_selection(item)


          return


        end


      else


        # apply target parsing the invoked skill to weapons and armors


        invoke = PearlKernel.tool_invoke


        if invoke != nil && invoke > 0 && invoke != 1 && invoke != 2


          invokeskill = $data_skills[invoke]


          if PearlKernel.tool_target == "true" || invokeskill.scope == 7 ||


            invokeskill.scope == 9


            load_target_selection(item)


            return


          end


          # apply target to normal weapon and armor without invoking


        else


          if PearlKernel.tool_target == "true"


            load_target_selection(item)


            return


          end


        end


      end


    end


    if item.is_a?(RPG::Skill) || item.is_a?(RPG::Item)


      battler.use_item(item)


    else


      if PearlKernel.tool_invoke != 0


        battler.use_item($data_skills[PearlKernel.tool_invoke])


      end


    end


    


    # if the tool has data continue


    if PearlKernel.has_data?


      consume_ammo_item(item) if battler.is_a?(Game_Actor) and


      PearlKernel.tool_itemcost != 0


      @anime_speed = PearlKernel.user_animespeed


      battler.apply_cooldown(item, PearlKernel.tool_cooldown)


    end


    create_projectile_object(item)


    create_anime_sprite_object(item)


  end


 


  # projectile creator


  def create_projectile_object(item)


    if PearlKernel.tool_special == "hook"


      PearlKernel.tool_distance.times {|i|


      $game_player.projectiles.push(Projectile.new(self, item, i))}


      @hookshoting[0] = true


    elsif PearlKernel.tool_special == "triple"       # loads 3 projectiles


      for i in [:uno, :dos, :tres]


        $game_player.projectiles.push(Projectile.new(self, item, i))


      end


    elsif PearlKernel.tool_special == "quintuple"     #loads 5 projectiles


      for i in [:uno, :dos, :tres, :cuatro, :cinco]


        $game_player.projectiles.push(Projectile.new(self, item, i))


      end


    elsif PearlKernel.tool_special == "octuple"       # loads 8 projectiles


      for i in [:uno, :dos, :tres, :cuatro, :cinco, :seis, :siete, :ocho]


        $game_player.projectiles.push(Projectile.new(self, item, i))


      end


    else # load default projectile


      $game_player.projectiles.push(Projectile.new(self, item))


    end


  end


 


  # User anime sprite creation


  def create_anime_sprite_object(item)


    $game_player.anime_action.each {|i|


    if i.user == self


      if i.custom_graphic


        @transparent = false


        i.user.using_custom_g = false


      end


      $game_player.anime_action.delete(i)


    end}


    


    if PearlKernel.user_graphic != "nil"


      return if PearlKernel.user_graphic.nil?


      $game_player.anime_action.push(Anime_Obj.new(self, item))


    end


    


    # using iconset graphic


    if PearlKernel.user_graphic == "nil" and


      !item.tool_data("User Iconset = ", false).nil?


      return if PearlKernel.user_graphic.nil?


      $game_player.anime_action.push(Anime_Obj.new(self, item))


    end


  end


 


  # consume ammo item


  def consume_ammo_item(item)


    itemcost = $data_items[PearlKernel.tool_itemcost]


    return if item.is_a?(RPG::Item) and item.consumable and item == itemcost


    battler.use_item(itemcost)


  end


 


  alias falcaopearl_chaupdate update


  def update


    update_falcao_pearl_abs


    falcaopearl_chaupdate


  end


 


  # Falcao pearl abs main update


  def update_falcao_pearl_abs


    if @user_move_distance[0] > 0 and not moving?


      move_forward ; @user_move_distance[0] -= 1


    end


    return if battler.nil?


    update_pearlabs_timing


    update_followers_attack if self.is_a?(Game_Follower) && self.visible?


    if @targeting[2] != nil


      load_abs_tool(@targeting[1]) if battler.is_a?(Game_Actor)


      @targeting = [false, item=nil, char=nil]


    end


    update_battler_collapse


    update_state_effects


    


    @combodata.each {|combo|


    if combo[3] > 0


      combo[3] -= 1


      if combo[3] == 0


        perform_combo(combo[0], combo[1], combo[2])


        @combodata.delete(combo)


      end


      break


    end}


  end





  def perform_combo(kind, id, jumpp)


    if jumpp == 'jump'


      jump(0, 0)


      move_forward


    end


    case kind


    when :weapon then use_weapon(id)


    when :armor  then use_armor(id)


    when :item   then use_item(id)


    when :skill  then use_skill(id)


    end


    @doingcombo = 12


  end


 


  #========================================================================


  #     * followers attacks engine


 


  def fo_tool


    return actor.equips[0]       if actor.primary_use == 1


    return actor.equips[1]       if actor.primary_use == 2


    return actor.assigned_item   if actor.primary_use == 3


    return actor.assigned_item2  if actor.primary_use == 4


    return actor.assigned_skill  if actor.primary_use == 5


    return actor.assigned_skill2 if actor.primary_use == 6


    return actor.assigned_skill3 if actor.primary_use == 7


    return actor.assigned_skill4 if actor.primary_use == 8


  end


 


  # followers attack engine


  def update_followers_attack


    if fo_tool.nil? || battler.dead?


      @targeted_character = nil if @targeted_character != nil


      return


    end


    return if @stopped_movement > 0


    if @follower_attacktimer > 0


      @follower_attacktimer -= 1


      if @follower_attacktimer == 40 and !moving?


        r = rand(3)


        move_random if r == 0 || r == 1


        move_away_from_character(@targeted_character) if


        !@targeted_character.nil? and r == 2


      end


    end


    


     # si la skill es para el player


    if @targeted_character != nil and @targeted_character.is_a?(Game_Player)


      if all_enemies_dead?


        delete_targetf


        return


      end


      use_predefined_tool


      return


    end


    


    # si la skill es para un enemigo continuar


    if @targeted_character != nil


      use_predefined_tool


      return if @targeted_character.nil?


      # reset if the target is dead


      if @targeted_character.collapsing?


        force_cancel_actions


        delete_targetf


      end


    else


      # select a follower slected target


      $game_player.followers.each do |follower|


        if !follower.targeted_character.nil?


          next if follower.targeted_character.is_a?(Game_Player)


          if follower.stuck_timer >= 10


            follower.targeted_character = nil


            return


          end


          @targeted_character = follower.targeted_character


          break


        end


      end


    end


  end


 


  # prepare the tool usage


  def setup_followertool_usage


    @range_view = 2


    @range_view = 6 if fo_tool.tool_data("Tool Target = ", false) == "true" ||


    fo_tool.tool_data("Tool Special = ", false) == "autotarget"


    


    if fo_tool.is_a?(RPG::Skill) || fo_tool.is_a?(RPG::Item)


      if fo_tool.scope.between?(1, 6)


        setup_target


      else ; @targeted_character = $game_player


        @range_view = 6


      end


      # prepare tool for invoke follower


    elsif fo_tool.is_a?(RPG::Weapon) || fo_tool.is_a?(RPG::Armor)


      invoke = fo_tool.tool_data("Tool Invoke Skill = ")


      if invoke > 0


        if $data_skills[invoke].scope.between?(1, 6)


          setup_target


        else ; @targeted_character = $game_player


          @range_view = 6


        end


      else


        # no invoke skill just set up an enemy target


        setup_target


      end


    end


  end


 


  # use the predifined tool


  def use_predefined_tool


    update_follower_movement


    return if @targeted_character.nil?


    if obj_size?(@targeted_character, @range_view) && @follower_attacktimer == 0


      turn_toward_character(@targeted_character)


      use_weapon(fo_tool.id) if actor.primary_use == 1


      use_armor(fo_tool.id)  if actor.primary_use == 2


      use_item(fo_tool.id)   if actor.primary_use == 3 || actor.primary_use == 4


      use_skill(fo_tool.id)  if actor.primary_use==5 || actor.primary_use==6 ||


      actor.primary_use == 7 || actor.primary_use == 8


      if fo_tool.tool_data("User Graphic = ", false).nil?


        @targeted_character = nil


        turn_toward_player


      end


      @follower_attacktimer = 60


    end


    delete_targetf if self.actor.dead?


  end


 


  def all_enemies_dead?


    for event in $game_map.event_enemies


      if event.on_battle_screen? && event.enemy_ready?


        return false if $game_player.obj_size?(event,PearlKernel::playerRange+1)


      end


    end


    return true


  end


 


  def delete_targetf


    @targeted_character = nil


  end


 


  #------------------------


  # follower movement attack


  def reset_targeting_settings(target)


    target.being_targeted = false if target.is_a?(Game_Event)


    delete_targetf


    turn_toward_player


    @stuck_timer = 0


  end


 


  def update_follower_movement


    target = @targeted_character


    if @stuck_timer >= 30


      reset_targeting_settings(target)


      return


    end


    


    # if the follower is unabble to use the tool


    unless usable_test_passed?(fo_tool)


      if SceneManager.scene_is?(Scene_Map)


        reset_targeting_settings(target)


        @balloon_id = PearlKernel::FailBalloon


        return


      end


    end


    


    return if target.nil?


    @stuck_timer += 1 if !obj_size?(target, @range_view) and !moving?


 


    if moving? || @anime_speed > 0 || @making_spiral || @hookshoting[0] ||


      @knockdown_data[0] > 0


      @stuck_timer = 0


    end


    return if moving?


    if fo_tool.tool_data("Tool Target = ", false) == "true" ||


      fo_tool.tool_data("Tool Special = ", false) == "autotarget" ||


      target.is_a?(Game_Player)


      # using skill con target true magical


      cpu_reactiontype(1, target)


      return


      # target not exist


    else


    


      if fo_tool.is_a?(RPG::Skill) || fo_tool.is_a?(RPG::Item)


        fo_tool.scope.between?(1, 6) ? cpu_reactiontype(2, target) : # to enemy


        cpu_reactiontype(1, target) # benefical


      else


        # for weapon armor without target


        cpu_reactiontype(2, target)


      end


    end


    return if !obj_size?(target, @range_view)


    return if target.is_a?(Game_Player)


    case rand(40)


    when 4  then move_backward


    when 10 then move_random


    end


  end


 


  # cpu reaction


  def cpu_reactiontype(type, target)


    unless on_battle_screen?


      3.times.each {|i|  move_toward_player}


      return


    end


    move_toward_character(target) if !obj_size?(target, @range_view) if type==1


    if @follower_attacktimer == 0 || !obj_size?(target, @range_view)


      move_toward_character(target) if type == 2


    end


  end


  #-------------------------------------------------


 


  # buff timer


  def update_buff_timing


    battler.buff_turns.each do |id, value|


      if battler.buff_turns[id] > 0


        battler.buff_turns[id] -= 1


        if battler.buff_turns[id] <= 0


          battler.remove_buff(id)


          pop_damage


        end


      end


    end


  end


 


  #blow power effect


  def update_blow_power_effect


    if @blowpower[4] > 0


      @blowpower[4] -= 1


      if @blowpower[4] == 0


        @direction_fix = @blowpower[2]


        @move_speed = @blowpower[3]


      end


    end


    if @blowpower[0] > 0 and !moving?


      @move_speed = 5.5


      @direction_fix = true


      move_straight(@blowpower[1]); @blowpower[0] -= 1


      if @blowpower[0] == 0


        @blowpower[4] = 10


      end


    end


  end


 


  # Pearl timing


  def update_pearlabs_timing


    @just_hitted -= 1 if @just_hitted > 0


    @stopped_movement -= 1 if @stopped_movement > 0


    @doingcombo -= 1 if @doingcombo > 0


    


    # hookshooting


    if @hookshoting[3] > 0


      @hookshoting[3] -= 1


      if @hookshoting[3] == 0


        @hookshoting = [false, false, false, 0]


        @user_move_distance[3].being_grabbed = false if


        @user_move_distance[3].is_a?(Game_Event)


        @user_move_distance[3] = nil


      end


    end


    update_buff_timing


    update_blow_power_effect


    # anime


    if @anime_speed > 0


      @pattern = 0


      @anime_speed -= 1


    end


    # casting


    if @user_casting[0] > 0


      @user_casting[0] -= 1


      load_abs_tool(@user_casting[1]) if @user_casting[0] == 0


    end


    update_knockdown


  end


 


  # Update battler collapse


 


  def check_for_dead_four


    return if $game_party.members.size <= 4


    SceneManager.goto(Scene_Gameover) if all_fourdead?


  end


 


  def all_fourdead?


    m = $game_party.battle_members


    return true if m[0].dead? && m[1].dead? && m[2].dead? && m[3].dead?


    return false


  end


 


  def update_battler_collapse


    if @colapse_time > 0


      @colapse_time -= 1


      force_cancel_actions


      if battler.is_a?(Game_Actor)


        Sound.play_actor_collapse if @secollapse.nil?


        @secollapse = true


        


        if @colapse_time == 0


          @secollapse = nil


          for event in $game_map.event_enemies


            if event.agroto_f == self


              event.agroto_f = nil


            end


          end


          


          check_for_dead_four


          member = $game_party.battle_members


          # swap and reset player


          if self.is_a?(Game_Player)


            reset_knockdown_actors


            battler.deadposing=$game_map.map_id if PearlKernel::FollowerDeadPose


            $game_party.swap_order(0,3) if !member[3].nil? and !member[3].dead?


            $game_party.swap_order(0,2) if !member[2].nil? and !member[2].dead?


            $game_party.swap_order(0,1) if !member[1].nil? and !member[1].dead?


          else


            if PearlKernel::FollowerDeadPose


              battler.deadposing = $game_map.map_id


              if !$game_player.follower_fighting? and member.size > 2


                swap_dead_follower


              else


                $game_player.reserved_swap << battler.id if member.size > 2


              end


            end


          end


        end


        


      elsif battler.is_a?(Game_Enemy)


        @die_through = @through if @die_through.nil?


        @through = true


        apply_collapse_anime(battler.collapse_type)


        @secollapse = true


        battler.object ? @transparent = true : @opacity -= 2 if !@deadposee


        if @colapse_time == 0


          self.kill_enemy


        end


      end


    end


  end


 


  def swap_dead_follower


    reset_knockdown_actors


    member = $game_party.battle_members


    member.each_with_index.each do |actorr, i|


      next unless actorr.id == self.actor.id


      case member.size


      when 3


        break if i == 2


        $game_party.swap_order(i, 2)


      when 4


        break if i == 3


        if !member[3].dead?


          $game_party.swap_order(i, 3)


          break


        end


        if !member[2].dead?  


          $game_party.swap_order(i, 2)


          break


        end


      end


    end


  end





  def apply_collapse_anime(type)


    # sound and animation


    if battler.die_animation != nil


      @animation_id = battler.die_animation if @secollapse.nil?


    else


      Sound.play_enemy_collapse if @secollapse.nil? and !battler.object


    end


    return if battler.object


    if @deadposee


      @knockdown_data[0] = 8


      return


    end


    type = PearlKernel::DefaultCollapse if type.nil?


    case type.to_sym


    when :zoom_vertical


      @zoomfx_x -= 0.03


      @zoomfx_y += 0.02


    when :zoom_horizontal


      @zoomfx_x += 0.03


      @zoomfx_y -= 0.02


    when :zoom_maximize


      @zoomfx_x += 0.02


      @zoomfx_y += 0.02


    when :zoom_minimize


      @zoomfx_x -= 0.02


      @zoomfx_y -= 0.02


    end


  end


 


  # konck down engine update


  def update_knockdown


    if @knockdown_data[0] > 0


      @knockdown_data[0] -= 1


      @knockdown_data[0] == 0 ? knowdown_effect(2) : knowdown_effect(1)


      if @knockdown_data[1] != nil


        @pattern = @knockdown_data[2]


        @direction = @knockdown_data[3]


      end


    end


  end


 


  def knowdown_effect(type)


    return if self.is_a?(Projectile)


    if type[0] == 1


      if @knockdown_data[1] == nil


        if battler.is_a?(Game_Enemy)


          if self.knockdown_enable


            force_cancel_actions


            self_sw = PearlKernel::KnockdownSelfW


            $game_self_switches[[$game_map.map_id, self.id, self_sw]] = true


            @knockdown_data[1] = self_sw


            self.refresh


            @knockdown_data[2] = self.page.graphic.pattern


            @knockdown_data[3] = self.page.graphic.direction


            $game_map.screen.start_shake(7, 4, 20)


          end


          


          @knockdown_data[0] = 0 if @knockdown_data[1] == nil


       elsif battler.is_a?(Game_Actor)


         if PearlKernel.knock_actor(self.actor) != nil and


           if @knockdown_data[1] == nil


             force_cancel_actions


             @knockdown_data[1] = @character_name


             @knockdown_data[4] = @character_index


             @character_name = PearlKernel.knock_actor(self.actor)[0]


             @character_index = PearlKernel.knock_actor(self.actor)[1]


             @knockdown_data[2] = PearlKernel.knock_actor(self.actor)[2]


             @knockdown_data[3] = PearlKernel.knock_actor(self.actor)[3]


             $game_map.screen.start_shake(7, 4, 20) if battler.deadposing.nil?


           end


         end


         @knockdown_data[0] = 0 if @knockdown_data[1] == nil


        end


      end


    elsif type == 2


      if battler.is_a?(Game_Enemy)


        if @deadposee and battler.dead?


          @knockdown_data[1] = nil


          return


        end


        $game_self_switches[[$game_map.map_id, self.id,


        @knockdown_data[1]]] = false if @knockdown_data[1] != nil


        @knockdown_data[1] = nil


      else


        @character_name = @knockdown_data[1]


        @character_index = @knockdown_data[4]


        @knockdown_data[1] = nil


      end


    end


  end


 


  #================================


  # states


  def primary_state_ani


    return nil if battler.states[0].nil?


    return battler.states[0].tool_data("State Animation = ")


  end


 


  # higer priority state animation displayed


  def update_state_effects


    return if battler.nil?


    @state_poptimer[0] += 1 unless primary_state_ani.nil?


    if @state_poptimer[0] == 30


      @animation_id = primary_state_ani


      @animation_id = 0 if @animation_id.nil?


    elsif @state_poptimer[0] == 180


      @state_poptimer[0] = 0


    end


    update_state_action_steps


  end


 


  # update state actions


  def update_state_action_steps


    for state in battler.states


      if state.remove_by_walking


        if !battler.state_steps[state.id].nil? &&


          battler.state_steps[state.id] > 0


          battler.state_steps[state.id] -= 1


        end


        if battler.state_steps[state.id] == 0


          battler.remove_state(state.id)


          pop_damage


        end


      end


      if state.restriction == 4


        @stopped_movement = 10


        @pattern = 2 if @knockdown_data[0] == 0


      end


      state.features.each do |feature|


        if feature.code == 22


          @knockdown_data[0] =10 if state.restriction == 4 && feature.data_id==1


          next unless feature.data_id.between?(7, 9)


          apply_regen_state(state, feature.data_id)


        end


      end


    end


  end


 


  # apply regen for hp, mp and tp


  def apply_regen_state(state, type)


    random = state.tool_data("State Effect Rand Rate = ")


    random = 120 if random.nil?


    if rand(random) == 1


      battler.regenerate_hp if type == 7


      battler.regenerate_mp if type == 8


      battler.regenerate_tp if type == 9


      if type == 7 and battler.result.hp_damage == 0


        @colapse_time = 80


        battler.add_state(1)


        return


      end


      type == 9 ? pop_damage("Tp Up!") : pop_damage


    end


  end


 


  alias falcaopearl_update_anime_pattern update_anime_pattern


  def update_anime_pattern


    return if @anime_speed > 0 || @knockdown_data[0] > 0


    falcaopearl_update_anime_pattern


  end


 


  #=============================================================================


  # Reset Pearl ABS System


 


  # reset from game player call


  def reset_knockdown_actors


    # reset knock down


    if @knockdown_data[1] != nil


      @knockdown_data[0] = 0


      knowdown_effect(2)


    end


    # force clear knock down


    $game_player.followers.each do |follower|


      if follower.knockdown_data[1] != nil


        follower.knockdown_data[0] = 0


        follower.knowdown_effect(2)


      end


    end


  end


 


  # reset knockdown enemies game player call


  def reset_knockdown_enemies


    $game_map.events.values.each do |event|


      if event.knockdown_data[1] != nil


        event.knockdown_data[0] = 0


        event.knowdown_effect(2)


      end


      if event.deadposee and event.killed


        $game_self_switches[[$game_map.map_id, event.id,


        PearlKernel::KnockdownSelfW]] = false


      end


    end


  end


 


  # glabal reseting


  def pearl_abs_global_reset


    force_cancel_actions


    battler.remove_state(9) if @battler_guarding[0]


    @battler_guarding = [false, nil]


    @making_spiral = false


    set_hook_variables


    @using_custom_g = false


    $game_player.followers.each do |f|


      f.targeted_character = nil if !f.targeted_character.nil?


      f.stuck_timer = 0 if f.stuck_timer > 0


      f.follower_attacktimer = 0 if f.follower_attacktimer > 0


      f.force_cancel_actions unless f.visible?


      f.battler.remove_state(9) if f.battler_guarding[0]


      f.battler_guarding = [false, nil]


      f.set_hook_variables


      f.making_spiral = false


    end


    reset_knockdown_actors


    reset_knockdown_enemies


    $game_player.projectiles.clear


    $game_player.damage_pop.clear


    $game_player.anime_action.clear


    $game_player.enemy_drops.clear


    @send_dispose_signal = true


  end


end





#===============================================================================


# Evets as enemies registration





class Game_Event < Game_Character


  attr_accessor :enemy, :move_type, :page, :deadposee


  attr_accessor :being_targeted, :agroto_f, :draw_drop, :dropped_items


  attr_accessor :start_delay, :epassive, :erased, :killed, :boom_grabdata


  attr_reader   :token_weapon, :token_armor,:token_item,:token_skill,:boom_start


  attr_reader   :hook_pull, :hook_grab, :event, :knockdown_enable, :boom_grab


  attr_reader   :respawn_anim


  alias falcaopearlabs_iniev initialize


  def initialize(map_id, event)


    @inrangeev = nil


    @being_targeted = false


    @agroto_f = nil


    @draw_drop = false


    @dropped_items = []


    @epassive = false


    @touch_damage = 0


    @start_delay = 0


    @touch_atkdelay = 0


    @killed = false


    @knockdown_enable = false


    @deadposee = false


    @respawn_anim = 0


    create_token_arrays


    falcaopearlabs_iniev(map_id, event)


    register_enemy(event)


  end


 


  def create_token_arrays


    @token_weapon = []


    @token_armor  = []


    @token_item   = []


    @token_skill  = []


  end


 


  alias falcaopearl_setup_page_settings setup_page_settings


  def setup_page_settings


    create_token_arrays


    falcaopearl_setup_page_settings


    wtag = string_data("<start_with_weapon: ")


    @token_weapon = wtag.split(",").map { |s| s.to_i } if wtag != nil


    atag = string_data("<start_with_armor: ")


    @token_armor = atag.split(",").map { |s| s.to_i } if atag != nil


    itag = string_data("<start_with_item: ")


    @token_item = itag.split(",").map { |s| s.to_i } if itag != nil


    stag = string_data("<start_with_skill: ")


    @token_skill = stag.split(",").map { |s| s.to_i } if stag != nil


    @hook_pull = string_data("<hook_pull: ") == "true"


    @hook_grab = string_data("<hook_grab: ") == "true"


    @boom_grab = string_data("<boom_grab: ") == "true"


    @boom_start = string_data("<boomed_start: ") == "true"


    @direction_fix = false if @hook_grab


    if has_token? || @hook_pull || @hook_grab || @boom_grab || @boom_start


      $game_map.events_withtags.push(self) unless


      $game_map.events_withtags.include?(self)


    end


  end


 


  def has_token?


    !@token_weapon.empty? || !@token_armor.empty? || !@token_item.empty? ||


    !@token_skill.empty?


  end


 


  def register_enemy(event)


    


    if !$game_system.remain_killed[$game_map.map_id].nil? and


      $game_system.remain_killed[$game_map.map_id].include?(self.id)


      return


    end


    


    @enemy  = Game_Enemy.new(0, $1.to_i) if event.name =~ /<enemy: (.*)>/i


    if @enemy != nil


      passive = @enemy.enemy.tool_data("Enemy Passive = ", false)


      @epassive = true if passive == "true"


      touch = @enemy.enemy.tool_data("Enemy Touch Damage Range = ")


      @sensor = @enemy.esensor


      @touch_damage = touch if touch != nil


      $game_map.event_enemies.push(self) # new separate enemy list


      $game_map.enemies.push(@enemy)     # just enemies used in the cooldown


      @event.pages.each do |page|


        if page.condition.self_switch_valid and


          page.condition.self_switch_ch == PearlKernel::KnockdownSelfW


          @knockdown_enable = true


          break


        end


      end


      pose = @enemy.enemy.tool_data("Enemy Dead Pose = ", false) == "true"


      @deadposee = true if pose and @knockdown_enable


    end


  end


 


  def update_state_effects


    @killed ? return : super


  end


 


  def collapsing?


    return true if @killed || @colapse_time > 0


    return false


  end


 


  def enemy_ready?


    return false if @enemy.nil? || @page.nil? || collapsing? || @enemy.object


    return true


  end


 


  def battler


    return @enemy


  end


 


  def apply_respawn


    return if @colapse_time > 0


    @draw_drop = false


    @dropped_items.clear


    @through = @die_through


    @through = false if @through.nil?


    @die_through = nil


    @secollapse = nil


    @colapse_time = 0


    @erased = false ; @opacity = 255


    @zoomfx_x = 1.0 ; @zoomfx_y = 1.0


    @killed = false


    @priority_type = 1 if @deadposee


    resetdeadpose


    refresh


  end


 


  def resetdeadpose


    if @deadposee


      $game_self_switches[[$game_map.map_id, @id,


      PearlKernel::KnockdownSelfW]] = false


    end


  end


 


  def kill_enemy


    @secollapse = nil


    @killed = true


    @priority_type = 0 if @deadposee


    gain_exp


    gain_gold


    etext = 'Exp '  + @enemy.exp.to_s if @enemy.exp > 0


    gtext = 'Gold ' + @enemy.gold.to_s if @enemy.gold > 0


    $game_player.pop_damage("#{etext} #{gtext}") if etext || gtext


    make_drop_items


    run_assigned_commands


  end


 


  def run_assigned_commands


    transform = @enemy.enemy.tool_data("Enemy Die Transform = ")


    switch = @enemy.enemy.tool_data("Enemy Die Switch = ")


    $game_switches[switch] = true if switch != nil


    variable = @enemy.enemy.tool_data("Enemy Die Variable = ")


    $game_variables[variable] += 1 if variable != nil


    self_sw = @enemy.enemy.tool_data("Enemy Die Self Switch = ", false)


    #$game_map.event_enemies.delete(self) if @enemy.object


    #$game_map.enemies.delete(@enemy) if @enemy.object


    if self_sw.is_a?(String)


      $game_self_switches[[$game_map.map_id, self.id, self_sw]] = true


      apply_respawn


      $game_map.event_enemies.delete(self)


      $game_map.enemies.delete(@enemy)


      unless $game_system.remain_killed.has_key?($game_map.map_id)


        $game_system.remain_killed[$game_map.map_id] = []


      end


      $game_system.remain_killed[$game_map.map_id].push(self.id) unless


      $game_system.remain_killed[$game_map.map_id].include?(self.id)


      @enemy = nil


    else


      erase unless @deadposee


      respawn = @enemy.enemy.tool_data("Enemy Respawn Seconds = ")


      animation = @enemy.enemy.tool_data("Enemy Respawn Animation = ")


      @respawn_count = respawn * 60 unless respawn.nil?


      


      @respawn_anim = animation unless animation.nil?


      


    end


    if transform != nil


      @enemy = Game_Enemy.new(0, transform)


      apply_respawn


    end


  end


 


  def make_drop_items


    @dropped_items = @enemy.make_drop_items


    unless @dropped_items.empty?


      $game_player.enemy_drops.push(self)


      $game_map.events_withtags.push(self) unless


      $game_map.events_withtags.include?(self)


    end


  end


 


  def gain_exp


    return if @enemy.exp == 0


    $game_party.all_members.each do |actor|


      actor.gain_exp(@enemy.exp)


    end


  end


 


  def gain_gold


    return if @enemy.gold == 0


    $game_party.gain_gold(@enemy.gold)


  end


 


  alias falcaopearlabs_updatev update


  def update


    @start_delay -= 1 if @start_delay > 0


    @touch_atkdelay -= 1 if @touch_atkdelay > 0


    update_enemy_sensor unless @enemy.nil?


    update_enemy_touch_damage unless @enemy.nil?


    falcaopearlabs_updatev


  end


 


  def update_enemy_touch_damage


    return unless @touch_damage > 0


    return unless @character_name != ""


    return if @epassive || @killed


    return if @touch_atkdelay > 0


    unless @enemy.object


      @agroto_f.nil? ? target = $game_player : target = @agroto_f


    else


      target = $game_player


      $game_player.followers.each do |follower|


        next unless follower.visible?


        if obj_size?(follower, @touch_damage) and !follower.battler.dead?


          execute_touch_damage(follower)


        end


      end


    end


    execute_touch_damage(target) if obj_size?(target, @touch_damage)


  end


 


  def execute_touch_damage(target)


    target.battler.attack_apply(@enemy)


    target.pop_damage


    @touch_atkdelay = 50


    target.colapse_time = 60 if target.battler.dead?


    return if target.battler.result.hp_damage == 0


    target.jump(0, 0)


  end


 


  # enemy sensor


  def update_enemy_sensor


    return if @hookshoting[0]


    return if @epassive


    if @sensor != nil


      @agroto_f.nil? ? target = $game_player : target = @agroto_f


      if obj_size?(target, @sensor)


        data = [$game_map.map_id, @id, PearlKernel::Enemy_Sensor]


        if @inrangeev.nil? and !$game_self_switches[[data[0], data[1],


          data[2]]]


          $game_self_switches[[data[0], data[1], data[2]]] = true


          @inrangeev = true


        end


      elsif @inrangeev != nil


        data = [$game_map.map_id, @id, PearlKernel::Enemy_Sensor]


        if $game_self_switches[[data[0], data[1], data[2]]]


          $game_self_switches[[data[0], data[1], data[2]]] = false


          @inrangeev = nil


        end


      end


    end


  end


 


  # on battle pixel, take a lot of time procesing, but it is very exact


  def on_battle_pixel?(out=0)


    w = Graphics.width + out; h = Graphics.height + out


    return true if screen_x.between?(0 - out,w) and screen_y.between?(0 - out,h)


    return false


  end





  def cmt_data(comment)


    return 0 if @list.nil? or @list.size <= 0


    for item in @list


      if item.code == 108 or item.code == 408


        return $1.to_i if item.parameters[0] =~ /#{comment}(.*)>/i


      end


    end


    return 0


  end


 


  def string_data(comment)


    return nil if @list.nil? or @list.size <= 0


    for item in @list


      if item.code == 108 or item.code == 408


        return $1.to_s if item.parameters[0] =~ /#{comment}(.*)>/i


      end


    end


    return nil


  end


 


  # stop event movement


  alias falcaopearl_update_self_movement update_self_movement


  def update_self_movement


    return if !@boom_grabdata.nil?


    return if force_stopped? || @colapse_time > 0 || @blowpower[0] > 0


    falcaopearl_update_self_movement


  end


end







class Game_System


  attr_accessor :remain_killed


  alias falcao_fantastic_store_ini initialize


  def initialize


    falcao_fantastic_store_ini


    @remain_killed = {}


  end


end





#===============================================================================





# mist


class Game_Map


  attr_reader   :map


  attr_accessor :event_enemies, :enemies, :events_withtags


  alias falcaopearl_enemycontrol_ini initialize


  def initialize


    @event_enemies = []


    @enemies = []


    @events_withtags = []


    falcaopearl_enemycontrol_ini


  end


 


  alias falcaopearl_enemycontrol_setup setup


  def setup(map_id)


    @event_enemies.clear


    @enemies.clear


    @events_withtags.clear


    falcaopearl_enemycontrol_setup(map_id)


    if $game_temp.loadingg != nil


      @event_enemies.each do |event|


        event.resetdeadpose


      end


      $game_temp.loadingg = nil


    end


  end


 


  alias falcaopearl_damage_floor damage_floor?


  def damage_floor?(x, y)


    return if $game_player.hookshoting[1]


    falcaopearl_damage_floor(x, y)


  end


end





class Game_Temp


  attr_accessor :pop_windowdata, :loadingg


  def pop_w(time, name, text)


    return unless @pop_windowdata.nil?


    @pop_windowdata = [time, text, name]


  end


end





class Game_Party < Game_Unit


  alias falcaopearl_swap_order swap_order


  def swap_order(index1, index2)


    unless SceneManager.scene_is?(Scene_Map)


      if $game_player.in_combat_mode?


        $game_temp.pop_w(180, 'Pearl ABS',


        'You cannot switch player while in combat!')


        return


      elsif $game_player.any_collapsing?


        $game_temp.pop_w(180, 'Pearl ABS',


        'You cannot switch player while collapsing!')


        return


      elsif $game_party.battle_members[index2].deadposing != nil


         $game_temp.pop_w(180, 'Pearl ABS',


        'You cannot move a dead ally!')


        return


      end


    end


    falcaopearl_swap_order(index1, index2)


  end


end





class << DataManager


  alias falcaopearl_extract extract_save_contents


  def DataManager.extract_save_contents(contents)


    falcaopearl_extract(contents)


    $game_temp.loadingg = true


  end


end





 











 





And this one is "Pearl Scenes" (seemed important?):








Spoiler








#===============================================================================
# * Falcao Pearl ABS script shelf # 6
#
# This script handles all scenes related in pearl ABS
#===============================================================================

module PearlScenes

# Cursor icon displayed when selecting a target
CursorIcon = 389

# Status text displayed in the player selection menu
DeathStatus = 'Death' # Displayed when death
BadStatus = 'Bad' # Displayed when 0 to 25% of hp
OverageStatus = 'Overage' # Displayed when 25 to 50% of hp
GoodStatus = 'Good' # Displayed when 50 to 75% of hp
ExellentStatus = 'Exellent' # Displayed when 75 to 100% of hp
end

#===============================================================================
# target slection engine

class Window_EventSelect < Window_Selectable
attr_reader :participants
def initialize(object)
super(0, 0, 150, 192)
self.z = 101
@participants = []
refresh(object)
self.index = 0
self.visible = false
activate
end

def item
return @data[self.index]
end

def refresh(object)
self.contents.clear if self.contents != nil
@data = []
for character in object
if character.is_a?(Game_Event)
if character.on_battle_screen? and character.enemy_ready?
@data.push(character)
character.target_index = @data.size - 1
@participants.push(character)
end
elsif character.on_battle_screen?
next if character.battler.deadposing != nil and
$game_map.map_id != character.battler.deadposing
@data.push(character)
character.target_index = @data.size - 1
@participants.push(character)
end
end
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 26)
for i in 0...@item_max
draw_item(i)
end
end
end

def draw_item(index)
item = @data[index]
x, y = index % col_max * (120 + 32), index / col_max * 24
self.contents.font.size = 16
self.contents.draw_text(x + 24, y, 212, 32, 'none', 0)
end

def item_max
return @item_max.nil? ? 0 : @item_max
end
end

# Scenen events selection target
class Scene_BattlerSelection < Scene_MenuBase

def start
super
@mouse_exist = defined?(Map_Buttons).is_a?(String)
item = $game_player.targeting[1]
if item.is_a?(RPG::Skill) || item.is_a?(RPG::Item)
load_target(item)
else
invoke = item.tool_data("Tool Invoke Skill = ")
if invoke != 0
load_target($data_skills[invoke])
else
@event_window = Window_EventSelect.new($game_map.events.values)
end
end

# info window
@info_window = Sprite.new
@event_window.item.nil? ? t = 'No targets!' : t = 'Select target'
@info_window.bitmap = Bitmap.new(300, 60)
@info_window.z = 900
x, y = Graphics.width / 2 - 300 / 2, Graphics.height / 2 - 60 / 2
@info_window.x = x; @info_window.y = y
@info_window.bitmap.font.size = 30
@info_window.bitmap.font.shadow = true
@info_window.bitmap.draw_text(0, 0, @info_window.width, 32, t, 1)
@info_time = 60
create_cursor unless @event_window.item.nil?
@background_sprite.color.set(16, 16, 16, 70)
end

def create_name_sprites
return if !@name_text.nil?
@name_text = Sprite.new
@name_text.bitmap = Bitmap.new(200, 60)
@name_text.bitmap.font.size = 20
@name_text.bitmap.font.shadow = true
@name_text.x = @event_window.item.screen_x - 100
@name_text.y = @event_window.item.screen_y - 58
text = @event_window.item.battler.name
@name_text.bitmap.draw_text(0, 0, @name_text.width, 32, text, 1)
end

def dispose_name_sprites
return if @name_text.nil?
@name_text.bitmap.dispose
@name_text.dispose
@name_text = nil
end

# load item target
def load_target(item)
if item.scope.between?(1, 6)
@event_window = Window_EventSelect.new($game_map.events.values)
else
targets = []
$game_player.followers.each {|i| targets << i if i.visible?}
targets << $game_player
@event_window = Window_EventSelect.new(targets)
end
end

def refresh_info(type)
@info_window.bitmap.clear
t = 'Invalid Target!' if type == 2
@info_window.bitmap.draw_text(-30, 0, @info_window.width, 32, t, 1)
end

def create_cursor
if @mouse_exist
@cursor = $mouse_cursor
@cursor_zooming = 0 ; update_cursor_position
return
end
@cursor = Sprite.new
icon = PearlScenes::CursorIcon
@cursor.bitmap = Bitmap.new(24, 24)
bitmap = Cache.system("Iconset")
rect = Rect.new(icon % 16 * 24, icon / 16 * 24, 24, 24)
@cursor.bitmap.blt(0, 0, bitmap, rect)
@cursor_zooming = 0
update_cursor_position
end

def update
super
if Input.trigger?:)B)
$game_player.targeting = [false, item=nil, char=nil]
SceneManager.return
Sound.play_cancel
end

@info_time -= 1 if @info_time > 0
if @info_time == 0
@info_window.opacity -= 8 if @info_window.opacity > 0
if @info_window.opacity == 0 and @event_window.item.nil?
Sound.play_cancel
$game_player.targeting = [false, item=nil, char=nil]
SceneManager.return
end
end
return if @event_window.item.nil?
if @mouse_exist
for target in @event_window.participants
if Mouse.map_grid[0] == target.x and Mouse.map_grid[1] == target.y
@event_window.select(target.target_index)
end
end
end

if @current_index != @event_window.index
@current_index = @event_window.index
dispose_name_sprites
create_name_sprites
end

update_cursor_position
update_target_selection
end

# target selection
def update_target_selection
if Input.trigger?:)C)
if @mouse_exist
for event in @event_window.participants
if Mouse.map_grid[0] == event.x and Mouse.map_grid[1] == event.y
@event_window.select(event.target_index)
@selected = true
end
end

if @selected.nil?
refresh_info(2)
@info_time = 60; @info_window.opacity = 255
Sound.play_buzzer
return
end
end
Sound.play_ok
$game_player.targeting[2] = @event_window.item
SceneManager.return
end
end

def update_cursor_position
if @mouse_exist
@cursor.x = Mouse.pos[0]
@cursor.y = Mouse.pos[1]
else
@cursor.x = @event_window.item.screen_x
@cursor.y = @event_window.item.screen_y - 16
end
@cursor_zooming += 1
case @cursor_zooming
when 1..10 ; @cursor.zoom_x -= 0.01 ; @cursor.zoom_y -= 0.01
when 11..20; @cursor.zoom_x += 0.01 ; @cursor.zoom_y += 0.01
when 21..30; @cursor.zoom_x = 1.0 ; @cursor.zoom_y = 1.0
@cursor_zooming = 0
end
end

def terminate
super
@event_window.dispose
@info_window.dispose
@info_window.bitmap.dispose
dispose_name_sprites
if @mouse_exist and !@cursor.nil?
@cursor.zoom_x = 1.0 ; @cursor.zoom_y = 1.0 ; @selected = nil
else
@cursor.dispose unless @cursor.nil?
@cursor.bitmap.dispose unless @cursor.nil?
end
end
end

#===============================================================================
#===============================================================================
# * Player slection engine

# Primary use selection
class Window_Primaryuse < Window_Command
attr_accessor :actor
def initialize(x, y, actor)
@actor = actor
super(x, y)
deactivate ; unselect
end

def window_width() return 544 end
def window_height() return 80 end

def make_command_list
add_command('Weapon ' + Key::Weapon[1], 'Weapon ' + Key::Weapon[1])
add_command('Armor ' + Key::Armor[1], 'Armor ' + Key::Armor[1])
add_command('Item ' + Key::Item[1], 'Item ' + Key::Item[1])
add_command('Item ' + Key::Item2[1], 'Item ' + Key::Item2[1])
add_command('Skill ' + Key::Skill[1], 'Skill ' + Key::Skill[1])
add_command('Skill ' + Key::Skill2[1], 'Skill ' + Key::Skill2[1])
add_command('Skill ' + Key::Skill3[1], 'Skill ' + Key::Skill3[1])
add_command('Skill ' + Key::Skill4[1], 'Skill ' + Key::Skill4[1])
end

def refresh_actor(actor)
@actor = actor
refresh
end

def col_max
return 4
end

def draw_item(index)
contents.font.size = 20
if @actor.primary_use == index + 1
contents.font.color = Color.new(255, 120, 0, 255)
draw_text(item_rect_for_text(index), command_name(index), alignment)
change_color(normal_color, command_enabled?(index))
return
end
super
end
end

class Window_CharacterSet < Window_Selectable
include PearlScenes
def initialize(x=0, y=0)
super(x, y, 544, 156)
refresh
self.index = 0
activate
end

def item
return @data[self.index]
end

def refresh
self.contents.clear if self.contents != nil
@data = []
$game_party.battle_members.each {|actor| @data.push(actor)}
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 26, row_max * 128)
for i in 0...@item_max
draw_item(i)
end
end
end

def draw_item(index)
item = @data[index]
x, y = index % col_max * (138), index / col_max * 130
self.contents.font.size = 20
contents.fill_rect(x, y, item_width, item_height, Color.new(0, 0, 0, 60))
draw_character(item.character_name, item.character_index, x + 22, y + 56)
hp_color = [Color.new(205, 255, 205, 200), Color.new(10, 220, 45, 200)]
mp_color = [Color.new(180, 225, 245, 200), Color.new(20, 160, 225, 200)]
PearlKernel.draw_hp(self.contents, item, x + 4, y + 66, 96, 12, hp_color)
PearlKernel.draw_mp(self.contents, item, x + 4, y + 86, 96, 12, mp_color)
contents.draw_text(x - 2, y, item_width, 32, item.name, 2)
contents.draw_text(x - 2, y + 20, item_width, 32, item.class.name, 2)
case (item.hp.to_f / item.mhp.to_f * 100.0)
when 0 ; text = DeathStatus
when 1..25 ; text = BadStatus
when 26..50 ; text = OverageStatus
when 51..75 ; text = GoodStatus
when 76..100 ; text = ExellentStatus
end
if item.state?(1)
draw_icon($data_states[1].icon_index, x + 50, y + 100)
end
contents.draw_text(x + 4, y + 100, item_width, 32, text) rescue nil
end

def item_max
return @item_max.nil? ? 0 : @item_max
end

def col_max
return 4
end

def line_height
return 130
end
end

class Scene_CharacterSet < Scene_MenuBase
def start
super
x, y = Graphics.width / 2 - 544 / 2, Graphics.height / 2 - 60 / 2
@top_text = Window_Base.new(x, y - 170, 544, 60)
@top_text.draw_text(0, 0, @top_text.width, 32, 'Select your Player', 1)
@window_charset = Window_CharacterSet.new(@top_text.x, @top_text.y + 60)
@primary_info = Window_Base.new(@top_text.x,@window_charset.y + 156, 544,60)
@timer = 0
refresh_primary_info('Press A to set up')
@primary_use = Window_Primaryuse.new(@top_text.x,@primary_info.y + 60,actor)
@primary_use.set_handler('Weapon ' + Key::Weapon[1], method:)apply_item))
@primary_use.set_handler('Armor ' + Key::Armor[1], method:)apply_item))
@primary_use.set_handler('Item ' + Key::Item[1], method:)apply_item))
@primary_use.set_handler('Item ' + Key::Item2[1], method:)apply_item))
@primary_use.set_handler('Skill ' + Key::Skill[1], method:)apply_item))
@primary_use.set_handler('Skill ' + Key::Skill2[1], method:)apply_item))
@primary_use.set_handler('Skill ' + Key::Skill3[1], method:)apply_item))
@primary_use.set_handler('Skill ' + Key::Skill4[1], method:)apply_item))
DisplayTools.create(@primary_use.x + 94, @primary_use.y + 85)
if $game_player.in_combat_mode?
$game_temp.pop_w(180, 'Pearl ABS',
'You cannot switch player while in combat!')
end
@index_char = @window_charset.index
@background_sprite.color.set(16, 16, 16, 70)
end

def apply_item
case @primary_use.current_symbol
when 'Weapon ' + Key::Weapon[1] then actor.primary_use = 1
when 'Armor ' + Key::Armor[1] then actor.primary_use = 2
when 'Item ' + Key::Item[1] then actor.primary_use = 3
when 'Item ' + Key::Item2[1] then actor.primary_use = 4
when 'Skill ' + Key::Skill[1] then actor.primary_use = 5
when 'Skill ' + Key::Skill2[1] then actor.primary_use = 6
when 'Skill ' + Key::Skill3[1] then actor.primary_use = 7
when 'Skill ' + Key::Skill4[1] then actor.primary_use = 8
end
refresh_primary_info(actor.name+ " now use #{@primary_use.current_symbol}!")
@primary_use.refresh_actor(actor)
cancel_setup; @timer = 120
end

def actor
@window_charset.item
end

def refresh_primary_info(text)
@primary_info.contents.clear
@primary_info.contents.font.size = 20
@primary_info.draw_text(0, 0, 544, 32, 'As a follower primarily use tool?')
@primary_info.draw_text(-26, 0, 544, 32, text, 2)
end

def update
super
if $game_player.in_combat_mode?
SceneManager.return if $game_temp.pop_windowdata[0] == 4
return
end
if @timer > 0
@timer -= 1
refresh_primary_info('Press A to set up') if @timer == 0
end
DisplayTools.update
if @index_char != @window_charset.index
@index_char = @window_charset.index
DisplayTools.sprite.actor = actor
DisplayTools.sprite.refresh_icons
DisplayTools.sprite.refresh_texts
@primary_use.refresh_actor(actor)
end
update_cancel if Input.trigger?:)B)
update_player_selection if Input.trigger?:)C)
update_setup if Input.trigger?:)X)
end

def update_setup
return if @primary_use.active
Sound.play_ok
@window_charset.deactivate
@primary_use.activate
@primary_use.select(0)
end

def cancel_setup
@window_charset.activate
@primary_use.deactivate
@primary_use.unselect
end

def update_cancel
Sound.play_cancel
if @window_charset.active
if $game_player.actor.dead?
Sound.play_buzzer
return
end
SceneManager.return
else
cancel_setup
end
end

def update_player_selection
if @window_charset.active
if @window_charset.item.dead?
Sound.play_buzzer
return
end
Sound.play_ok
$game_party.swap_order(0, @window_charset.index)
SceneManager.return
end
end

def terminate
super
@window_charset.dispose
@top_text.dispose
@primary_use.dispose
@primary_info.dispose
DisplayTools.dispose
end
end

#===============================================================================
#===============================================================================
# * Quick tool se3lection engine

class Window_Base < Window
def draw_text_ex2(x, y, text)
text = convert_escape_characters(text)
pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
process_character(text.slice!(0, 1), text, pos) until text.empty?
end
end

# window horizon
class Window_ItemSelect < Window_HorzCommand
def initialize(x=0, y=0)
super(x, y)
end

def window_width() return 460 end
def window_height() return 50 end

def make_command_list
add_command("Weapons", :weapon)
add_command("Left Hand", :armor)
add_command("Items", :item)
add_command("Skills", :skill)
end

def draw_item(index)
contents.font.size = 20
super
end
end

# window slot ask
class Window_SlotConfirm < Window_Command
def initialize(x, y, kind)
@kind = kind
super(x, y)
activate
end

def window_width() return 130 end
def window_height() return @kind == :item ? 80 : 120 end

def make_command_list
case @kind
when :item
add_command('Slot ' + Key::Item[1], :slot1)
add_command('Slot ' + Key::Item2[1], :slot2)
when :skill
add_command('Slot ' + Key::Skill[1], :slot1)
add_command('Slot ' + Key::Skill2[1], :slot2)
add_command('Slot ' + Key::Skill3[1], :slot3)
add_command('Slot ' + Key::Skill4[1], :slot4)
end
end

def draw_item(index)
contents.font.size = 20
super
end
end

# Actor quick tool
class Window_ActorQuickTool < Window_Selectable
def initialize(x=0, y=124, w=460, h=148)
super(x, y, w, h)
unselect
end

def item() return @data[self.index] end
def col_max() return 2 end
def spacing() return 6 end

def refresh(actor, kind)
self.contents.clear if self.contents != nil
@data = []
if kind == :weapon
operand = $game_party.weapons
operand.push(actor.equips[0]) if actor.equips[0] != nil
end
if kind == :armor
operand = $game_party.armors
operand.push(actor.equips[1]) if actor.equips[1] != nil
end
operand = $game_party.items if kind == :item
operand = actor.skills if kind == :skill
for item in operand
if kind == :weapon || kind == :armor
next unless actor.equippable?(item)
next if item.etype_id > 1
end

unless @data.include?(item)
next if item.tool_data("Exclude From Tool Menu = ", false) == "true"
@data.push(item)
end




end
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 24)
for i in 0...@item_max
draw_item(i)
end
end
end

def draw_item(index)
item = @data[index]
x, y = index % col_max * (190 + 32), index / col_max * 24
self.contents.font.size = 20
draw_icon(item.icon_index, x, y)
contents.draw_text(x + 24, y, 212, 32, item.name)
end

def item_max
return @item_max.nil? ? 0 : @item_max
end
end

module DisplayTools

def self.create(x, y)
@viewport2 = Viewport.new ; @viewport2.z = 999
@pearl_tool_sprite = Sprite_PearlTool.new(@viewport2, [x, y])
end

def self.sprite
return @pearl_tool_sprite
end

def self.update
@pearl_tool_sprite.update
end
def self.dispose
@pearl_tool_sprite.dispose ; @viewport2.dispose
@viewport2 = nil ; @pearl_tool_sprite = nil
end
end


# Scene quick tool
class Scene_QuickTool < Scene_MenuBase
def start
super
x, y = Graphics.width / 2 - 460 / 2, Graphics.height / 2 - 85 / 2
@top_text = Window_Base.new(x, y - 156, 460, 85)
@statust = ['Ready', 0]
refresh_top_info
@type_select = Window_ItemSelect.new(@top_text.x, @top_text.y + 85)
@type_select.set_handler:)weapon, method:)refresh_tools))
@type_select.set_handler:)armor, method:)refresh_tools))
@type_select.set_handler:)item, method:)refresh_tools))
@type_select.set_handler:)skill, method:)refresh_tools))
@type_select.set_handler:)cancel, method:)refresh_cancel))
@type_index = @type_select.index
@items_w = Window_ActorQuickTool.new(@type_select.x, @type_select.y + 50)
@items_w.refresh($game_player.actor, @type_select.current_symbol)
@description = Window_Base.new(@items_w.x, @items_w.y + 148, 460, 75)
DisplayTools.create(@description.x + 75, @description.y + 80)
@background_sprite.color.set(16, 16, 16, 70)
end

# create slot confirm
def create_slot_confirm
@slot_confirm = Window_SlotConfirm.new(@items_w.x + 144, @items_w.y + 36,
@type_select.current_symbol)
if @type_select.current_symbol == :item
@slot_confirm.set_handler:)slot1, method:)open_slots))
@slot_confirm.set_handler:)slot2, method:)open_slots))
else
@slot_confirm.set_handler:)slot1, method:)open_slots))
@slot_confirm.set_handler:)slot2, method:)open_slots))
@slot_confirm.set_handler:)slot3, method:)open_slots))
@slot_confirm.set_handler:)slot4, method:)open_slots))
end
end

# dispose slot confirm
def dispose_slot_confirm
return if @slot_confirm.nil?
@slot_confirm.dispose
@slot_confirm = nil
end

# top info
def refresh_top_info
@top_text.contents.clear
@top_text.contents.font.size = 20
@top_text.contents.fill_rect(0, 0, 58, 74, Color.new(0, 0, 0, 60))
@top_text.draw_character(actor.character_name,actor.character_index, 26, 60)
@top_text.draw_text(62, 0, @top_text.width, 32, actor.name + ' Equippment')
@top_text.draw_text(62, 22, @top_text.width, 32, actor.class.name)
@top_text.draw_text(-22, 30, @top_text.width, 32, @statust[0], 2)
@top_text.draw_text(-22, 0,@top_text.width,32, 'M = Switch Player',2) unless
PearlKernel::SinglePlayer
end

def refresh_tools
enable_items
end

def refresh_cancel
SceneManager.return
end

def enable_items
@items_w.activate
@items_w.select(0)
end

def refresh_description
@description.contents.clear
@desc_index = @items_w.index
return if @items_w.item.nil? || @items_w.index < 0
@description.contents.font.size = 20
@description.draw_text_ex2(0, -4, @items_w.item.description)
end

def update
super
perform_item_ok if Input.trigger?:)C)
perform_canceling if Input.trigger?:)B)
if PearlKey.trigger?(Key::playerSelect) and !PearlKernel::SinglePlayer
Sound.play_ok
SceneManager.call(Scene_CharacterSet)
end
DisplayTools.update
perform_refresh
end

def perform_item_ok
return if @items_w.item.nil?
case @type_select.current_symbol
when :weapon
actor.change_equip_by_id(0, @items_w.item.id)
equip_play
when :armor
actor.change_equip_by_id(1, @items_w.item.id)
equip_play
when :item
activate_slots
when :skill
activate_slots
end
DisplayTools.sprite.refresh_texts
end

def activate_slots
@items_w.deactivate
create_slot_confirm
Sound.play_ok
end

def deactivate_slots
@items_w.activate
dispose_slot_confirm
end

def actor
return $game_player.actor
end

def equip_play
Sound.play_equip
@statust[1] = 80
end

# open slots
def open_slots
if @type_select.current_symbol == :item
case @slot_confirm.current_symbol
when :slot1 then actor.assigned_item = @items_w.item
when :slot2 then actor.assigned_item2 = @items_w.item
end
else
case @slot_confirm.current_symbol
when :slot1 then actor.assigned_skill = @items_w.item
when :slot2 then actor.assigned_skill2 = @items_w.item
when :slot3 then actor.assigned_skill3 = @items_w.item
when :slot4 then actor.assigned_skill4 = @items_w.item
end
end
equip_play ; deactivate_slots
DisplayTools.sprite.refresh_texts
end

def perform_canceling
Sound.play_cancel
if @items_w.active
@items_w.deactivate
@items_w.unselect
@type_select.activate
else
deactivate_slots
end
end

def perform_refresh
if @type_index != @type_select.index
@type_index = @type_select.index
@items_w.refresh($game_player.actor, @type_select.current_symbol)
refresh_description
end
if @desc_index != @items_w.index
@desc_index = @items_w.index
refresh_description
end
if @statust[1] > 0
@statust[1] -= 1
if @statust[1] == 78
@statust[0] = @items_w.item.name + ' Equipped'
refresh_top_info
elsif @statust[1] == 0
@statust = ['Ready', 0]
refresh_top_info
end
end
end

def terminate
super
@top_text.dispose
@type_select.dispose
@items_w.dispose
@description.dispose
dispose_slot_confirm
DisplayTools.dispose
end
end



 











 

Latest Threads

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,049
Messages
1,018,547
Members
137,835
Latest member
yetisteven
Top