查看: 813|回复: 2

[已经解决] 如何把这个ABS系统的血条背景改没?

[复制链接]
梦石
0
星屑
401
在线时间
330 小时
注册时间
2013-8-24
回帖
81
发表于 2016-8-19 21:10:15 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
hp.png
脚本盲一个
自己改成这样了,最后只要把HP的背景改没就好了,然而怎么删减都无果

求教各位大触T T

有关的脚本↓

  1. #===============================================================================
  2. # * Falcao Pearl ABS script shelf # 1
  3. #
  4. # This script is the Heart of Pearl ABS Liquid, it handles all the character
  5. # management, the tools variables and the input module, enemy registration etc.
  6. # 这个脚本是ABS的核心部分,他控制了所有的字符、模块等
  7. #===============================================================================

  8. module PearlKernel
  9.   
  10.   # 默认敌人自身开关为“B”【Default enemy sensor self switch】
  11.   Enemy_Sensor = "B"
  12.   
  13.   # 默认敌人感知距离【Default enemy sensor (distance in tiles the enemy is able to see the Player】
  14.   Sensor = 7
  15.   
  16.   # 默认敌人自身事件页上的击倒开关“C”,用来显示击倒图像【Default enemy knockdown self switch (used to display knockdowned graphic)】
  17.   KnockdownSelfW = "C"
  18.   
  19.   # 默认敌人消失方式【Deafault Enemy collapse】
  20.   DefaultCollapse = 'zoom_vertical'
  21.   
  22.   # 在团战中,玩家是整个队伍的指挥者【While in party battle on map, the game player is the manager of the group】
  23.   # 在距离为多少时,玩家可以看到敌人?这决定了随从是否可以开始战斗【Which distance the player can see the enemies?, this is used, to determine wheter the follower can start fighting. 】
  24.   # 在玩家达到指定距离之前,敌人会被无视【enemy away from this tiles whil be ignored untill the player is near them】
  25.   # 距离靠(地砖)空格计算【distamce measured in tiles】
  26.   PlayerRange = 7
  27.   
  28.   # 当随从的动作失败时,这个balloon就会启动,能量会归0【When a follower fail an action this balloon is played, runs out of mana etc.】
  29.   FailBalloon = 1
  30.   
  31.   # 开始游戏是,是否展开ABS的HUD条?【Start the game with the ABS huds turned on?】
  32.   StartWithHud = false
  33.   
  34.   # 你是否想要激活随从死的花样?【Do you want to activate the followers dead poses?】
  35.   FollowerDeadPose = true
  36.   
  37.   # 你是否想要激活单人游戏模式?【Do you want to activate the single player mode?】
  38.   # 这让你无法进入人员选择菜单,K键也被设置为打开快速工具选择栏【this only avoid you accesing the player slection menu and the K key is used to open the quick tool selection menu】
  39.   SinglePlayer = true
  40.   
  41.   #-----------------------------------------------------------------------------
  42.   @gaugeback = Color.new(0, 0, 0, 100)
  43.   def self.draw_hp(obj, battler, x, y, w, h, color, name=nil)
  44.     tag = 'Hp' ; c = color
  45.     name = battler.name if !name.nil?
  46.     draw_gauge(obj, battler.hp, battler.mhp, x, y, w, h, c, tag, name)
  47.   end
  48.   
  49.   def self.draw_mp(obj, battler, x, y, w, h, color, name=nil)
  50.     tag = 'Mp' ; c = color
  51.     name = battler.name if !name.nil?
  52.     draw_gauge(obj, battler.mp, battler.mmp, x, y, w, h, c, tag, name)
  53.   end
  54.   
  55. # def self.draw_exp(obj, battler, x, y, w, h, color, name=nil)
  56. #   tag = 'Exp' ; c = color
  57. #   name = battler.name if !name.nil?
  58. #   draw_gauge(obj,battler.exp, battler.next_level_exp, x, y, w, h, c, tag,name)
  59. # end
  60.   
  61. # def self.draw_tp(obj, x, y, actor)
  62. #   string = 'Tp ' + (actor.tp).to_i.to_s
  63. #   obj.fill_rect(x, y + 10 , string.length * 9, 12, @gaugeback)
  64. #   obj.draw_text(x, y, obj.width, 32, string)
  65. # end
  66.   
  67.   def self.draw_gauge(obj, nm, max, x, y, w, h, col, tag, name)
  68.     obj.font.shadow = true
  69.     w2 = w - 2 ; max = 1 if max == 0
  70.     obj.fill_rect(x, y - 1, w, h + 2, @gaugeback)
  71.     obj.fill_rect(x+1, y+1, w2*nm/max, h/2 - 1, col[0])
  72.     obj.fill_rect(x+1, y + h/2, w2*nm/max, h/2 - 1, col[1])
  73.     obj.draw_text(x, y + h - 22, w, 32, nm.to_s, 2)
  74.     obj.draw_text(x + 4, y + h - 22, w, 32, tag)
  75.     obj.draw_text(x, y - 25, w, 32, name, 1) if !name.nil?
  76.   end
  77.   
  78.   # image based bars definition
  79.   def self.image_hp(bitmap, x, y, back, image, battler, name=nil)
  80.     tag = 'Hp'
  81.     name = battler.name if !name.nil?
  82.     draw_i_gauge(bitmap, x, y, back, image, battler.hp, battler.mhp, tag, name)
  83.   end
  84.   
  85.   def self.image_mp(bitmap, x, y, back, image, battler, name=nil)
  86.     tag = 'Mp'
  87.     name = battler.name if !name.nil?
  88.     draw_i_gauge(bitmap, x, y, back, image, battler.mp, battler.mmp, tag, name)
  89.   end
  90.   
  91. # def self.image_exp(bitmap, x, y, back, image, battler, name=nil)
  92. #   tag = 'Exp'
  93. #   name = battler.name if !name.nil?
  94. #   exp, nexte = battler.exp, battler.next_level_exp
  95. #   draw_i_gauge(bitmap, x, y, back, image, exp, nexte, tag, name)
  96. # end
  97.   
  98.   def self.draw_i_gauge(bitmap, x, y, back, image, nm, max, tag, name)
  99.     cw = back.width  
  100.     ch = back.height
  101.     max = 1 if max == 0
  102.     src_rect = Rect.new(0, 0, cw, ch)   
  103.     bitmap.blt(x - 12, y - ch + 30, back, src_rect)#这里与背景有关
  104.     cw = image.width  * nm / max
  105.     ch = image.height
  106.     src_rect = Rect.new(0, 0, cw, ch)
  107.     bitmap.blt(x - -35, y - ch + 23, image, src_rect)
  108.    # bitmap.draw_text(x - 4, y + back.height - 14, back.width, 32, tag)
  109.    # bitmap.draw_text(x - 12, y + back.height - 14, back.width, 32, nm.to_s, 2)
  110.    # bitmap.draw_text(x - 6, y - 10, back.width, 32, name, 1) if !name.nil?
  111.   end
  112.   
  113.   def self.has_data?
  114.     !user_graphic.nil?
  115.   end
  116.   
  117.   def self.load_item(item)
  118.     @item = item
  119.   end
  120.   
  121.   def self.user_graphic()      @item.tool_data("User Graphic = ", false)    end
  122.   def self.user_animespeed()   @item.tool_data("User Anime Speed = ")       end
  123.   def self.tool_cooldown()     @item.tool_data("Tool Cooldown = ")          end
  124.   def self.tool_graphic()      @item.tool_data("Tool Graphic = ", false)    end
  125.   def self.tool_index()        @item.tool_data("Tool Index = ")             end
  126.   def self.tool_size()         @item.tool_data("Tool Size = ")              end
  127.   def self.tool_distance()     @item.tool_data("Tool Distance = ")          end
  128.   def self.tool_effectdelay()  @item.tool_data("Tool Effect Delay = ")      end
  129.   def self.tool_destroydelay() @item.tool_data("Tool Destroy Delay = ")     end
  130.   def self.tool_speed()         @item.tool_float("Tool Speed = ")            end
  131.   def self.tool_castime()       @item.tool_data("Tool Cast Time = ")         end
  132.   def self.tool_castanimation() @item.tool_data("Tool Cast Animation = ")    end
  133.   def self.tool_blowpower()     @item.tool_data("Tool Blow Power = ")        end
  134.   def self.tool_piercing()      @item.tool_data("Tool Piercing = ", false)   end
  135.   def self.tool_animation() @item.tool_data("Tool Animation When = ", false) end
  136.   def self.tool_anirepeat() @item.tool_data("Tool Animation Repeat = ",false)end
  137.   def self.tool_special() @item.tool_data("Tool Special = ", false)          end
  138.   def self.tool_target() @item.tool_data("Tool Target = ", false)            end
  139.   def self.tool_invoke() @item.tool_data("Tool Invoke Skill = ")             end
  140.   def self.tool_guardrate() @item.tool_data("Tool Guard Rate = ")            end
  141.   def self.tool_knockdown() @item.tool_data("Tool Knockdown Rate = ")        end
  142.   def self.tool_soundse() @item.tool_data("Tool Sound Se = ", false)         end
  143.   def self.tool_itemcost() @item.tool_data("Tool Item Cost = ")              end
  144.   def self.tool_shortjump() @item.tool_data("Tool Short Jump = ", false)     end
  145.   def self.tool_through() @item.tool_data("Tool Through = ", false)          end
  146.   def self.tool_priority() @item.tool_data("Tool Priority = ")               end
  147.   def self.tool_selfdamage() @item.tool_data("Tool Self Damage = ", false)   end
  148.   def self.tool_hitshake() @item.tool_data("Tool Hit Shake = ", false)       end
  149.   def self.tool_combo() @item.tool_data("Tool Combo Tool = ", false)         end
  150.   
  151.   def self.knock_actor(actor)
  152.     a = actor.actor.tool_data("Knockdown Graphic = ", false)
  153.     b = actor.actor.tool_data("Knockdown Index = ")
  154.     c = actor.actor.tool_data("Knockdown pattern = ")
  155.     d = actor.actor.tool_data("Knockdown Direction = ")
  156.     return nil if a.nil?
  157.     return [a, b, c, d]
  158.   end
  159.   
  160.   def self.jump_hit?(target)
  161.     t = target.enemy.tool_data("Hit Jump = ", false) if target.is_a?(Game_Enemy)
  162.     t = target.actor.tool_data("Hit Jump = ", false) if target.is_a?(Game_Actor)
  163.     return true if !t.nil? and t == "true"
  164.     return true if t.nil?
  165.     return false
  166.   end
  167.   
  168.   def self.voices(b)
  169.     voices = b.actor.tool_data("Battler Voices = ",false) if b.is_a?(Game_Actor)
  170.     voices = b.enemy.tool_data("Battler Voices = ",false) if b.is_a?(Game_Enemy)
  171.     voices = voices.split(", ") unless voices.nil?
  172.     voices
  173.   end
  174.   
  175.   def self.hitvoices(b)
  176.     voices = b.actor.tool_data("Hit Voices = ",false) if b.is_a?(Game_Actor)
  177.     voices = b.enemy.tool_data("Hit Voices = ",false) if b.is_a?(Game_Enemy)
  178.     voices = voices.split(", ") unless voices.nil?
  179.     voices
  180.   end
  181.   
  182.   # check for iconset
  183.   def self.check_iconset(item, tag, object)
  184.     data = item.tool_data(tag, false)
  185.     return if data.nil?
  186.     v = [item.icon_index, data.to_sym] if data == "animated" ||
  187.     data == "static" || data == "shielding"
  188.     object.is_a?(Projectile) ? object.pro_iconset = v : object.user_iconset = v
  189.   end
  190.   
  191.   def self.clean_back?
  192.     @clean_back == true
  193.   end
  194. end

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

  196. class RPG::BaseItem
  197.   attr_reader :has_data
  198.   def tool_data(comment, sw=true)
  199.     if @note =~ /#{comment}(.*)/i
  200.       @has_data = true
  201.       return sw ? $1.to_i : $1.to_s.sub("\r","")
  202.     end
  203.   end
  204.   
  205.   def tool_float(comment)
  206.     return  $1.to_f if @note =~ /#{comment}(.*)/i
  207.   end
  208.   
  209.   def cool_enabled?
  210.     @cd_dis = @note.include?("Tool Cooldown Display = true") if @cd_dis.nil?
  211.     @cd_dis
  212.   end
  213.   
  214.   def itemcost
  215.     if @i_cost.nil?
  216.       @note =~ /Tool Item Cost = (.*)/i ? @i_cost = $1.to_i : @i_cost = 0
  217.     end
  218.     @i_cost
  219.   end
  220. end

  221. # Pearl ABS Input module
  222. module PearlKey

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

  233.   @unpack_string = 'b'*256
  234.   @last_array = '0'*256
  235.   @press = Array.new(256, false)
  236.   @trigger = Array.new(256, false)
  237.   @release = Array.new(256, false)
  238.   @getKeyboardState = Win32API.new('user32', 'GetKeyboardState', ['P'], 'V')
  239.   @getAsyncKeyState = Win32API.new('user32', 'GetAsyncKeyState', 'i', 'i')
  240.   @getKeyboardState.call(@last_array)
  241.   
  242.   @last_array = @last_array.unpack(@unpack_string)
  243.   for i in [email]0...@last_array.size[/email]
  244.     @press[i] = @getAsyncKeyState.call(i) == 0 ? false : true
  245.   end

  246.   def self.update
  247.     @trigger = Array.new(256, false)
  248.     @release = Array.new(256, false)
  249.     array = '0'*256
  250.     @getKeyboardState.call(array)
  251.     array = array.unpack(@unpack_string)
  252.     for i in 0...array.size
  253.       if array[i] != @last_array[i]
  254.         @press[i] = @getAsyncKeyState.call(i) == 0 ? false : true
  255.         if !@press[i]
  256.           @release[i] = true
  257.         else
  258.           @trigger[i] = true
  259.         end
  260.       else
  261.         if @press[i] == true
  262.           @press[i] = @getAsyncKeyState.call(i) == 0 ? false : true
  263.           @release[i] = true if !@press[i]
  264.         end
  265.       end
  266.     end
  267.     @last_array = array
  268.   end
  269.   
  270.   def self.press?(key)
  271.     return @press[key]
  272.   end

  273.   def self.trigger?(key)
  274.     return @trigger[key]
  275.   end
  276. end

  277. # Input module update engine
  278. class << Input
  279.   alias falcaopearl_abs_cooldown_update update
  280.   def Input.update
  281.     update_pearl_abs_cooldown
  282.     update_popwindow if !$game_temp.nil? and !$game_temp.pop_windowdata.nil?
  283.     update_pearl_abs_respawn
  284.     falcaopearl_abs_cooldown_update
  285.   end
  286.   
  287.   
  288.   def update_pearl_abs_respawn
  289.     $game_map.event_enemies.each do |event|
  290.       if event.respawn_count > 0
  291.         event.respawn_count -= 1
  292.         if event.respawn_count == 0
  293.           event.battler.remove_state(event.battler.death_state_id)
  294.           event.battler.hp = event.battler.mhp
  295.           event.battler.mp = event.battler.mmp
  296.           event.apply_respawn
  297.           event.animation_id = event.respawn_anim
  298.         end
  299.       end
  300.     end
  301.   end
  302.   
  303.   alias falcaopearl_trigger trigger?
  304.   def trigger?(constant)
  305.     return true if constant == :B and PearlKey.trigger?(PearlKey::B)
  306.     falcaopearl_trigger(constant)
  307.   end
  308.   
  309.   # pop window global
  310.   def update_popwindow
  311.     $game_temp.pop_windowdata[0] -= 1 if $game_temp.pop_windowdata[0] > 0
  312.     if @temp_window.nil?
  313.       tag = $game_temp.pop_windowdata[2]
  314.       string = $game_temp.pop_windowdata[1] + tag
  315.       width = (string.length * 9) - 10
  316.       x, y = Graphics.width / 2 - width / 2,  Graphics.height / 2 - 64 / 2
  317.       @temp_window = Window_Base.new(x, y, width, 64)
  318.       @temp_window.contents.font.size = 20
  319.       @temp_window.draw_text(-10, -6, width, 32, tag, 1)
  320.       @temp_window.draw_text(-10, 14, width, 32, $game_temp.pop_windowdata[1],1)
  321.       @current_scene = SceneManager.scene.class
  322.     end
  323.    
  324.     if $game_temp.pop_windowdata[0] == 0 ||
  325.       @current_scene != SceneManager.scene.class
  326.       @temp_window.dispose
  327.       @temp_window = nil
  328.       $game_temp.pop_windowdata = nil
  329.     end
  330.   end
  331.   
  332.   def update_pearl_abs_cooldown
  333.     PearlKey.update
  334.     eval_cooldown($game_party.all_members) if !$game_party.nil?
  335.     eval_cooldown($game_map.enemies) if !$game_map.nil?
  336.   end
  337.   
  338.   # cooldown update
  339.   def eval_cooldown(operand)
  340.     for sub in operand
  341.       sub.skill_cooldown.each {|sid, sv| # skill
  342.       if sub.skill_cooldown[sid] > 0
  343.         sub.skill_cooldown[sid] -= 1
  344.         sub.skill_cooldown.delete(sid) if sub.skill_cooldown[sid] == 0
  345.       end}
  346.       sub.item_cooldown.each {|iid, iv| # item
  347.       if sub.item_cooldown[iid] > 0
  348.         sub.item_cooldown[iid] -= 1
  349.         sub.item_cooldown.delete(iid) if sub.item_cooldown[iid] == 0
  350.       end}
  351.       sub.weapon_cooldown.each {|wid, wv| # weapon
  352.       if sub.weapon_cooldown[wid] > 0
  353.         sub.weapon_cooldown[wid] -= 1
  354.         sub.weapon_cooldown.delete(wid) if sub.weapon_cooldown[wid] == 0
  355.       end}
  356.       sub.armor_cooldown.each {|aid, av| #armor
  357.       if sub.armor_cooldown[aid] > 0
  358.         sub.armor_cooldown[aid] -= 1
  359.         sub.armor_cooldown.delete(aid) if sub.armor_cooldown[aid] == 0
  360.       end}
  361.     end
  362.   end
  363. end

  364. #===============================================================================
  365. #===============================================================================
  366. # Game character

  367. class Game_CharacterBase
  368.   attr_accessor :just_hitted, :anime_speed, :blowpower, :targeting, :x, :y
  369.   attr_accessor :battler_guarding, :knockdown_data, :colapse_time, :opacity
  370.   attr_accessor :zoomfx_x, :zoomfx_y, :targeted_character, :stuck_timer
  371.   attr_accessor :send_dispose_signal, :follower_attacktimer, :stopped_movement
  372.   attr_accessor :hookshoting, :battler_chain, :pattern, :user_move_distance
  373.   attr_accessor :move_speed, :through, :being_grabbed, :making_spiral
  374.   attr_accessor :direction, :direction_fix, :zfx_bol, :buff_pop_stack
  375.   attr_accessor :die_through, :target_index, :using_custom_g, :combodata
  376.   attr_accessor :originalasp, :doingcombo, :angle_fx
  377.   attr_accessor :user_iconset, :pro_iconset, :respawn_count
  378.   alias falcaopearl_abmain_ini initialize
  379.   def initialize
  380.     @zfx_bol = false
  381.     @just_hitted = 0
  382.     @anime_speed = 0
  383.     @respawn_count = 0
  384.     @blowpower = [0, dir=2, dirfix=false, s=4, wait_reset=0]
  385.     @user_casting = [0, nil]
  386.     @send_dispose_signal = false
  387.     @targeting = [false, item=nil, char=nil]
  388.     @colapse_time = 0
  389.     @stopped_movement = 0
  390.     @follower_attacktimer = 0
  391.     set_hook_variables
  392.     @target_index = 0
  393.     @using_custom_g = false
  394.     @combodata = []
  395.     @angle_fx = 0.0
  396.     #--------------
  397.     @zoomfx_x = 1.0
  398.     @zoomfx_y = 1.0
  399.     @stuck_timer = 0
  400.     @battler_guarding = [false, nil]
  401.     @knockdown_data = [0, nil, nil, nil, nil]
  402.     @state_poptimer = [0, 0]
  403.     @making_spiral = false
  404.     @buff_pop_stack = []
  405.     @doingcombo = 0
  406.     @range_view = 2
  407.     @originalasp = 0
  408.     falcaopearl_abmain_ini
  409.   end
  410.   
  411.   def set_hook_variables
  412.     @hookshoting = [on=false, hooking=false, grabing=false, delay=0]
  413.     @battler_chain = []
  414.     @user_move_distance = [steps=0, speed=nil, trought=nil, cor=nil, evmove=nil]
  415.     @being_grabbed = false
  416.   end

  417.   # projectiles at nt
  418.   def projectiles_xy_nt(x, y)
  419.     $game_player.projectiles.select {|pro| pro.pos_nt?(x, y) }
  420.   end
  421.   
  422.   # collide with projectiles
  423.   def collide_with_projectiles?(x, y)
  424.     projectiles_xy_nt(x, y).any? do |pro|
  425.       pro.normal_priority? || self.is_a?(Projectile)
  426.     end
  427.   end
  428.   
  429.   def zoom(x, y)
  430.     @zoomfx_x = x
  431.     @zoomfx_y = y
  432.   end
  433.   
  434.   alias falcaopearl_collide_with collide_with_characters?
  435.   def collide_with_characters?(x, y)
  436.     return true if collide_with_projectiles?(x, y)
  437.     falcaopearl_collide_with(x, y)
  438.   end
  439.   
  440.   # follow character straigh and diagonal
  441.   def follow_char(character)
  442.     sx = distance_x_from(character.x)
  443.     sy = distance_y_from(character.y)
  444.     if sx != 0 && sy != 0
  445.       move_diagonal(sx > 0 ? 4 : 6, sy > 0 ? 8 : 2)
  446.     elsif sx != 0
  447.       move_straight(sx > 0 ? 4 : 6)
  448.     elsif sy != 0
  449.       move_straight(sy > 0 ? 8 : 2)
  450.     end
  451.   end
  452.   
  453.   def on_battle_screen?(out = 0)
  454.     max_w = (Graphics.width / 32).to_i - 1
  455.     max_h = (Graphics.height / 32).to_i - 1
  456.     sx = (screen_x / 32).to_i
  457.     sy = (screen_y / 32).to_i
  458.     if sx.between?(0 - out, max_w + out) and sy.between?(0 - out, max_h + out)
  459.       return true
  460.     end
  461.     return false
  462.   end
  463.   
  464.    # jump to specific tiles
  465.   def jumpto_tile(x, y)
  466.     jumpto(0, [x, y])
  467.   end
  468.   
  469.   # jumpto character ( 0 = Game Player, 1 and up event id)
  470.   def jumpto(char_id, tilexy=nil)
  471.     char_id > 0 ? char = $game_map.events[char_id] : char = $game_player
  472.     tilexy.nil? ? condxy = [char.x, char.y] : condxy = [tilexy[0], tilexy[1]]
  473.     jx = + eval_distance(tilexy.nil? ? char : tilexy)[0] if condxy[0] >= @x
  474.     jy = - eval_distance(tilexy.nil? ? char : tilexy)[1] if condxy[1] <= @y
  475.     jx = - eval_distance(tilexy.nil? ? char : tilexy)[0] if condxy[0] <= @x
  476.     jy = - eval_distance(tilexy.nil? ? char : tilexy)[1] if condxy[1] <= @y
  477.     jx = - eval_distance(tilexy.nil? ? char : tilexy)[0] if condxy[0] <= @x
  478.     jy = + eval_distance(tilexy.nil? ? char : tilexy)[1] if condxy[1] >= @y
  479.     jx = + eval_distance(tilexy.nil? ? char : tilexy)[0] if condxy[0] >= @x
  480.     jy = + eval_distance(tilexy.nil? ? char : tilexy)[1] if condxy[1] >= @y
  481.     jump(jx, jy)
  482.   end
  483.   
  484.   # distance
  485.   def eval_distance(target)
  486.     if target.is_a?(Array)
  487.       distance_x = (@x - target[0]).abs
  488.       distance_y = (@y - target[1]).abs
  489.     else
  490.       distance_x = (@x - target.x).abs
  491.       distance_y = (@y - target.y).abs
  492.     end
  493.     return [distance_x, distance_y]
  494.   end
  495.   
  496.   # check if the game player and follower are executing an action
  497.   def battler_acting?
  498.     return true if @user_casting[0] > 0 || @targeting[0]
  499.     return true if @knockdown_data[0] > 0 and battler.deadposing.nil?
  500.     return true if @anime_speed > 0
  501.     return true if @hookshoting[0] || @making_spiral
  502.     if self.is_a?(Game_Player)
  503.       $game_player.followers.each {|f| return true if f.battler_acting?}
  504.     end
  505.     return false
  506.   end

  507.   def battler
  508.   end
  509.   
  510.   #use single tools
  511.   def use_weapon(id)
  512.     return unless tool_can_use?
  513.     process_tool_action($data_weapons[id])
  514.   end
  515.   
  516.   def use_item(id)
  517.     return unless tool_can_use?
  518.     process_tool_action($data_items[id])
  519.   end
  520.   
  521.   def use_skill(id)
  522.     return unless tool_can_use?
  523.     process_tool_action($data_skills[id])
  524.   end
  525.   
  526.   def use_armor(id)
  527.     return unless tool_can_use?
  528.     process_tool_action($data_armors[id])
  529.   end
  530.   
  531.   # use multiple tools
  532.   def rand_weapon(*args)
  533.     return unless tool_can_use?
  534.     process_tool_action($data_weapons[args[rand(args.size)]])
  535.   end
  536.   
  537.   def rand_item(*args)
  538.     return unless tool_can_use?
  539.     process_tool_action($data_items[args[rand(args.size)]])
  540.   end
  541.   
  542.   def rand_skill(*args)
  543.     return unless tool_can_use?
  544.     process_tool_action($data_skills[args[rand(args.size)]])
  545.   end
  546.   
  547.   def rand_armor(*args)
  548.     return unless tool_can_use?
  549.     process_tool_action($data_armors[args[rand(args.size)]])
  550.   end
  551.   
  552.   def tool_can_use?
  553.     return false if @hookshoting[0] || @making_spiral
  554.     return false if @user_casting[0] > 0 || @targeting[0]
  555.     return false if battler.nil?
  556.     return false if battler.dead?
  557.     return false if @doingcombo > 0 || @battler_guarding[0]
  558.     return false if $game_message.busy?
  559.     return true
  560.   end
  561.   
  562.   def load_target_selection(item)
  563.     @targeting[0] = true; @targeting[1] = item
  564.     if self.is_a?(Game_Player)
  565.       $game_player.pearl_menu_call = [:battler, 2]
  566.     elsif self.is_a?(Game_Follower)
  567.       @targeting[2] = @targeted_character
  568.       @targeting = [false, item=nil, char=nil] if @targeting[2].nil?
  569.     elsif self.is_a?(Projectile)
  570.       if user.is_a?(Game_Player)
  571.         user.targeting[0] = true; user.targeting[1] = item
  572.         $game_player.pearl_menu_call = [:battler, 2]
  573.       end
  574.       if user.is_a?(Game_Follower)
  575.         @targeting[2] = user.targeted_character
  576.         @targeting = [false, item=nil, char=nil] if @targeting[2].nil?
  577.       end
  578.     end
  579.   end
  580.   
  581.   def playdead
  582.     @angle_fx = 90
  583.   end
  584.   
  585.   def resetplaydead
  586.     @angle_fx = 0.0
  587.   end

  588.   #action canceling
  589.   def force_cancel_actions
  590.     @user_casting[0] = 0
  591.     @anime_speed = 0
  592.   end
  593.   
  594.   def speed(x)
  595.     @move_speed = x
  596.   end
  597.   
  598.   def anima(x)
  599.     @animation_id = x
  600.   end
  601.   
  602.   # aply melee params
  603.   def apply_weapon_param(weapon, add)
  604.     id = 0
  605.     for param in weapon.params
  606.       add ? battler.add_param(id, param) : battler.add_param(id, -param)
  607.       id += 1
  608.     end
  609.   end
  610.   
  611.   # Short script call for poping damage text
  612.   def pop_damage(custom=nil)
  613.     $game_player.damage_pop.push(DamagePop_Obj.new(self, custom))
  614.   end
  615.   
  616.   #check if target is unable to move
  617.   def force_stopped?
  618.     return true if @anime_speed > 0 || @knockdown_data[0] > 0 ||
  619.     @stopped_movement > 0 || @hookshoting[0] || @angle_fx != 0.0
  620.     return true if @making_spiral
  621.     return false
  622.   end
  623.   
  624.   # sensor
  625.   def obj_size?(target, size)
  626.     return false if size.nil?
  627.     distance = (@x - target.x).abs + (@y - target.y).abs
  628.     enable   = (distance <= size-1)
  629.     return true if enable
  630.     return false
  631.   end
  632.   
  633.   # sensor body
  634.   def body_size?(target, size)
  635.     distance = (@x - target[0]).abs + (@y - target[1]).abs
  636.     enable   = (distance <= size-1)
  637.     return true if enable
  638.     return false
  639.   end
  640.   
  641.   def faceto_face?(target)
  642.     return true if @direction == 2 and target.direction == 8
  643.     return true if @direction == 4 and target.direction == 6
  644.     return true if @direction == 6 and target.direction == 4
  645.     return true if @direction == 8 and target.direction == 2
  646.     return false
  647.   end
  648.   
  649.   def adjustcxy
  650.     push_x, push_y =   0,   1 if @direction == 2
  651.     push_x, push_y = - 1,   0 if @direction == 4
  652.     push_x, push_y =   1,   0 if @direction == 6
  653.     push_x, push_y =   0, - 1 if @direction == 8
  654.     return [push_x, push_y]
  655.   end
  656.   
  657.   def in_frontof?(target)
  658.     return true if @direction == 2 and @x == target.x and (@y+1) == target.y
  659.     return true if @direction == 4 and (@x-1) == target.x and @y == target.y
  660.     return true if @direction == 6 and (@x+1) == target.x and @y == target.y
  661.     return true if @direction == 8 and @x == target.x and (@y-1) == target.y
  662.     return false
  663.   end
  664.   
  665.   # detect map edges ignoring loop maps
  666.   def facing_corners?
  667.     case $game_map.map.scroll_type
  668.     when 1 then return false if @direction == 2 || @direction == 8
  669.     when 2 then return false if @direction == 4 || @direction == 6
  670.     when 3 then return false
  671.     end
  672.     m = $game_map
  673.     unless @x.between?(1, m.width - 2) && @y.between?(1, m.height - 2)
  674.       return true if @x == 0 and @direction == 4
  675.       return true if @y == 0 and @direction == 8
  676.       return true if @x == m.width  - 1  and @direction == 6
  677.       return true if @y == m.height - 1  and @direction == 2
  678.     end
  679.     return false
  680.   end
  681.   
  682.   # item usable test
  683.   def usable_test_passed?(item)
  684.     return true if battler.is_a?(Game_Enemy) && item.is_a?(RPG::Item)
  685.     itemcost = item.tool_data("Tool Item Cost = ")
  686.     invoke = item.tool_data("Tool Invoke Skill = ")
  687.     if battler.is_a?(Game_Actor) and itemcost != nil and itemcost != 0
  688.       return false if !battler.usable?($data_items[itemcost])
  689.     end
  690.     if item.is_a?(RPG::Skill) || item.is_a?(RPG::Item)
  691.       return false if !battler.usable?(item)
  692.     else
  693.       if invoke != nil and invoke != 0
  694.         return false if !battler.usable?($data_skills[invoke])
  695.       else
  696.         return false if !battler.attack_usable?
  697.       end
  698.     end
  699.     return true
  700.   end
  701.   
  702.   # process the tool and verify wheter can be used
  703.   def process_tool_action(item)
  704.     PearlKernel.load_item(item)
  705.     return if !battler.tool_ready?(item)
  706.   
  707.     unless PearlKernel.has_data?
  708.       if item.is_a?(RPG::Weapon) || item.is_a?(RPG::Armor)
  709.         msgbox('Tool data missing') if $DEBUG
  710.         return
  711.       end
  712.       if item.scope.between?(1, 6)
  713.         msgbox('Tool data missing') if $DEBUG
  714.         return
  715.       elsif item.scope == 0
  716.         return
  717.         
  718.       elsif !battler.usable?(item)
  719.         RPG::SE.new("Cursor1", 80).play if self.is_a?(Game_Player)
  720.         return
  721.       end
  722.     end
  723.    
  724.     if PearlKernel.has_data? and not usable_test_passed?(item)
  725.       RPG::SE.new("Cursor1", 80).play if self.is_a?(Game_Player)
  726.       return
  727.     end
  728.    
  729.     @user_casting = [PearlKernel.tool_castime,item] if PearlKernel.has_data?
  730.     if @user_casting[0] > 0
  731.       @animation_id = 0
  732.       @animation_id = PearlKernel.tool_castanimation
  733.     else
  734.       load_abs_tool(item)
  735.     end
  736.   end
  737.   
  738.   # load the abs tool
  739.   def load_abs_tool(item)
  740.     return if @knockdown_data[0] > 0
  741.     PearlKernel.load_item(item)
  742.   
  743.     return if self.is_a?(Game_Follower) and @targeted_character.nil?
  744.    
  745.     if !@targeting[0] and  self.battler.is_a?(Game_Actor)
  746.       if item.is_a?(RPG::Skill) || item.is_a?(RPG::Item)
  747.         # apply target to skills items
  748.         if PearlKernel.tool_target == "true" || item.scope == 7 ||
  749.           item.scope == 9
  750.           load_target_selection(item)
  751.           return
  752.         end
  753.       else
  754.         # apply target parsing the invoked skill to weapons and armors
  755.         invoke = PearlKernel.tool_invoke
  756.         if invoke != nil && invoke > 0 && invoke != 1 && invoke != 2
  757.           invokeskill = $data_skills[invoke]
  758.           if PearlKernel.tool_target == "true" || invokeskill.scope == 7 ||
  759.             invokeskill.scope == 9
  760.             load_target_selection(item)
  761.             return
  762.           end
  763.           # apply target to normal weapon and armor without invoking
  764.         else
  765.           if PearlKernel.tool_target == "true"
  766.             load_target_selection(item)
  767.             return
  768.           end
  769.         end
  770.       end
  771.     end
  772.     if item.is_a?(RPG::Skill) || item.is_a?(RPG::Item)
  773.       battler.use_item(item)
  774.     else
  775.       if PearlKernel.tool_invoke != 0
  776.         battler.use_item($data_skills[PearlKernel.tool_invoke])
  777.       end
  778.     end
  779.    
  780.     # if the tool has data continue
  781.     if PearlKernel.has_data?
  782.       consume_ammo_item(item) if battler.is_a?(Game_Actor) and
  783.       PearlKernel.tool_itemcost != 0
  784.       @anime_speed = PearlKernel.user_animespeed
  785.       battler.apply_cooldown(item, PearlKernel.tool_cooldown)
  786.     end
  787.     create_projectile_object(item)
  788.     create_anime_sprite_object(item)
  789.   end
  790.   
  791.   # projectile creator
  792.   def create_projectile_object(item)
  793.     if PearlKernel.tool_special == "hook"
  794.       PearlKernel.tool_distance.times {|i|
  795.       $game_player.projectiles.push(Projectile.new(self, item, i))}
  796.       @hookshoting[0] = true
  797.     elsif PearlKernel.tool_special == "triple"       # loads 3 projectiles
  798.       for i in [:uno, :dos, :tres]
  799.         $game_player.projectiles.push(Projectile.new(self, item, i))
  800.       end
  801.     elsif PearlKernel.tool_special == "quintuple"     #loads 5 projectiles
  802.       for i in [:uno, :dos, :tres, :cuatro, :cinco]
  803.         $game_player.projectiles.push(Projectile.new(self, item, i))
  804.       end
  805.     elsif PearlKernel.tool_special == "octuple"       # loads 8 projectiles
  806.       for i in [:uno, :dos, :tres, :cuatro, :cinco, :seis, :siete, :ocho]
  807.         $game_player.projectiles.push(Projectile.new(self, item, i))
  808.       end
  809.     else # load default projectile
  810.       $game_player.projectiles.push(Projectile.new(self, item))
  811.     end
  812.   end
  813.   
  814.   # User anime sprite creation
  815.   def create_anime_sprite_object(item)
  816.     $game_player.anime_action.each {|i|
  817.     if i.user == self
  818.       if i.custom_graphic
  819.         @transparent = false
  820.         i.user.using_custom_g = false
  821.       end
  822.       $game_player.anime_action.delete(i)
  823.     end}
  824.    
  825.     if PearlKernel.user_graphic != "nil"
  826.       return if PearlKernel.user_graphic.nil?
  827.       $game_player.anime_action.push(Anime_Obj.new(self, item))
  828.     end
  829.    
  830.     # using iconset graphic
  831.     if PearlKernel.user_graphic == "nil" and
  832.       !item.tool_data("User Iconset = ", false).nil?
  833.       return if PearlKernel.user_graphic.nil?
  834.       $game_player.anime_action.push(Anime_Obj.new(self, item))
  835.     end
  836.   end
  837.   
  838.   # consume ammo item
  839.   def consume_ammo_item(item)
  840.     itemcost = $data_items[PearlKernel.tool_itemcost]
  841.     return if item.is_a?(RPG::Item) and item.consumable and item == itemcost
  842.     battler.use_item(itemcost)
  843.   end
  844.   
  845.   alias falcaopearl_chaupdate update
  846.   def update
  847.     update_falcao_pearl_abs
  848.     falcaopearl_chaupdate
  849.   end
  850.   
  851.   # Falcao pearl abs main update
  852.   def update_falcao_pearl_abs
  853.     if @user_move_distance[0] > 0 and not moving?
  854.       move_forward ; @user_move_distance[0] -= 1
  855.     end
  856.     return if battler.nil?
  857.     update_pearlabs_timing
  858.     update_followers_attack if self.is_a?(Game_Follower) && self.visible?
  859.     if @targeting[2] != nil
  860.       load_abs_tool(@targeting[1]) if battler.is_a?(Game_Actor)
  861.       @targeting = [false, item=nil, char=nil]
  862.     end
  863.     update_battler_collapse
  864.     update_state_effects
  865.    
  866.     @combodata.each {|combo|
  867.     if combo[3] > 0
  868.       combo[3] -= 1
  869.       if combo[3] == 0
  870.         perform_combo(combo[0], combo[1], combo[2])
  871.         @combodata.delete(combo)
  872.       end
  873.       break
  874.     end}
  875.   end

  876.   def perform_combo(kind, id, jumpp)
  877.     if jumpp == 'jump'
  878.       jump(0, 0)
  879.       move_forward
  880.     end
  881.     case kind
  882.     when :weapon then use_weapon(id)
  883.     when :armor  then use_armor(id)
  884.     when :item   then use_item(id)
  885.     when :skill  then use_skill(id)
  886.     end
  887.     @doingcombo = 12
  888.   end
  889.   
  890.   #========================================================================
  891.   #     * followers attacks engine
  892.   
  893.   def fo_tool
  894.     return actor.equips[0]       if actor.primary_use == 1
  895.     return actor.equips[1]       if actor.primary_use == 2
  896.     return actor.assigned_item   if actor.primary_use == 3
  897.     return actor.assigned_item2  if actor.primary_use == 4
  898.     return actor.assigned_skill  if actor.primary_use == 5
  899.     return actor.assigned_skill2 if actor.primary_use == 6
  900.     return actor.assigned_skill3 if actor.primary_use == 7
  901.     return actor.assigned_skill4 if actor.primary_use == 8
  902.   end
  903.   
  904.   # followers attack engine
  905.   def update_followers_attack
  906.     if fo_tool.nil? || battler.dead?
  907.       @targeted_character = nil if @targeted_character != nil
  908.       return
  909.     end
  910.     return if @stopped_movement > 0
  911.     if @follower_attacktimer > 0
  912.       @follower_attacktimer -= 1
  913.       if @follower_attacktimer == 40 and !moving?
  914.         r = rand(3)
  915.         move_random if r == 0 || r == 1
  916.         move_away_from_character(@targeted_character) if
  917.         !@targeted_character.nil? and r == 2
  918.       end
  919.     end
  920.    
  921.      # si la skill es para el player
  922.     if @targeted_character != nil and @targeted_character.is_a?(Game_Player)
  923.       if all_enemies_dead?
  924.         delete_targetf
  925.         return
  926.       end
  927.       use_predefined_tool
  928.       return
  929.     end
  930.    
  931.     # si la skill es para un enemigo continuar
  932.     if @targeted_character != nil
  933.       use_predefined_tool
  934.       return if @targeted_character.nil?
  935.       # reset if the target is dead
  936.       if @targeted_character.collapsing?
  937.         force_cancel_actions
  938.         delete_targetf
  939.       end
  940.     else
  941.       # select a follower slected target
  942.       $game_player.followers.each do |follower|
  943.         if !follower.targeted_character.nil?
  944.           next if follower.targeted_character.is_a?(Game_Player)
  945.           if follower.stuck_timer >= 10
  946.             follower.targeted_character = nil
  947.             return
  948.           end
  949.           @targeted_character = follower.targeted_character
  950.           break
  951.         end
  952.       end
  953.     end
  954.   end
  955.   
  956.   # prepare the tool usage
  957.   def setup_followertool_usage
  958.     @range_view = 2
  959.     @range_view = 6 if fo_tool.tool_data("Tool Target = ", false) == "true" ||
  960.     fo_tool.tool_data("Tool Special = ", false) == "autotarget"
  961.    
  962.     if fo_tool.is_a?(RPG::Skill) || fo_tool.is_a?(RPG::Item)
  963.       if fo_tool.scope.between?(1, 6)
  964.         setup_target
  965.       else ; @targeted_character = $game_player
  966.         @range_view = 6
  967.       end
  968.       # prepare tool for invoke follower
  969.     elsif fo_tool.is_a?(RPG::Weapon) || fo_tool.is_a?(RPG::Armor)
  970.       invoke = fo_tool.tool_data("Tool Invoke Skill = ")
  971.       if invoke > 0
  972.         if $data_skills[invoke].scope.between?(1, 6)
  973.           setup_target
  974.         else ; @targeted_character = $game_player
  975.           @range_view = 6
  976.         end
  977.       else
  978.         # no invoke skill just set up an enemy target
  979.         setup_target
  980.       end
  981.     end
  982.   end
  983.   
  984.   # use the predifined tool
  985.   def use_predefined_tool
  986.     update_follower_movement
  987.     return if @targeted_character.nil?
  988.     if obj_size?(@targeted_character, @range_view) && @follower_attacktimer == 0
  989.       turn_toward_character(@targeted_character)
  990.       use_weapon(fo_tool.id) if actor.primary_use == 1
  991.       use_armor(fo_tool.id)  if actor.primary_use == 2
  992.       use_item(fo_tool.id)   if actor.primary_use == 3 || actor.primary_use == 4
  993.       use_skill(fo_tool.id)  if actor.primary_use==5 || actor.primary_use==6 ||
  994.       actor.primary_use == 7 || actor.primary_use == 8
  995.       if fo_tool.tool_data("User Graphic = ", false).nil?
  996.         @targeted_character = nil
  997.         turn_toward_player
  998.       end
  999.       @follower_attacktimer = 60
  1000.     end
  1001.     delete_targetf if self.actor.dead?
  1002.   end
  1003.   
  1004.   def all_enemies_dead?
  1005.     for event in $game_map.event_enemies
  1006.       if event.on_battle_screen? && event.enemy_ready?
  1007.         return false if $game_player.obj_size?(event,PearlKernel::PlayerRange+1)
  1008.       end
  1009.     end
  1010.     return true
  1011.   end
  1012.   
  1013.   def delete_targetf
  1014.     @targeted_character = nil
  1015.   end
  1016.   
  1017.   #------------------------
  1018.   # follower movement attack
  1019.   def reset_targeting_settings(target)
  1020.     target.being_targeted = false if target.is_a?(Game_Event)
  1021.     delete_targetf
  1022.     turn_toward_player
  1023.     @stuck_timer = 0
  1024.   end
  1025.   
  1026.   def update_follower_movement
  1027.     target = @targeted_character
  1028.     if @stuck_timer >= 30
  1029.       reset_targeting_settings(target)
  1030.       return
  1031.     end
  1032.    
  1033.     # if the follower is unabble to use the tool
  1034.     unless usable_test_passed?(fo_tool)
  1035.       if SceneManager.scene_is?(Scene_Map)
  1036.         reset_targeting_settings(target)
  1037.         @balloon_id = PearlKernel::FailBalloon
  1038.         return
  1039.       end
  1040.     end
  1041.    
  1042.     return if target.nil?
  1043.     @stuck_timer += 1 if !obj_size?(target, @range_view) and !moving?
  1044.   
  1045.     if moving? || @anime_speed > 0 || @making_spiral || @hookshoting[0] ||
  1046.       @knockdown_data[0] > 0
  1047.       @stuck_timer = 0
  1048.     end
  1049.     return if moving?
  1050.     if fo_tool.tool_data("Tool Target = ", false) == "true" ||
  1051.       fo_tool.tool_data("Tool Special = ", false) == "autotarget" ||
  1052.       target.is_a?(Game_Player)
  1053.       # using skill con target true magical
  1054.       cpu_reactiontype(1, target)
  1055.       return
  1056.       # target not exist
  1057.     else
  1058.    
  1059.       if fo_tool.is_a?(RPG::Skill) || fo_tool.is_a?(RPG::Item)
  1060.         fo_tool.scope.between?(1, 6) ? cpu_reactiontype(2, target) : # to enemy
  1061.         cpu_reactiontype(1, target) # benefical
  1062.       else
  1063.         # for weapon armor without target
  1064.         cpu_reactiontype(2, target)
  1065.       end
  1066.     end
  1067.     return if !obj_size?(target, @range_view)
  1068.     return if target.is_a?(Game_Player)
  1069.     case rand(40)
  1070.     when 4  then move_backward
  1071.     when 10 then move_random
  1072.     end
  1073.   end
  1074.   
  1075.   # cpu reaction
  1076.   def cpu_reactiontype(type, target)
  1077.     unless on_battle_screen?
  1078.       3.times.each {|i|  move_toward_player}
  1079.       return
  1080.     end
  1081.     move_toward_character(target) if !obj_size?(target, @range_view) if type==1
  1082.     if @follower_attacktimer == 0 || !obj_size?(target, @range_view)
  1083.       move_toward_character(target) if type == 2
  1084.     end
  1085.   end
  1086.   #-------------------------------------------------
  1087.   
  1088.   # buff timer
  1089.   def update_buff_timing
  1090.     battler.buff_turns.each do |id, value|
  1091.       if battler.buff_turns[id] > 0
  1092.         battler.buff_turns[id] -= 1
  1093.         if battler.buff_turns[id] <= 0
  1094.           battler.remove_buff(id)
  1095.           pop_damage
  1096.         end
  1097.       end
  1098.     end
  1099.   end
  1100.   
  1101.   #blow power effect
  1102.   def update_blow_power_effect
  1103.     if @blowpower[4] > 0
  1104.       @blowpower[4] -= 1
  1105.       if @blowpower[4] == 0
  1106.         @direction_fix = @blowpower[2]
  1107.         @move_speed = @blowpower[3]
  1108.       end
  1109.     end
  1110.     if @blowpower[0] > 0 and !moving?
  1111.       @move_speed = 5.5
  1112.       @direction_fix = true
  1113.       move_straight(@blowpower[1]); @blowpower[0] -= 1
  1114.       if @blowpower[0] == 0
  1115.         @blowpower[4] = 10
  1116.       end
  1117.     end
  1118.   end
  1119.   
  1120.   # Pearl timing
  1121.   def update_pearlabs_timing
  1122.     @just_hitted -= 1 if @just_hitted > 0
  1123.     @stopped_movement -= 1 if @stopped_movement > 0
  1124.     @doingcombo -= 1 if @doingcombo > 0
  1125.    
  1126.     # hookshooting
  1127.     if @hookshoting[3] > 0
  1128.       @hookshoting[3] -= 1
  1129.       if @hookshoting[3] == 0
  1130.         @hookshoting = [false, false, false, 0]
  1131.         @user_move_distance[3].being_grabbed = false if
  1132.         @user_move_distance[3].is_a?(Game_Event)
  1133.         @user_move_distance[3] = nil
  1134.       end
  1135.     end
  1136.     update_buff_timing
  1137.     update_blow_power_effect
  1138.     # anime
  1139.     if @anime_speed > 0
  1140.       @pattern = 0
  1141.       @anime_speed -= 1
  1142.     end
  1143.     # casting
  1144.     if @user_casting[0] > 0
  1145.       @user_casting[0] -= 1
  1146.       load_abs_tool(@user_casting[1]) if @user_casting[0] == 0
  1147.     end
  1148.     update_knockdown
  1149.   end
  1150.   
  1151.   # Update battler collapse
  1152.   
  1153.   def check_for_dead_four
  1154.     return if $game_party.members.size <= 4
  1155.     SceneManager.goto(Scene_Gameover) if all_fourdead?
  1156.   end

  1157.   def all_fourdead?
  1158.     m = $game_party.battle_members
  1159.     return true if m[0].dead? && m[1].dead? && m[2].dead? && m[3].dead?
  1160.     return false
  1161.   end
  1162.   
  1163.   def update_battler_collapse
  1164.     if @colapse_time > 0
  1165.       @colapse_time -= 1
  1166.       force_cancel_actions
  1167.       if battler.is_a?(Game_Actor)
  1168.         Sound.play_actor_collapse if @secollapse.nil?
  1169.         @secollapse = true
  1170.         
  1171.         if @colapse_time == 0
  1172.           @secollapse = nil
  1173.           for event in $game_map.event_enemies
  1174.             if event.agroto_f == self
  1175.               event.agroto_f = nil
  1176.             end
  1177.           end
  1178.          
  1179.           check_for_dead_four
  1180.           member = $game_party.battle_members
  1181.           # swap and reset player
  1182.           if self.is_a?(Game_Player)
  1183.             reset_knockdown_actors
  1184.             battler.deadposing=$game_map.map_id if PearlKernel::FollowerDeadPose
  1185.             $game_party.swap_order(0,3) if !member[3].nil? and !member[3].dead?
  1186.             $game_party.swap_order(0,2) if !member[2].nil? and !member[2].dead?
  1187.             $game_party.swap_order(0,1) if !member[1].nil? and !member[1].dead?
  1188.           else
  1189.             if PearlKernel::FollowerDeadPose
  1190.               battler.deadposing = $game_map.map_id
  1191.               if !$game_player.follower_fighting? and member.size > 2
  1192.                 swap_dead_follower
  1193.               else
  1194.                 $game_player.reserved_swap << battler.id if member.size > 2
  1195.               end
  1196.             end
  1197.           end
  1198.         end
  1199.         
  1200.       elsif battler.is_a?(Game_Enemy)
  1201.         @die_through = @through if @die_through.nil?
  1202.         @through = true
  1203.         apply_collapse_anime(battler.collapse_type)
  1204.         @secollapse = true
  1205.         battler.object ? @transparent = true : @opacity -= 2 if !@deadposee
  1206.         if @colapse_time == 0
  1207.           self.kill_enemy
  1208.         end
  1209.       end
  1210.     end
  1211.   end
  1212.   
  1213.   def swap_dead_follower
  1214.     reset_knockdown_actors
  1215.     member = $game_party.battle_members
  1216.     member.each_with_index.each do |actorr, i|
  1217.       next unless actorr.id == self.actor.id
  1218.       case member.size
  1219.       when 3
  1220.         break if i == 2
  1221.         $game_party.swap_order(i, 2)
  1222.       when 4
  1223.         break if i == 3
  1224.         if !member[3].dead?
  1225.           $game_party.swap_order(i, 3)
  1226.           break
  1227.         end
  1228.         if !member[2].dead?  
  1229.           $game_party.swap_order(i, 2)
  1230.           break
  1231.         end
  1232.       end
  1233.     end
  1234.   end

  1235.   def apply_collapse_anime(type)
  1236.     # sound and animation
  1237.     if battler.die_animation != nil
  1238.       @animation_id = battler.die_animation if @secollapse.nil?
  1239.     else
  1240.       Sound.play_enemy_collapse if @secollapse.nil? and !battler.object
  1241.     end
  1242.     return if battler.object
  1243.     if @deadposee
  1244.       @knockdown_data[0] = 8
  1245.       return
  1246.     end
  1247.     type = PearlKernel::DefaultCollapse if type.nil?
  1248.     case type.to_sym
  1249.     when :zoom_vertical
  1250.       @zoomfx_x -= 0.03
  1251.       @zoomfx_y += 0.02
  1252.     when :zoom_horizontal
  1253.       @zoomfx_x += 0.03
  1254.       @zoomfx_y -= 0.02
  1255.     when :zoom_maximize
  1256.       @zoomfx_x += 0.02
  1257.       @zoomfx_y += 0.02
  1258.     when :zoom_minimize
  1259.       @zoomfx_x -= 0.02
  1260.       @zoomfx_y -= 0.02
  1261.     end
  1262.   end
  1263.   
  1264.   # konck down engine update
  1265.   def update_knockdown
  1266.     if @knockdown_data[0] > 0
  1267.       @knockdown_data[0] -= 1
  1268.       @knockdown_data[0] == 0 ? knowdown_effect(2) : knowdown_effect(1)
  1269.       if @knockdown_data[1] != nil
  1270.         @pattern = @knockdown_data[2]
  1271.         @direction = @knockdown_data[3]
  1272.       end
  1273.     end
  1274.   end
  1275.   
  1276.   def knowdown_effect(type)
  1277.     return if self.is_a?(Projectile)
  1278.     if type[0] == 1
  1279.       if @knockdown_data[1] == nil
  1280.         if battler.is_a?(Game_Enemy)
  1281.           if self.knockdown_enable
  1282.             force_cancel_actions
  1283.             self_sw = PearlKernel::KnockdownSelfW
  1284.             $game_self_switches[[$game_map.map_id, self.id, self_sw]] = true
  1285.             @knockdown_data[1] = self_sw
  1286.             self.refresh
  1287.             @knockdown_data[2] = self.page.graphic.pattern
  1288.             @knockdown_data[3] = self.page.graphic.direction
  1289.             $game_map.screen.start_shake(7, 4, 20)
  1290.           end
  1291.          
  1292.           @knockdown_data[0] = 0 if @knockdown_data[1] == nil
  1293.        elsif battler.is_a?(Game_Actor)
  1294.          if PearlKernel.knock_actor(self.actor) != nil and
  1295.            if @knockdown_data[1] == nil
  1296.              force_cancel_actions
  1297.              @knockdown_data[1] = @character_name
  1298.              @knockdown_data[4] = @character_index
  1299.              @character_name = PearlKernel.knock_actor(self.actor)[0]
  1300.              @character_index = PearlKernel.knock_actor(self.actor)[1]
  1301.              @knockdown_data[2] = PearlKernel.knock_actor(self.actor)[2]
  1302.              @knockdown_data[3] = PearlKernel.knock_actor(self.actor)[3]
  1303.              $game_map.screen.start_shake(7, 4, 20) if battler.deadposing.nil?
  1304.            end
  1305.          end
  1306.          @knockdown_data[0] = 0 if @knockdown_data[1] == nil
  1307.         end
  1308.       end
  1309.     elsif type == 2
  1310.       if battler.is_a?(Game_Enemy)
  1311.         if @deadposee and battler.dead?
  1312.           @knockdown_data[1] = nil
  1313.           return
  1314.         end
  1315.         $game_self_switches[[$game_map.map_id, self.id,
  1316.         @knockdown_data[1]]] = false if @knockdown_data[1] != nil
  1317.         @knockdown_data[1] = nil
  1318.       else
  1319.         @character_name = @knockdown_data[1]
  1320.         @character_index = @knockdown_data[4]
  1321.         @knockdown_data[1] = nil
  1322.       end
  1323.     end
  1324.   end
  1325.   
  1326.   #================================
  1327.   # states
  1328.   def primary_state_ani
  1329.     return nil if battler.states[0].nil?
  1330.     return battler.states[0].tool_data("State Animation = ")
  1331.   end
  1332.   
  1333.   # higer priority state animation displayed
  1334.   def update_state_effects
  1335.     return if battler.nil?
  1336.     @state_poptimer[0] += 1 unless primary_state_ani.nil?
  1337.     if @state_poptimer[0] == 30
  1338.       @animation_id = primary_state_ani
  1339.       @animation_id = 0 if @animation_id.nil?
  1340.     elsif @state_poptimer[0] == 180
  1341.       @state_poptimer[0] = 0
  1342.     end
  1343.     update_state_action_steps
  1344.   end
  1345.   
  1346.   # update state actions
  1347.   def update_state_action_steps
  1348.     for state in battler.states
  1349.       if state.remove_by_walking
  1350.         if !battler.state_steps[state.id].nil? &&
  1351.           battler.state_steps[state.id] > 0
  1352.           battler.state_steps[state.id] -= 1
  1353.         end
  1354.         if battler.state_steps[state.id] == 0
  1355.           battler.remove_state(state.id)
  1356.           pop_damage
  1357.         end
  1358.       end
  1359.       if state.restriction == 4
  1360.         @stopped_movement = 10
  1361.         @pattern = 2 if @knockdown_data[0] == 0
  1362.       end
  1363.       state.features.each do |feature|
  1364.         if feature.code == 22
  1365.           @knockdown_data[0] =10 if state.restriction == 4 && feature.data_id==1
  1366.           next unless feature.data_id.between?(7, 9)
  1367.           apply_regen_state(state, feature.data_id)
  1368.         end
  1369.       end
  1370.     end
  1371.   end
  1372.   
  1373.   # apply regen for hp, mp and tp
  1374.   def apply_regen_state(state, type)
  1375.     random = state.tool_data("State Effect Rand Rate = ")
  1376.     random = 120 if random.nil?
  1377.     if rand(random) == 1
  1378.       battler.regenerate_hp if type == 7
  1379.       battler.regenerate_mp if type == 8
  1380.       battler.regenerate_tp if type == 9
  1381.       if type == 7 and battler.result.hp_damage == 0
  1382.         @colapse_time = 80
  1383.         battler.add_state(1)
  1384.         return
  1385.       end
  1386.       type == 9 ? pop_damage("Tp Up!") : pop_damage
  1387.     end
  1388.   end
  1389.   
  1390.   alias falcaopearl_update_anime_pattern update_anime_pattern
  1391.   def update_anime_pattern
  1392.     return if @anime_speed > 0 || @knockdown_data[0] > 0
  1393.     falcaopearl_update_anime_pattern
  1394.   end
  1395.   
  1396.   #=============================================================================
  1397.   # Reset Pearl ABS System
  1398.   
  1399.   # reset from game player call
  1400.   def reset_knockdown_actors
  1401.     # reset knock down
  1402.     if @knockdown_data[1] != nil
  1403.       @knockdown_data[0] = 0
  1404.       knowdown_effect(2)
  1405.     end
  1406.     # force clear knock down
  1407.     $game_player.followers.each do |follower|
  1408.       if follower.knockdown_data[1] != nil
  1409.         follower.knockdown_data[0] = 0
  1410.         follower.knowdown_effect(2)
  1411.       end
  1412.     end
  1413.   end
  1414.   
  1415.   # reset knockdown enemies game player call
  1416.   def reset_knockdown_enemies
  1417.     $game_map.events.values.each do |event|
  1418.       if event.knockdown_data[1] != nil
  1419.         event.knockdown_data[0] = 0
  1420.         event.knowdown_effect(2)
  1421.       end
  1422.       if event.deadposee and event.killed
  1423.         $game_self_switches[[$game_map.map_id, event.id,
  1424.         PearlKernel::KnockdownSelfW]] = false
  1425.       end
  1426.     end
  1427.   end
  1428.   
  1429.   # glabal reseting
  1430.   def pearl_abs_global_reset
  1431.     force_cancel_actions
  1432.     battler.remove_state(9) if @battler_guarding[0]
  1433.     @battler_guarding = [false, nil]
  1434.     @making_spiral = false
  1435.     set_hook_variables
  1436.     @using_custom_g = false
  1437.     $game_player.followers.each do |f|
  1438.       f.targeted_character = nil if !f.targeted_character.nil?
  1439.       f.stuck_timer = 0 if f.stuck_timer > 0
  1440.       f.follower_attacktimer = 0 if f.follower_attacktimer > 0
  1441.       f.force_cancel_actions unless f.visible?
  1442.       f.battler.remove_state(9) if f.battler_guarding[0]
  1443.       f.battler_guarding = [false, nil]
  1444.       f.set_hook_variables
  1445.       f.making_spiral = false
  1446.     end
  1447.     reset_knockdown_actors
  1448.     reset_knockdown_enemies
  1449.     $game_player.projectiles.clear
  1450.     $game_player.damage_pop.clear
  1451.     $game_player.anime_action.clear
  1452.     $game_player.enemy_drops.clear
  1453.     @send_dispose_signal = true
  1454.   end
  1455. end

  1456. #===============================================================================
  1457. # Evets as enemies registration

  1458. class Game_Event < Game_Character
  1459.   attr_accessor :enemy, :move_type, :page, :deadposee
  1460.   attr_accessor :being_targeted, :agroto_f, :draw_drop, :dropped_items
  1461.   attr_accessor :start_delay, :epassive, :erased, :killed, :boom_grabdata
  1462.   attr_reader   :token_weapon, :token_armor,:token_item,:token_skill,:boom_start
  1463.   attr_reader   :hook_pull, :hook_grab, :event, :knockdown_enable, :boom_grab
  1464.   attr_reader   :respawn_anim
  1465.   alias falcaopearlabs_iniev initialize
  1466.   def initialize(map_id, event)
  1467.     @inrangeev = nil
  1468.     @being_targeted = false
  1469.     @agroto_f = nil
  1470.     @draw_drop = false
  1471.     @dropped_items = []
  1472.     @epassive = false
  1473.     @touch_damage = 0
  1474.     @start_delay = 0
  1475.     @touch_atkdelay = 0
  1476.     @killed = false
  1477.     @knockdown_enable = false
  1478.     @deadposee = false
  1479.     @respawn_anim = 0
  1480.     create_token_arrays
  1481.     falcaopearlabs_iniev(map_id, event)
  1482.     register_enemy(event)
  1483.   end
  1484.   
  1485.   def create_token_arrays
  1486.     @token_weapon = []
  1487.     @token_armor  = []
  1488.     @token_item   = []
  1489.     @token_skill  = []
  1490.   end
  1491.   
  1492.   alias falcaopearl_setup_page_settings setup_page_settings
  1493.   def setup_page_settings
  1494.     create_token_arrays
  1495.     falcaopearl_setup_page_settings
  1496.     wtag = string_data("<start_with_weapon: ")
  1497.     @token_weapon = wtag.split(",").map { |s| s.to_i } if wtag != nil
  1498.     atag = string_data("<start_with_armor: ")
  1499.     @token_armor = atag.split(",").map { |s| s.to_i } if atag != nil
  1500.     itag = string_data("<start_with_item: ")
  1501.     @token_item = itag.split(",").map { |s| s.to_i } if itag != nil
  1502.     stag = string_data("<start_with_skill: ")
  1503.     @token_skill = stag.split(",").map { |s| s.to_i } if stag != nil
  1504.     @hook_pull = string_data("<hook_pull: ") == "true"
  1505.     @hook_grab = string_data("<hook_grab: ") == "true"
  1506.     @boom_grab = string_data("<boom_grab: ") == "true"
  1507.     @boom_start = string_data("<boomed_start: ") == "true"
  1508.     @direction_fix = false if @hook_grab
  1509.     if has_token? || @hook_pull || @hook_grab || @boom_grab || @boom_start
  1510.       $game_map.events_withtags.push(self) unless
  1511.       $game_map.events_withtags.include?(self)
  1512.     end
  1513.   end
  1514.   
  1515.   def has_token?
  1516.     !@token_weapon.empty? || !@token_armor.empty? || !@token_item.empty? ||
  1517.     !@token_skill.empty?
  1518.   end
  1519.   
  1520.   def register_enemy(event)
  1521.    
  1522.     if !$game_system.remain_killed[$game_map.map_id].nil? and
  1523.       $game_system.remain_killed[$game_map.map_id].include?(self.id)
  1524.       return
  1525.     end
  1526.    
  1527.     @enemy  = Game_Enemy.new(0, $1.to_i) if event.name =~ /<enemy: (.*)>/i
  1528.     if @enemy != nil
  1529.       passive = @enemy.enemy.tool_data("Enemy Passive = ", false)
  1530.       @epassive = true if passive == "true"
  1531.       touch = @enemy.enemy.tool_data("Enemy Touch Damage Range = ")
  1532.       @sensor = @enemy.esensor
  1533.       @touch_damage = touch if touch != nil
  1534.       $game_map.event_enemies.push(self) # new separate enemy list
  1535.       $game_map.enemies.push(@enemy)     # just enemies used in the cooldown
  1536.       @event.pages.each do |page|
  1537.         if page.condition.self_switch_valid and
  1538.           page.condition.self_switch_ch == PearlKernel::KnockdownSelfW
  1539.           @knockdown_enable = true
  1540.           break
  1541.         end
  1542.       end
  1543.       pose = @enemy.enemy.tool_data("Enemy Dead Pose = ", false) == "true"
  1544.       @deadposee = true if pose and @knockdown_enable
  1545.     end
  1546.   end
  1547.   
  1548.   def update_state_effects
  1549.     @killed ? return : super
  1550.   end
  1551.   
  1552.   def collapsing?
  1553.     return true if @killed || @colapse_time > 0
  1554.     return false
  1555.   end
  1556.   
  1557.   def enemy_ready?
  1558.     return false if @enemy.nil? || @page.nil? || collapsing? || @enemy.object
  1559.     return true
  1560.   end
  1561.   
  1562.   def battler
  1563.     return @enemy
  1564.   end
  1565.   
  1566.   def apply_respawn
  1567.     return if @colapse_time > 0
  1568.     @draw_drop = false
  1569.     @dropped_items.clear
  1570.     @through = @die_through
  1571.     @through = false if @through.nil?
  1572.     @die_through = nil
  1573.     @secollapse = nil
  1574.     @colapse_time = 0
  1575.     @erased = false ; @opacity = 255
  1576.     @zoomfx_x = 1.0 ; @zoomfx_y = 1.0
  1577.     @killed = false
  1578.     @priority_type = 1 if @deadposee
  1579.     resetdeadpose
  1580.     refresh
  1581.   end
  1582.   
  1583.   def resetdeadpose
  1584.     if @deadposee
  1585.       $game_self_switches[[$game_map.map_id, @id,
  1586.       PearlKernel::KnockdownSelfW]] = false
  1587.     end
  1588.   end
  1589.   
  1590.   def kill_enemy
  1591.     @secollapse = nil
  1592.     @killed = true
  1593.     @priority_type = 0 if @deadposee
  1594.     gain_exp
  1595.     gain_gold
  1596.     etext = 'Exp '  + @enemy.exp.to_s if @enemy.exp > 0
  1597.     gtext = 'Gold ' + @enemy.gold.to_s if @enemy.gold > 0
  1598.     $game_player.pop_damage("#{etext} #{gtext}") if etext || gtext
  1599.     make_drop_items
  1600.     run_assigned_commands
  1601.   end
  1602.   
  1603.   def run_assigned_commands
  1604.     transform = @enemy.enemy.tool_data("Enemy Die Transform = ")
  1605.     switch = @enemy.enemy.tool_data("Enemy Die Switch = ")
  1606.     $game_switches[switch] = true if switch != nil
  1607.     variable = @enemy.enemy.tool_data("Enemy Die Variable = ")
  1608.     $game_variables[variable] += 1 if variable != nil
  1609.     self_sw = @enemy.enemy.tool_data("Enemy Die Self Switch = ", false)
  1610.     #$game_map.event_enemies.delete(self) if @enemy.object
  1611.     #$game_map.enemies.delete(@enemy) if @enemy.object
  1612.     if self_sw.is_a?(String)
  1613.       $game_self_switches[[$game_map.map_id, self.id, self_sw]] = true
  1614.       apply_respawn
  1615.       $game_map.event_enemies.delete(self)
  1616.       $game_map.enemies.delete(@enemy)
  1617.       unless $game_system.remain_killed.has_key?($game_map.map_id)
  1618.         $game_system.remain_killed[$game_map.map_id] = []
  1619.       end
  1620.       $game_system.remain_killed[$game_map.map_id].push(self.id) unless
  1621.       $game_system.remain_killed[$game_map.map_id].include?(self.id)
  1622.       @enemy = nil
  1623.     else
  1624.       erase unless @deadposee
  1625.       respawn = @enemy.enemy.tool_data("Enemy Respawn Seconds = ")
  1626.       animation = @enemy.enemy.tool_data("Enemy Respawn Animation = ")
  1627.       @respawn_count = respawn * 60 unless respawn.nil?
  1628.       
  1629.       @respawn_anim = animation unless animation.nil?
  1630.       
  1631.     end
  1632.     if transform != nil
  1633.       @enemy = Game_Enemy.new(0, transform)
  1634.       apply_respawn
  1635.     end
  1636.   end
  1637.   
  1638.   def make_drop_items
  1639.     @dropped_items = @enemy.make_drop_items
  1640.     unless @dropped_items.empty?
  1641.       $game_player.enemy_drops.push(self)
  1642.       $game_map.events_withtags.push(self) unless
  1643.       $game_map.events_withtags.include?(self)
  1644.     end
  1645.   end
  1646.   
  1647.   def gain_exp
  1648.     return if @enemy.exp == 0
  1649.     $game_party.all_members.each do |actor|
  1650.       actor.gain_exp(@enemy.exp)
  1651.     end
  1652.   end
  1653.   
  1654.   def gain_gold
  1655.     return if @enemy.gold == 0
  1656.     $game_party.gain_gold(@enemy.gold)
  1657.   end
  1658.   
  1659.   alias falcaopearlabs_updatev update
  1660.   def update
  1661.     @start_delay -= 1 if @start_delay > 0
  1662.     @touch_atkdelay -= 1 if @touch_atkdelay > 0
  1663.     update_enemy_sensor unless @enemy.nil?
  1664.     update_enemy_touch_damage unless @enemy.nil?
  1665.     falcaopearlabs_updatev
  1666.   end
  1667.   
  1668.   def update_enemy_touch_damage
  1669.     return unless @touch_damage > 0
  1670.     return unless @character_name != ""
  1671.     return if @epassive || @killed
  1672.     return if @touch_atkdelay > 0
  1673.     unless @enemy.object
  1674.       @agroto_f.nil? ? target = $game_player : target = @agroto_f
  1675.     else
  1676.       target = $game_player
  1677.       $game_player.followers.each do |follower|
  1678.         next unless follower.visible?
  1679.         if obj_size?(follower, @touch_damage) and !follower.battler.dead?
  1680.           execute_touch_damage(follower)
  1681.         end
  1682.       end
  1683.     end
  1684.     execute_touch_damage(target) if obj_size?(target, @touch_damage)
  1685.   end
  1686.   
  1687.   def execute_touch_damage(target)
  1688.     target.battler.attack_apply(@enemy)
  1689.     target.pop_damage
  1690.     @touch_atkdelay = 50
  1691.     target.colapse_time = 60 if target.battler.dead?
  1692.     return if target.battler.result.hp_damage == 0
  1693.     target.jump(0, 0)
  1694.   end
  1695.   
  1696.   # enemy sensor
  1697.   def update_enemy_sensor
  1698.     return if @hookshoting[0]
  1699.     return if @epassive
  1700.     if @sensor != nil
  1701.       @agroto_f.nil? ? target = $game_player : target = @agroto_f
  1702.       if obj_size?(target, @sensor)
  1703.         data = [$game_map.map_id, @id, PearlKernel::Enemy_Sensor]
  1704.         if @inrangeev.nil? and !$game_self_switches[[data[0], data[1],
  1705.           data[2]]]
  1706.           $game_self_switches[[data[0], data[1], data[2]]] = true
  1707.           @inrangeev = true
  1708.         end
  1709.       elsif @inrangeev != nil
  1710.         data = [$game_map.map_id, @id, PearlKernel::Enemy_Sensor]
  1711.         if $game_self_switches[[data[0], data[1], data[2]]]
  1712.           $game_self_switches[[data[0], data[1], data[2]]] = false
  1713.           @inrangeev = nil
  1714.         end
  1715.       end
  1716.     end
  1717.   end
  1718.   
  1719.   # on battle pixel, take a lot of time procesing, but it is very exact
  1720.   def on_battle_pixel?(out=0)
  1721.     w = Graphics.width + out; h = Graphics.height + out
  1722.     return true if screen_x.between?(0 - out,w) and screen_y.between?(0 - out,h)
  1723.     return false
  1724.   end

  1725.   def cmt_data(comment)
  1726.     return 0 if @list.nil? or @list.size <= 0
  1727.     for item in @list
  1728.       if item.code == 108 or item.code == 408
  1729.         return $1.to_i if item.parameters[0] =~ /#{comment}(.*)>/i
  1730.       end
  1731.     end
  1732.     return 0
  1733.   end
  1734.   
  1735.   def string_data(comment)
  1736.     return nil if @list.nil? or @list.size <= 0
  1737.     for item in @list
  1738.       if item.code == 108 or item.code == 408
  1739.         return $1.to_s if item.parameters[0] =~ /#{comment}(.*)>/i
  1740.       end
  1741.     end
  1742.     return nil
  1743.   end
  1744.   
  1745.   # stop event movement
  1746.   alias falcaopearl_update_self_movement update_self_movement
  1747.   def update_self_movement
  1748.     return if !@boom_grabdata.nil?
  1749.     return if force_stopped? || @colapse_time > 0 || @blowpower[0] > 0
  1750.     falcaopearl_update_self_movement
  1751.   end
  1752. end


  1753. class Game_System
  1754.   attr_accessor :remain_killed
  1755.   alias falcao_fantastic_store_ini initialize
  1756.   def initialize
  1757.     falcao_fantastic_store_ini
  1758.     @remain_killed = {}
  1759.   end
  1760. end

  1761. #===============================================================================

  1762. # mist
  1763. class Game_Map
  1764.   attr_reader   :map
  1765.   attr_accessor :event_enemies, :enemies, :events_withtags
  1766.   alias falcaopearl_enemycontrol_ini initialize
  1767.   def initialize
  1768.     @event_enemies = []
  1769.     @enemies = []
  1770.     @events_withtags = []
  1771.     falcaopearl_enemycontrol_ini
  1772.   end
  1773.   
  1774.   alias falcaopearl_enemycontrol_setup setup
  1775.   def setup(map_id)
  1776.     @event_enemies.clear
  1777.     @enemies.clear
  1778.     @events_withtags.clear
  1779.     falcaopearl_enemycontrol_setup(map_id)
  1780.     if $game_temp.loadingg != nil
  1781.       @event_enemies.each do |event|
  1782.         event.resetdeadpose
  1783.       end
  1784.       $game_temp.loadingg = nil
  1785.     end
  1786.   end
  1787.   
  1788.   alias falcaopearl_damage_floor damage_floor?
  1789.   def damage_floor?(x, y)
  1790.     return if $game_player.hookshoting[1]
  1791.     falcaopearl_damage_floor(x, y)
  1792.   end
  1793. end

  1794. class Game_Temp
  1795.   attr_accessor :pop_windowdata, :loadingg
  1796.   def pop_w(time, name, text)
  1797.     return unless @pop_windowdata.nil?
  1798.     @pop_windowdata = [time, text, name]
  1799.   end
  1800. end

  1801. class Game_Party < Game_Unit
  1802.   alias falcaopearl_swap_order swap_order
  1803.   def swap_order(index1, index2)
  1804.     unless SceneManager.scene_is?(Scene_Map)
  1805.       if $game_player.in_combat_mode?
  1806.         $game_temp.pop_w(180, 'Pearl ABS',
  1807.         'You cannot switch player while in combat!')
  1808.         return
  1809.       elsif $game_player.any_collapsing?
  1810.         $game_temp.pop_w(180, 'Pearl ABS',
  1811.         'You cannot switch player while collapsing!')
  1812.         return
  1813.       elsif $game_party.battle_members[index2].deadposing != nil
  1814.          $game_temp.pop_w(180, 'Pearl ABS',
  1815.         'You cannot move a dead ally!')
  1816.         return
  1817.       end
  1818.     end
  1819.     falcaopearl_swap_order(index1, index2)
  1820.   end
  1821. end

  1822. class << DataManager
  1823.   alias falcaopearl_extract extract_save_contents
  1824.   def DataManager.extract_save_contents(contents)
  1825.     falcaopearl_extract(contents)
  1826.     $game_temp.loadingg = true
  1827.   end
  1828. end
复制代码


  1. #===============================================================================
  2. # * Falcao Pearl ABS script shelf # 7
  3. #
  4. # Actor / Eenemies HP and MP bars display v 2.0
  5. # 显示玩家和敌人的HP/MP条
  6. # This script acts like an Add-On, the main system can run without this piece
  7. # 这个脚本是附加脚本,核心脚本可以在无此脚本下运行
  8. #-------------------------------------------------------------------------------

  9. # * Features
  10. # - 显示当前玩家的HP和MP条,经验还有TP条
  11. # -【Display HP, MP, experience and TP bars of the current player actor】
  12. # - 当敌人被攻击时,显示敌人的Hp【Display the Enemy HP bar when was hit】
  13. # - BOSS的HP条【Boss HP bar anabled】
  14. # - 显示玩家状态和增益减益效果图标【Display enemy states and buff / debuff icons】
  15. # - 无图像但是高定制的条?【Non-graphical bars but hightly customizable】
  16. # - 2.0现在支持直接使用图像而不是脚本绘制【2.0 now support images instead of script drawing bars】


  17. # * Usage and Installation【安装说明】
  18. # Just copy and paste below the Pearl ABS System【直接拷贝在PEARL ABS SYSTEM后即可】
  19. #
  20. # * Commands【指令】
  21. # PearlBars.hide          - Hide the actor bars【隐藏玩家条,栏】
  22. # PearlBars.show          - Show the actor bars (by default)【显示玩家条,栏(默认)】
  23. #
  24. # PearlBars.enemy_auto(id)- 不需要攻击敌人而自动显示敌人HP条,用来做BOSS的,id改为事件ID
  25. # 【Show automatically the enemy HP bars without need
  26. # to hit, this is mostly used for bosses, change id for the event id】
  27. # Tag any enemy with   Enemy Boss Bar = true   to eneble the boss bar mode
  28. # 在敌人标注栏里标注“Enemy Boss Bar = true”来开启BOSS血条模式
  29. #------------------------------------------------------------------------------
  30. module PearlBars
  31.   #=============================================================================
  32.   # * Actors bars configuration
  33.   #
  34.   # Bars x and y position on the screen【条的 X 和 Y 位置】
  35.   ScreenPos_X = -3
  36.   ScreenPos_Y = 410
  37.   #
  38.   # Dimentions of the bars you cant exceed 300 width x 100 height
  39.   #【条的大小不能超过宽300高100】
  40.   #                   x    y     width   height
  41.   HP_BarDimentions = [-3,   27,    79,     7]
  42.   MP_BarDimentions = [10,   40,    79,     7]
  43. #  EX_BarDimentions = [-500,   -500,    -518,    -510]#[8,   57,    118,    10]
  44.   
  45.   # Tp info     x   y
  46. # TP_Info =    [8,  64]
  47.   #
  48.   # color definition【定义颜色】
  49.   #           color 1    R    G    B   Opa     color 2   R   G    B    Opa
  50.   HP_Color = [Color.new(205, 255, 205, 200),   Color.new(10, 220, 45,  200)]
  51.   MP_Color = [Color.new(180, 225, 245, 200),   Color.new(20, 160, 225, 200)]
  52. #  EX_Color = [Color.new(180, 225, 245, 200),   Color.new(20, 160, 225, 200)]
  53.   
  54.   # Do you want to display graphics instead of script drawing bars?
  55.   # if so, fill this actors bars graphics requirements
  56.   # 想要用图像显示血条之类的而不是脚本简单的绘制?是的话,补充完整下面的栏目
  57.   
  58.   ActorsHp    = "HP"       # 玩家HP条图像名字 (引号内)
  59.   ActorsMp    = "Bullet"       # MP条名字
  60.   ActorsExp   = ""       # 经验条,不需要的话留空""
  61.   ActorsBack  = "BattleBackground"
  62.   
  63.   #=============================================================================
  64.   # * Normal Enemies bars【正常的敌人栏】
  65.   #
  66.   # Normal enemies Bars x and y position on the screen
  67.   NeScreenPos_X = 390
  68.   NeScreenPos_Y = 10
  69.   #
  70.   # Dimentions of the bars you cant exceed 300 width x 100 height
  71.   #                    x    y     width   height
  72.   EHP_BarDimentions = [8,   16,    126,    10]
  73.   #
  74.   # color definition
  75.   #            color 1    R    G    B   Opa     color 2   R   G    B    Opa
  76.   EHP_Color = [Color.new(205, 255, 205, 200),   Color.new(10, 220, 45,  200)]
  77.   
  78.   # if you want to display grahics bar pictures fill this
  79.   NormalEne = ""           # normal enemy hp bar
  80.   NormalBack = ""          # Background semi-transparent bar
  81.   
  82.   #=============================================================================
  83.   # * Enemy Boss HP Bar【BOSS的条子】
  84.   #
  85.   # Boss enemies Bar x and y position on the screen
  86.   BeScreenPos_X = 100
  87.   BeScreenPos_Y = 286
  88.   #
  89.   # Dimentions of the bars you cant exceed 640 width x 100 height
  90.   #                    x    y     width   height
  91.   BHP_BarDimentions = [8,   22,    330,    12]
  92.   #
  93.   #            color 1    R    G    B   Opa     color 2   R   G    B    Opa
  94.   BHP_Color = [Color.new(205, 255, 205, 200),   Color.new(10, 220, 45,  200)]
  95.   
  96.   # if you want to display grahics bar pictures fill this
  97.   BossEne = ""        # Boss enemy Hp bar
  98.   BossBack = ""       # Background semi-transparent bar
  99.   #=============================================================================
  100.   
  101.   def self.show() $game_system.pearlbars = nil  end
  102.   def self.hide() $game_system.pearlbars = true end
  103.    
  104.   def self.enemy_auto(event_id)
  105.     $game_system.enemy_lifeobject = $game_map.events[event_id]
  106.   end

  107. end

  108. ($imported ||= {})["Falcao Pearl ABS Life"] = true

  109. class Spriteset_Map
  110.   
  111.   alias falcaopearl_lifebars_create create_pictures
  112.   def create_pictures
  113.     create_hud_lifebars
  114.     falcaopearl_lifebars_create
  115.   end
  116.   
  117.   def create_hud_lifebars
  118.     @enemy_lifeobject = $game_system.enemy_lifeobject
  119.     @enemyhpsp = Sprite_LifeBars.new(@viewport2, @enemy_lifeobject) if
  120.     not @enemy_lifeobject.nil?
  121.   end
  122.   
  123.   def create_actorlifebars
  124.     return if !@actor_lifebar.nil?
  125.     @actor_lifebar = Sprite_LifeBars.new(@viewport2, $game_player)
  126.   end
  127.   
  128.   def dispose_actorlifebars
  129.     return if @actor_lifebar.nil?
  130.     @actor_lifebar.dispose
  131.     @actor_lifebar = nil
  132.   end
  133.   
  134.   alias falcaopearl_lifebars_update update
  135.   def update
  136.     update_lifebars_sprites
  137.     falcaopearl_lifebars_update
  138.   end
  139.   
  140.   def update_lifebars_sprites
  141.     $game_system.pearlbars.nil? ? create_actorlifebars : dispose_actorlifebars
  142.     @actor_lifebar.update unless @actor_lifebar.nil?
  143.    
  144.     # enemy
  145.     if !@enemyhpsp.nil?
  146.       unless @enemyhpsp.disposed?
  147.         @enemyhpsp.update
  148.       else
  149.         @enemyhpsp.dispose
  150.         @enemyhpsp = nil
  151.         $game_system.enemy_lifeobject = nil
  152.         @enemy_lifeobject = nil
  153.       end
  154.     end
  155.    
  156.     if @enemy_lifeobject != $game_system.enemy_lifeobject
  157.       @enemyhpsp.dispose if !@enemyhpsp.nil?
  158.       @enemyhpsp = nil
  159.       @enemyhpsp = Sprite_LifeBars.new(@viewport2,$game_system.enemy_lifeobject)
  160.       @enemy_lifeobject = $game_system.enemy_lifeobject
  161.     end
  162.   end

  163.   alias falcaopearl_lifebars_dispose dispose
  164.   def dispose
  165.     dispose_actorlifebars
  166.     @enemyhpsp.dispose unless @enemyhpsp.nil?
  167.     falcaopearl_lifebars_dispose
  168.   end
  169. end

  170. # Life bars sprite
  171. class Sprite_LifeBars < Sprite
  172.   include PearlBars
  173.   def initialize(viewport, character)
  174.     super(viewport)
  175.     @character = character
  176.     self.bitmap = Bitmap.new(boss? ? 640 : 300, 120)
  177.     @old_hp = battler.hp
  178.     @old_mp = battler.mp
  179.     @erasetimer = 180
  180.     @state_checker = []
  181.     @buff_checker = []
  182.     refresh_contents
  183.     @view = viewport
  184.     update
  185.   end
  186.   
  187.   def boss?
  188.     return true if battler.is_a?(Game_Enemy) && battler.boss_hud
  189.     return false
  190.   end
  191.   
  192.   def battler
  193.     return @character.battler
  194.   end
  195.   
  196.   def refresh_contents
  197.     self.bitmap.clear
  198.     self.bitmap.font.size = 19
  199.     @erasetimer = 180
  200.     self.opacity = 255
  201.       if battler.is_a?(Game_Actor)
  202.   #    @old_exp = battler.exp
  203.    #   @old_tp = battler.tp
  204.       self.x = ScreenPos_X
  205.       self.y = ScreenPos_Y
  206.       h  = HP_BarDimentions ; m = MP_BarDimentions #; e = EX_BarDimentions
  207.       if PearlBars::ActorsHp != ""
  208.         @pimg = Cache.picture(PearlBars::ActorsHp)  if @pimg.nil?
  209.         @bimg = Cache.picture(PearlBars::ActorsBack) if @bimg.nil?
  210.         @pimp = Cache.picture(PearlBars::ActorsMp)  if @pimp.nil?
  211.         PearlKernel.image_mp(self.bitmap, m[0] + 4, m[1], @bimg, @pimp, battler )
  212.         PearlKernel.image_hp(self.bitmap, h[0] + 4, h[1], @bimg, @pimg, battler,true)
  213.         #if PearlBars::ActorsExp != ""
  214.          # @piexp = Cache.picture(PearlBars::ActorsExp)  if @piexp.nil?
  215.         #  PearlKernel.image_exp(self.bitmap,e[0] + 4,e[1],@bimg,@piexp, battler)
  216.         #end
  217.       else
  218.         hc = HP_Color ; mc = MP_Color ; #ec = EX_Color
  219.         PearlKernel.draw_hp(self.bitmap,battler, h[0], h[1], h[2], h[3], hc)
  220.         PearlKernel.draw_mp(self.bitmap,battler, m[0], m[1], m[2], m[3], mc)
  221. #        PearlKernel.draw_exp(self.bitmap,battler, e[0], e[1], e[2], e[3], ec)
  222.       end
  223. #     PearlKernel.draw_tp(self.bitmap, TP_Info[0], TP_Info[1], battler)
  224.     else battler.is_a?(Game_Enemy)
  225.       if boss?
  226.         self.x = BeScreenPos_X
  227.         self.y = BeScreenPos_Y
  228.         h  = BHP_BarDimentions ; hc = BHP_Color
  229.         if PearlBars::BossEne != ""
  230.           @n_img = Cache.picture(PearlBars::BossEne) if @n_img.nil?
  231.           @n_back = Cache.picture(PearlBars::BossBack) if @n_back.nil?
  232.           PearlKernel.image_hp(self.bitmap, h[0] + 4, h[1],@n_back,
  233.           @n_img, battler,true)
  234.         else
  235.           PearlKernel.draw_hp(self.bitmap,battler, h[0],h[1],h[2], h[3],hc,true)
  236.         end
  237.       else
  238.         self.x = NeScreenPos_X
  239.         self.y = NeScreenPos_Y
  240.         h  = EHP_BarDimentions ; hc = EHP_Color
  241.         if PearlBars::NormalEne != ""
  242.           @n_img = Cache.picture(PearlBars::NormalEne) if @n_img.nil?
  243.           @n_back = Cache.picture(PearlBars::NormalBack) if @n_back.nil?
  244.           PearlKernel.image_hp(self.bitmap, h[0] + 4, h[1],@n_back,
  245.           @n_img, battler,true)
  246.         else
  247.           PearlKernel.draw_hp(self.bitmap,battler,h[0],h[1],h[2], h[3], hc,true)
  248.         end
  249.       end
  250.     end
  251.   end
  252.   
  253.   def update
  254.     super
  255.    
  256.    
  257.     if battler.nil?
  258.       dispose
  259.       return
  260.     end
  261.    
  262.     if @old_hp != battler.hp
  263.       refresh_contents
  264.       @old_hp = battler.hp
  265.     end
  266.     if @old_mp != battler.mp
  267.       refresh_contents
  268.       @character.actor.apply_usability if @character.is_a?(Game_Player)
  269.       @old_mp = battler.mp
  270.     end
  271.    
  272.     if battler.is_a?(Game_Actor)
  273.       if @old_exp != battler.exp
  274.         @old_exp = battler.exp
  275.         refresh_contents
  276.       end
  277.    #   if @old_tp != battler.tp
  278.    #     @old_tp = battler.tp
  279.    #     @character.actor.apply_usability if @character.is_a?(Game_Player)
  280.     #    refresh_contents
  281.     #  end
  282.       
  283.     elsif battler.is_a?(Game_Enemy)
  284.       if boss?
  285.         dispose if battler.dead?
  286.       else
  287.         if @erasetimer > 0
  288.           @erasetimer -= 1
  289.           self.opacity -= 10 if @erasetimer <= 25
  290.           @states.opacity = self.opacity if !@states.nil?
  291.           dispose if @erasetimer == 0
  292.         end
  293.       end
  294.       update_enemy_status_icons
  295.     end
  296.   end
  297.   
  298.   # enemy status icons engine
  299.   def update_enemy_status_icons
  300.     display_status? ? create_states_icons : dispose_state_icons
  301.     4.times.each {|i| refresh_states_icons if
  302.     @state_checker[i] != battler.state_icons[i]}
  303.     2.times.each {|i| refresh_states_icons if
  304.     @buff_checker[i] != battler.buff_icons[i]}
  305.   end
  306.   
  307.   def display_status?
  308.     return true if !battler.state_icons.empty?
  309.     return true if !battler.buff_icons.empty?
  310.     return false
  311.   end
  312.   
  313.   def create_states_icons
  314.     return if disposed?
  315.     return if !@states.nil?
  316.     @states = ::Sprite.new(@view)
  317.     @states.bitmap = Bitmap.new(144, 24)
  318.     @n_back.nil? ? y_plus = BHP_BarDimentions[3] : y_plus = @n_back.height
  319.     pos = [BeScreenPos_X, BeScreenPos_Y, y_plus] if  boss?
  320.     pos = [NeScreenPos_X, NeScreenPos_Y, y_plus] if !boss?
  321.     @states.x = pos[0] + 10
  322.     @states.y = pos[1] + pos[2] + 24
  323.     @states.zoom_x = 0.8
  324.     @states.zoom_y = 0.8
  325.     refresh_states_icons
  326.   end
  327.   
  328.   def dispose_state_icons
  329.     return if @states.nil?
  330.     @states.bitmap.dispose
  331.     @states.dispose
  332.     @states = nil
  333.   end
  334.   
  335.   def refresh_states_icons
  336.     4.times.each {|i| @state_checker[i] = battler.state_icons[i]}
  337.     2.times.each {|i| @buff_checker[i] = battler.buff_icons[i]}
  338.     return if @states.nil?
  339.     @states.bitmap.clear
  340.     x = 0
  341.     battler.state_icons.each {|icon| draw_icon(icon, x, 0) ; x += 24
  342.     break if x == 96}
  343.     count = 0
  344.     battler.buff_icons.each {|icon| draw_icon(icon, x, 0) ; x += 24 ; count += 1
  345.     break if count == 2}
  346.   end
  347.   
  348.   def draw_icon(icon_index, x, y, enabled = true)
  349.     bit = Cache.system("Iconset")
  350.     rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  351.     @states.bitmap.blt(x, y, bit, rect, enabled ? 255 : 150)
  352.   end
  353.   
  354.   def dispose
  355.     self.bitmap.dispose
  356.     dispose_state_icons
  357.     super
  358.   end
  359. end

  360. # Make the enemy bars to load when enemy is hited
  361. class Projectile < Game_Character
  362.   alias falcao_lifebars_execute execute_damageto_enemy
  363.   def execute_damageto_enemy(event)
  364.     $game_system.enemy_lifeobject = event if @user.is_a?(Game_Player) &&
  365.     !event.battler.object
  366.     falcao_lifebars_execute(event)
  367.   end
  368. end
复制代码
梦石
0
星屑
401
在线时间
330 小时
注册时间
2013-8-24
回帖
81
 楼主| 发表于 2016-8-19 21:13:04 | 显示全部楼层
h.png
↑完成效果大概是这样,想把hp的背景弄没就好了
回复

使用道具 举报

梦石
0
星屑
9726
在线时间
2775 小时
注册时间
2008-9-5
回帖
3458

开拓者短篇八RM组冠军短篇九导演组亚军白银编剧

发表于 2016-8-19 22:14:36 | 显示全部楼层
  1. # image based bars definition
  2.   def self.image_hp(bitmap, x, y, back, image, battler, name=nil, with_back=false)
  3.     tag = 'Hp'
  4.     name = battler.name if !name.nil?
  5.     draw_i_gauge(bitmap, x, y, back, image, battler.hp, battler.mhp, tag, name, with_back)
  6.   end

  7.   def self.image_mp(bitmap, x, y, back, image, battler, name=nil, with_back=true)
  8.     tag = 'Mp'
  9.     name = battler.name if !name.nil?
  10.     draw_i_gauge(bitmap, x, y, back, image, battler.mp, battler.mmp, tag, name, with_back)
  11.   end

  12.   def self.draw_i_gauge(bitmap, x, y, back, image, nm, max, tag, name, with_back)
  13.     cw = back.width  
  14.     ch = back.height
  15.     max = 1 if max == 0
  16.     src_rect = Rect.new(0, 0, cw, ch)   
  17.     bitmap.blt(x - 12, y - ch + 30, back, src_rect) if with_back# 这里与背景有关
  18.     cw = image.width  * nm / max
  19.     ch = image.height
  20.     src_rect = Rect.new(0, 0, cw, ch)
  21.     bitmap.blt(x - -35, y - ch + 23, image, src_rect)
  22.    # bitmap.draw_text(x - 4, y + back.height - 14, back.width, 32, tag)
  23.    # bitmap.draw_text(x - 12, y + back.height - 14, back.width, 32, nm.to_s, 2)
  24.    # bitmap.draw_text(x - 6, y - 10, back.width, 32, name, 1) if !name.nil?
  25.   end
复制代码

给这3个方法加了个参数“with_back”,
HP默认不绘制背景,MP默认会绘制背景。
“与背景有关”的那句后面加了个条件,只有传进去的with_back的值是true才会绘制背景。
可以替换原脚本的这3个方法,或者搜索这段代码里的“with_back”,给原脚本对应的位置加上。

评分

参与人数 2星屑 +265 梦石 +1 收起 理由
RaidenInfinity + 250 + 1 楼主认可的解答
bakaki + 15 非常感谢!!!

查看全部评分

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部