Guest User

Script2 Falcao

a guest
Jan 22nd, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 58.64 KB | None | 0 0
  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. #===============================================================================
  7.  
  8. module PearlKernel
  9.  
  10. # 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. # 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
  24. # wheter the follower can start fighting. enemy away from this tiles
  25. # whil be ignored untill the player is near them
  26. # distamce measured in tiles
  27. PlayerRange = 7
  28.  
  29. # When a follower fail an action this balloon is played, runs out of mana etc.
  30. FailBalloon = 1
  31.  
  32. # Start the game with the ABS huds turned on?
  33. StartWithHud = true
  34.  
  35. # Do you want to activate the followers dead poses?
  36. FollowerDeadPose = true
  37.  
  38. # Do you want to activate the single player mode?
  39. # this only avoid you accesing the player slection menu and the K key is used
  40. # to open the quick tool selection menu
  41. SinglePlayer = false
  42.  
  43. #-----------------------------------------------------------------------------
  44. @gaugeback = Color.new(0, 0, 0, 100)
  45. def self.draw_hp(obj, battler, x, y, w, h, color, name=nil)
  46. tag = 'Hp' ; c = color
  47. name = battler.name if !name.nil?
  48. draw_gauge(obj, battler.hp, battler.mhp, x, y, w, h, c, tag, name)
  49. end
  50.  
  51. def self.draw_mp(obj, battler, x, y, w, h, color, name=nil)
  52. tag = 'Mp' ; c = color
  53. name = battler.name if !name.nil?
  54. draw_gauge(obj, battler.mp, battler.mmp, x, y, w, h, c, tag, name)
  55. end
  56.  
  57. def self.draw_exp(obj, battler, x, y, w, h, color, name=nil)
  58. tag = 'Exp' ; c = color
  59. name = battler.name if !name.nil?
  60. draw_gauge(obj,battler.exp, battler.next_level_exp, x, y, w, h, c, tag,name)
  61. end
  62.  
  63. def self.draw_tp(obj, x, y, actor)
  64. string = 'Tp ' + (actor.tp).to_i.to_s
  65. obj.fill_rect(x, y + 10 , string.length * 9, 12, @gaugeback)
  66. obj.draw_text(x, y, obj.width, 32, string)
  67. end
  68.  
  69. def self.draw_gauge(obj, nm, max, x, y, w, h, col, tag, name)
  70. obj.font.shadow = true
  71. w2 = w - 2 ; max = 1 if max == 0
  72. obj.fill_rect(x, y - 1, w, h + 2, @gaugeback)
  73. obj.fill_rect(x+1, y+1, w2*nm/max, h/2 - 1, col[0])
  74. obj.fill_rect(x+1, y + h/2, w2*nm/max, h/2 - 1, col[1])
  75. obj.draw_text(x, y + h - 22, w, 32, nm.to_s, 2)
  76. obj.draw_text(x + 4, y + h - 22, w, 32, tag)
  77. obj.draw_text(x, y - 25, w, 32, name, 1) if !name.nil?
  78. end
  79.  
  80. # image based bars definition
  81. def self.image_hp(bitmap, x, y, back, image, battler, name=nil)
  82. tag = 'Hp'
  83. name = battler.name if !name.nil?
  84. draw_i_gauge(bitmap, x, y, back, image, battler.hp, battler.mhp, tag, name)
  85. end
  86.  
  87. def self.image_mp(bitmap, x, y, back, image, battler, name=nil)
  88. tag = 'Mp'
  89. name = battler.name if !name.nil?
  90. draw_i_gauge(bitmap, x, y, back, image, battler.mp, battler.mmp, tag, name)
  91. end
  92.  
  93. def self.image_exp(bitmap, x, y, back, image, battler, name=nil)
  94. tag = 'Exp'
  95. name = battler.name if !name.nil?
  96. exp, nexte = battler.exp, battler.next_level_exp
  97. draw_i_gauge(bitmap, x, y, back, image, exp, nexte, tag, name)
  98. end
  99.  
  100. def self.draw_i_gauge(bitmap, x, y, back, image, nm, max, tag, name)
  101. cw = back.width
  102. ch = back.height
  103. max = 1 if max == 0
  104. src_rect = Rect.new(0, 0, cw, ch)
  105. bitmap.blt(x - 10, y - ch + 30, back, src_rect)
  106. cw = image.width * nm / max
  107. ch = image.height
  108. src_rect = Rect.new(0, 0, cw, ch)
  109. bitmap.blt(x - 10, y - ch + 30, image, src_rect)
  110. bitmap.draw_text(x - 4, y + back.height - 14, back.width, 32, tag)
  111. bitmap.draw_text(x - 12, y + back.height - 14, back.width, 32, nm.to_s, 2)
  112. bitmap.draw_text(x - 6, y - 10, back.width, 32, name, 1) if !name.nil?
  113. end
  114.  
  115. def self.has_data?
  116. !user_graphic.nil?
  117. end
  118.  
  119. def self.load_item(item)
  120. @item = item
  121. end
  122.  
  123. def self.user_graphic() @item.tool_data("User Graphic = ", false) end
  124. def self.user_animespeed() @item.tool_data("User Anime Speed = ") end
  125. def self.tool_cooldown() @item.tool_data("Tool Cooldown = ") end
  126. def self.tool_graphic() @item.tool_data("Tool Graphic = ", false) end
  127. def self.tool_index() @item.tool_data("Tool Index = ") end
  128. def self.tool_size() @item.tool_data("Tool Size = ") end
  129. def self.tool_distance() @item.tool_data("Tool Distance = ") end
  130. def self.tool_effectdelay() @item.tool_data("Tool Effect Delay = ") end
  131. def self.tool_destroydelay() @item.tool_data("Tool Destroy Delay = ") end
  132. def self.tool_speed() @item.tool_float("Tool Speed = ") end
  133. def self.tool_castime() @item.tool_data("Tool Cast Time = ") end
  134. def self.tool_castanimation() @item.tool_data("Tool Cast Animation = ") end
  135. def self.tool_blowpower() @item.tool_data("Tool Blow Power = ") end
  136. def self.tool_piercing() @item.tool_data("Tool Piercing = ", false) end
  137. def self.tool_animation() @item.tool_data("Tool Animation When = ", false) end
  138. def self.tool_anirepeat() @item.tool_data("Tool Animation Repeat = ",false)end
  139. def self.tool_special() @item.tool_data("Tool Special = ", false) end
  140. def self.tool_target() @item.tool_data("Tool Target = ", false) end
  141. def self.tool_invoke() @item.tool_data("Tool Invoke Skill = ") end
  142. def self.tool_guardrate() @item.tool_data("Tool Guard Rate = ") end
  143. def self.tool_knockdown() @item.tool_data("Tool Knockdown Rate = ") end
  144. def self.tool_soundse() @item.tool_data("Tool Sound Se = ", false) end
  145. def self.tool_itemcost() @item.tool_data("Tool Item Cost = ") end
  146. def self.tool_shortjump() @item.tool_data("Tool Short Jump = ", false) end
  147. def self.tool_through() @item.tool_data("Tool Through = ", false) end
  148. def self.tool_priority() @item.tool_data("Tool Priority = ") end
  149. def self.tool_selfdamage() @item.tool_data("Tool Self Damage = ", false) end
  150. def self.tool_hitshake() @item.tool_data("Tool Hit Shake = ", false) end
  151. def self.tool_combo() @item.tool_data("Tool Combo Tool = ", false) end
  152.  
  153. def self.knock_actor(actor)
  154. a = actor.actor.tool_data("Knockdown Graphic = ", false)
  155. b = actor.actor.tool_data("Knockdown Index = ")
  156. c = actor.actor.tool_data("Knockdown pattern = ")
  157. d = actor.actor.tool_data("Knockdown Direction = ")
  158. return nil if a.nil?
  159. return [a, b, c, d]
  160. end
  161.  
  162. def self.jump_hit?(target)
  163. t = target.enemy.tool_data("Hit Jump = ", false) if target.is_a?(Game_Enemy)
  164. t = target.actor.tool_data("Hit Jump = ", false) if target.is_a?(Game_Actor)
  165. return true if !t.nil? and t == "true"
  166. return true if t.nil?
  167. return false
  168. end
  169.  
  170. def self.voices(b)
  171. voices = b.actor.tool_data("Battler Voices = ",false) if b.is_a?(Game_Actor)
  172. voices = b.enemy.tool_data("Battler Voices = ",false) if b.is_a?(Game_Enemy)
  173. voices = voices.split(", ") unless voices.nil?
  174. voices
  175. end
  176.  
  177. def self.hitvoices(b)
  178. voices = b.actor.tool_data("Hit Voices = ",false) if b.is_a?(Game_Actor)
  179. voices = b.enemy.tool_data("Hit Voices = ",false) if b.is_a?(Game_Enemy)
  180. voices = voices.split(", ") unless voices.nil?
  181. voices
  182. end
  183.  
  184. # check for iconset
  185. def self.check_iconset(item, tag, object)
  186. data = item.tool_data(tag, false)
  187. return if data.nil?
  188. v = [item.icon_index, data.to_sym] if data == "animated" ||
  189. data == "static" || data == "shielding"
  190. object.is_a?(Projectile) ? object.pro_iconset = v : object.user_iconset = v
  191. end
  192.  
  193. def self.clean_back?
  194. @clean_back == true
  195. end
  196. end
  197.  
  198. ($imported ||= {})["Falcao Pearl ABS Liquid"] = true
  199.  
  200. class RPG::BaseItem
  201. attr_reader :has_data
  202. def tool_data(comment, sw=true)
  203. if @note =~ /#{comment}(.*)/i
  204. @has_data = true
  205. return sw ? $1.to_i : $1.to_s.sub("\r","")
  206. end
  207. end
  208.  
  209. def tool_float(comment)
  210. return $1.to_f if @note =~ /#{comment}(.*)/i
  211. end
  212.  
  213. def cool_enabled?
  214. @cd_dis = @note.include?("Tool Cooldown Display = true") if @cd_dis.nil?
  215. @cd_dis
  216. end
  217.  
  218. def itemcost
  219. if @i_cost.nil?
  220. @note =~ /Tool Item Cost = (.*)/i ? @i_cost = $1.to_i : @i_cost = 0
  221. end
  222. @i_cost
  223. end
  224. end
  225.  
  226. # Pearl ABS Input module
  227. module PearlKey
  228.  
  229. # numbers
  230. N0 = 0x30; N1 = 0x31; N2 = 0x32; N3 = 0x33; N4 = 0x34
  231. N5 = 0x35; N6 = 0x36; N7 = 0x37; N8 = 0x38; N9 = 0x39
  232.  
  233. # keys
  234. A = 0x41; B = 0x42; C = 0x43; D = 0x44; E = 0x45
  235. F = 0x46; G = 0x47; H = 0x48; I = 0x49; J = 0x4A
  236. K = 0x4B; L = 0x4C; M = 0x4D; N = 0x4E; O = 0x4F
  237. P = 0x50; Q = 0x51; R = 0x52; S = 0x53; T = 0x54
  238. U = 0x55; V = 0x56; W = 0x57; X = 0x58; Y = 0x59; Z = 0x5A
  239.  
  240. @unpack_string = 'b'*256
  241. @last_array = '0'*256
  242. @press = Array.new(256, false)
  243. @trigger = Array.new(256, false)
  244. @release = Array.new(256, false)
  245. @getKeyboardState = Win32API.new('user32', 'GetKeyboardState', ['P'], 'V')
  246. @getAsyncKeyState = Win32API.new('user32', 'GetAsyncKeyState', 'i', 'i')
  247. @getKeyboardState.call(@last_array)
  248.  
  249. @last_array = @last_array.unpack(@unpack_string)
  250. for i in 0...@last_array.size
  251. @press[i] = @getAsyncKeyState.call(i) == 0 ? false : true
  252. end
  253.  
  254. def self.update
  255. @trigger = Array.new(256, false)
  256. @release = Array.new(256, false)
  257. array = '0'*256
  258. @getKeyboardState.call(array)
  259. array = array.unpack(@unpack_string)
  260. for i in 0...array.size
  261. if array[i] != @last_array[i]
  262. @press[i] = @getAsyncKeyState.call(i) == 0 ? false : true
  263. if !@press[i]
  264. @release[i] = true
  265. else
  266. @trigger[i] = true
  267. end
  268. else
  269. if @press[i] == true
  270. @press[i] = @getAsyncKeyState.call(i) == 0 ? false : true
  271. @release[i] = true if !@press[i]
  272. end
  273. end
  274. end
  275. @last_array = array
  276. end
  277.  
  278. def self.press?(key)
  279. return @press[key]
  280. end
  281.  
  282. def self.trigger?(key)
  283. return @trigger[key]
  284. end
  285. end
  286.  
  287. # Input module update engine
  288. class << Input
  289. alias falcaopearl_abs_cooldown_update update
  290. def Input.update
  291. update_pearl_abs_cooldown
  292. update_popwindow if !$game_temp.nil? and !$game_temp.pop_windowdata.nil?
  293. update_pearl_abs_respawn
  294. falcaopearl_abs_cooldown_update
  295. end
  296.  
  297.  
  298. def update_pearl_abs_respawn
  299. $game_map.event_enemies.each do |event|
  300. if event.respawn_count > 0
  301. event.respawn_count -= 1
  302. if event.respawn_count == 0
  303. event.battler.remove_state(event.battler.death_state_id)
  304. event.battler.hp = event.battler.mhp
  305. event.battler.mp = event.battler.mmp
  306. event.apply_respawn
  307. event.animation_id = event.respawn_anim
  308. end
  309. end
  310. end
  311. end
  312.  
  313. alias falcaopearl_trigger trigger?
  314. def trigger?(constant)
  315. return true if constant == :B and PearlKey.trigger?(PearlKey::B)
  316. falcaopearl_trigger(constant)
  317. end
  318.  
  319. # pop window global
  320. def update_popwindow
  321. $game_temp.pop_windowdata[0] -= 1 if $game_temp.pop_windowdata[0] > 0
  322. if @temp_window.nil?
  323. tag = $game_temp.pop_windowdata[2]
  324. string = $game_temp.pop_windowdata[1] + tag
  325. width = (string.length * 9) - 10
  326. x, y = Graphics.width / 2 - width / 2, Graphics.height / 2 - 64 / 2
  327. @temp_window = Window_Base.new(x, y, width, 64)
  328. @temp_window.contents.font.size = 20
  329. @temp_window.draw_text(-10, -6, width, 32, tag, 1)
  330. @temp_window.draw_text(-10, 14, width, 32, $game_temp.pop_windowdata[1],1)
  331. @current_scene = SceneManager.scene.class
  332. end
  333.  
  334. if $game_temp.pop_windowdata[0] == 0 ||
  335. @current_scene != SceneManager.scene.class
  336. @temp_window.dispose
  337. @temp_window = nil
  338. $game_temp.pop_windowdata = nil
  339. end
  340. end
  341.  
  342. def update_pearl_abs_cooldown
  343. PearlKey.update
  344. eval_cooldown($game_party.all_members) if !$game_party.nil?
  345. eval_cooldown($game_map.enemies) if !$game_map.nil?
  346. end
  347.  
  348. # cooldown update
  349. def eval_cooldown(operand)
  350. for sub in operand
  351. sub.skill_cooldown.each {|sid, sv| # skill
  352. if sub.skill_cooldown[sid] > 0
  353. sub.skill_cooldown[sid] -= 1
  354. sub.skill_cooldown.delete(sid) if sub.skill_cooldown[sid] == 0
  355. end}
  356. sub.item_cooldown.each {|iid, iv| # item
  357. if sub.item_cooldown[iid] > 0
  358. sub.item_cooldown[iid] -= 1
  359. sub.item_cooldown.delete(iid) if sub.item_cooldown[iid] == 0
  360. end}
  361. sub.weapon_cooldown.each {|wid, wv| # weapon
  362. if sub.weapon_cooldown[wid] > 0
  363. sub.weapon_cooldown[wid] -= 1
  364. sub.weapon_cooldown.delete(wid) if sub.weapon_cooldown[wid] == 0
  365. end}
  366. sub.armor_cooldown.each {|aid, av| #armor
  367. if sub.armor_cooldown[aid] > 0
  368. sub.armor_cooldown[aid] -= 1
  369. sub.armor_cooldown.delete(aid) if sub.armor_cooldown[aid] == 0
  370. end}
  371. end
  372. end
  373. end
  374.  
  375. #===============================================================================
  376. #===============================================================================
  377. # Game character
  378.  
  379. class Game_CharacterBase
  380. attr_accessor :just_hitted, :anime_speed, :blowpower, :targeting, :x, :y
  381. attr_accessor :battler_guarding, :knockdown_data, :colapse_time, :opacity
  382. attr_accessor :zoomfx_x, :zoomfx_y, :targeted_character, :stuck_timer
  383. attr_accessor :send_dispose_signal, :follower_attacktimer, :stopped_movement
  384. attr_accessor :hookshoting, :battler_chain, :pattern, :user_move_distance
  385. attr_accessor :move_speed, :through, :being_grabbed, :making_spiral
  386. attr_accessor :direction, :direction_fix, :zfx_bol, :buff_pop_stack
  387. attr_accessor :die_through, :target_index, :using_custom_g, :combodata
  388. attr_accessor :originalasp, :doingcombo, :angle_fx
  389. attr_accessor :user_iconset, :pro_iconset, :respawn_count
  390. alias falcaopearl_abmain_ini initialize
  391. def initialize
  392. @zfx_bol = false
  393. @just_hitted = 0
  394. @anime_speed = 0
  395. @respawn_count = 0
  396. @blowpower = [0, dir=2, dirfix=false, s=4, wait_reset=0]
  397. @user_casting = [0, nil]
  398. @send_dispose_signal = false
  399. @targeting = [false, item=nil, char=nil]
  400. @colapse_time = 0
  401. @stopped_movement = 0
  402. @follower_attacktimer = 0
  403. set_hook_variables
  404. @target_index = 0
  405. @using_custom_g = false
  406. @combodata = []
  407. @angle_fx = 0.0
  408. #--------------
  409. @zoomfx_x = 1.0
  410. @zoomfx_y = 1.0
  411. @stuck_timer = 0
  412. @battler_guarding = [false, nil]
  413. @knockdown_data = [0, nil, nil, nil, nil]
  414. @state_poptimer = [0, 0]
  415. @making_spiral = false
  416. @buff_pop_stack = []
  417. @doingcombo = 0
  418. @range_view = 2
  419. @originalasp = 0
  420. falcaopearl_abmain_ini
  421. end
  422.  
  423. def set_hook_variables
  424. @hookshoting = [on=false, hooking=false, grabing=false, delay=0]
  425. @battler_chain = []
  426. @user_move_distance = [steps=0, speed=nil, trought=nil, cor=nil, evmove=nil]
  427. @being_grabbed = false
  428. end
  429.  
  430. # projectiles at nt
  431. def projectiles_xy_nt(x, y)
  432. $game_player.projectiles.select {|pro| pro.pos_nt?(x, y) }
  433. end
  434.  
  435. # collide with projectiles
  436. def collide_with_projectiles?(x, y)
  437. projectiles_xy_nt(x, y).any? do |pro|
  438. pro.normal_priority? || self.is_a?(Projectile)
  439. end
  440. end
  441.  
  442. def zoom(x, y)
  443. @zoomfx_x = x
  444. @zoomfx_y = y
  445. end
  446.  
  447. alias falcaopearl_collide_with collide_with_characters?
  448. def collide_with_characters?(x, y)
  449. return true if collide_with_projectiles?(x, y)
  450. falcaopearl_collide_with(x, y)
  451. end
  452.  
  453. # follow character straigh and diagonal
  454. def follow_char(character)
  455. sx = distance_x_from(character.x)
  456. sy = distance_y_from(character.y)
  457. if sx != 0 && sy != 0
  458. move_diagonal(sx > 0 ? 4 : 6, sy > 0 ? 8 : 2)
  459. elsif sx != 0
  460. move_straight(sx > 0 ? 4 : 6)
  461. elsif sy != 0
  462. move_straight(sy > 0 ? 8 : 2)
  463. end
  464. end
  465.  
  466. def on_battle_screen?(out = 0)
  467. max_w = (Graphics.width / 32).to_i - 1
  468. max_h = (Graphics.height / 32).to_i - 1
  469. sx = (screen_x / 32).to_i
  470. sy = (screen_y / 32).to_i
  471. if sx.between?(0 - out, max_w + out) and sy.between?(0 - out, max_h + out)
  472. return true
  473. end
  474. return false
  475. end
  476.  
  477. # jump to specific tiles
  478. def jumpto_tile(x, y)
  479. jumpto(0, [x, y])
  480. end
  481.  
  482. # jumpto character ( 0 = Game Player, 1 and up event id)
  483. def jumpto(char_id, tilexy=nil)
  484. char_id > 0 ? char = $game_map.events[char_id] : char = $game_player
  485. tilexy.nil? ? condxy = [char.x, char.y] : condxy = [tilexy[0], tilexy[1]]
  486. jx = + eval_distance(tilexy.nil? ? char : tilexy)[0] if condxy[0] >= @x
  487. jy = - eval_distance(tilexy.nil? ? char : tilexy)[1] if condxy[1] <= @y
  488. jx = - eval_distance(tilexy.nil? ? char : tilexy)[0] if condxy[0] <= @x
  489. jy = - eval_distance(tilexy.nil? ? char : tilexy)[1] if condxy[1] <= @y
  490. jx = - eval_distance(tilexy.nil? ? char : tilexy)[0] if condxy[0] <= @x
  491. jy = + eval_distance(tilexy.nil? ? char : tilexy)[1] if condxy[1] >= @y
  492. jx = + eval_distance(tilexy.nil? ? char : tilexy)[0] if condxy[0] >= @x
  493. jy = + eval_distance(tilexy.nil? ? char : tilexy)[1] if condxy[1] >= @y
  494. jump(jx, jy)
  495. end
  496.  
  497. # distance
  498. def eval_distance(target)
  499. if target.is_a?(Array)
  500. distance_x = (@x - target[0]).abs
  501. distance_y = (@y - target[1]).abs
  502. else
  503. distance_x = (@x - target.x).abs
  504. distance_y = (@y - target.y).abs
  505. end
  506. return [distance_x, distance_y]
  507. end
  508.  
  509. # check if the game player and follower are executing an action
  510. def battler_acting?
  511. return true if @user_casting[0] > 0 || @targeting[0]
  512. return true if @knockdown_data[0] > 0 and battler.deadposing.nil?
  513. return true if @anime_speed > 0
  514. return true if @hookshoting[0] || @making_spiral
  515. if self.is_a?(Game_Player)
  516. $game_player.followers.each {|f| return true if f.battler_acting?}
  517. end
  518. return false
  519. end
  520.  
  521. def battler
  522. end
  523.  
  524. #use single tools
  525. def use_weapon(id)
  526. return unless tool_can_use?
  527. process_tool_action($data_weapons[id])
  528. end
  529.  
  530. def use_item(id)
  531. return unless tool_can_use?
  532. process_tool_action($data_items[id])
  533. end
  534.  
  535. def use_skill(id)
  536. return unless tool_can_use?
  537. process_tool_action($data_skills[id])
  538. end
  539.  
  540. def use_armor(id)
  541. return unless tool_can_use?
  542. process_tool_action($data_armors[id])
  543. end
  544.  
  545. # use multiple tools
  546. def rand_weapon(*args)
  547. return unless tool_can_use?
  548. process_tool_action($data_weapons[args[rand(args.size)]])
  549. end
  550.  
  551. def rand_item(*args)
  552. return unless tool_can_use?
  553. process_tool_action($data_items[args[rand(args.size)]])
  554. end
  555.  
  556. def rand_skill(*args)
  557. return unless tool_can_use?
  558. process_tool_action($data_skills[args[rand(args.size)]])
  559. end
  560.  
  561. def rand_armor(*args)
  562. return unless tool_can_use?
  563. process_tool_action($data_armors[args[rand(args.size)]])
  564. end
  565.  
  566. def tool_can_use?
  567. return false if @hookshoting[0] || @making_spiral
  568. return false if @user_casting[0] > 0 || @targeting[0]
  569. return false if battler.nil?
  570. return false if battler.dead?
  571. return false if @doingcombo > 0 || @battler_guarding[0]
  572. return false if $game_message.busy?
  573. return true
  574. end
  575.  
  576. def load_target_selection(item)
  577. @targeting[0] = true; @targeting[1] = item
  578. if self.is_a?(Game_Player)
  579. $game_player.pearl_menu_call = [:battler, 2]
  580. elsif self.is_a?(Game_Follower)
  581. @targeting[2] = @targeted_character
  582. @targeting = [false, item=nil, char=nil] if @targeting[2].nil?
  583. elsif self.is_a?(Projectile)
  584. if user.is_a?(Game_Player)
  585. user.targeting[0] = true; user.targeting[1] = item
  586. $game_player.pearl_menu_call = [:battler, 2]
  587. end
  588. if user.is_a?(Game_Follower)
  589. @targeting[2] = user.targeted_character
  590. @targeting = [false, item=nil, char=nil] if @targeting[2].nil?
  591. end
  592. end
  593. end
  594.  
  595. def playdead
  596. @angle_fx = 90
  597. end
  598.  
  599. def resetplaydead
  600. @angle_fx = 0.0
  601. end
  602.  
  603. #action canceling
  604. def force_cancel_actions
  605. @user_casting[0] = 0
  606. @anime_speed = 0
  607. end
  608.  
  609. def speed(x)
  610. @move_speed = x
  611. end
  612.  
  613. def anima(x)
  614. @animation_id = x
  615. end
  616.  
  617. # aply melee params
  618. def apply_weapon_param(weapon, add)
  619. id = 0
  620. for param in weapon.params
  621. add ? battler.add_param(id, param) : battler.add_param(id, -param)
  622. id += 1
  623. end
  624. end
  625.  
  626. # Short script call for poping damage text
  627. def pop_damage(custom=nil)
  628. $game_player.damage_pop.push(DamagePop_Obj.new(self, custom))
  629. end
  630.  
  631. #check if target is unable to move
  632. def force_stopped?
  633. return true if @anime_speed > 0 || @knockdown_data[0] > 0 ||
  634. @stopped_movement > 0 || @hookshoting[0] || @angle_fx != 0.0
  635. return true if @making_spiral
  636. return false
  637. end
  638.  
  639. # sensor
  640. def obj_size?(target, size)
  641. return false if size.nil?
  642. distance = (@x - target.x).abs + (@y - target.y).abs
  643. enable = (distance <= size-1)
  644. return true if enable
  645. return false
  646. end
  647.  
  648. # sensor body
  649. def body_size?(target, size)
  650. distance = (@x - target[0]).abs + (@y - target[1]).abs
  651. enable = (distance <= size-1)
  652. return true if enable
  653. return false
  654. end
  655.  
  656. def faceto_face?(target)
  657. return true if @direction == 2 and target.direction == 8
  658. return true if @direction == 4 and target.direction == 6
  659. return true if @direction == 6 and target.direction == 4
  660. return true if @direction == 8 and target.direction == 2
  661. return false
  662. end
  663.  
  664. def adjustcxy
  665. push_x, push_y = 0, 1 if @direction == 2
  666. push_x, push_y = - 1, 0 if @direction == 4
  667. push_x, push_y = 1, 0 if @direction == 6
  668. push_x, push_y = 0, - 1 if @direction == 8
  669. return [push_x, push_y]
  670. end
  671.  
  672. def in_frontof?(target)
  673. return true if @direction == 2 and @x == target.x and (@y+1) == target.y
  674. return true if @direction == 4 and (@x-1) == target.x and @y == target.y
  675. return true if @direction == 6 and (@x+1) == target.x and @y == target.y
  676. return true if @direction == 8 and @x == target.x and (@y-1) == target.y
  677. return false
  678. end
  679.  
  680. # detect map edges ignoring loop maps
  681. def facing_corners?
  682. case $game_map.map.scroll_type
  683. when 1 then return false if @direction == 2 || @direction == 8
  684. when 2 then return false if @direction == 4 || @direction == 6
  685. when 3 then return false
  686. end
  687. m = $game_map
  688. unless @x.between?(1, m.width - 2) && @y.between?(1, m.height - 2)
  689. return true if @x == 0 and @direction == 4
  690. return true if @y == 0 and @direction == 8
  691. return true if @x == m.width - 1 and @direction == 6
  692. return true if @y == m.height - 1 and @direction == 2
  693. end
  694. return false
  695. end
  696.  
  697. # item usable test
  698. def usable_test_passed?(item)
  699. return true if battler.is_a?(Game_Enemy) && item.is_a?(RPG::Item)
  700. itemcost = item.tool_data("Tool Item Cost = ")
  701. invoke = item.tool_data("Tool Invoke Skill = ")
  702. if battler.is_a?(Game_Actor) and itemcost != nil and itemcost != 0
  703. return false if !battler.usable?($data_items[itemcost])
  704. end
  705. if item.is_a?(RPG::Skill) || item.is_a?(RPG::Item)
  706. return false if !battler.usable?(item)
  707. else
  708. if invoke != nil and invoke != 0
  709. return false if !battler.usable?($data_skills[invoke])
  710. else
  711. return false if !battler.attack_usable?
  712. end
  713. end
  714. return true
  715. end
  716.  
  717. # process the tool and verify wheter can be used
  718. def process_tool_action(item)
  719. PearlKernel.load_item(item)
  720. return if !battler.tool_ready?(item)
  721.  
  722. unless PearlKernel.has_data?
  723. if item.is_a?(RPG::Weapon) || item.is_a?(RPG::Armor)
  724. msgbox('Tool data missing') if $DEBUG
  725. return
  726. end
  727. if item.scope.between?(1, 6)
  728. msgbox('Tool data missing') if $DEBUG
  729. return
  730. elsif item.scope == 0
  731. return
  732.  
  733. elsif !battler.usable?(item)
  734. RPG::SE.new("Cursor1", 80).play if self.is_a?(Game_Player)
  735. return
  736. end
  737. end
  738.  
  739. if PearlKernel.has_data? and not usable_test_passed?(item)
  740. RPG::SE.new("Cursor1", 80).play if self.is_a?(Game_Player)
  741. return
  742. end
  743.  
  744. @user_casting = [PearlKernel.tool_castime,item] if PearlKernel.has_data?
  745. if @user_casting[0] > 0
  746. @animation_id = 0
  747. @animation_id = PearlKernel.tool_castanimation
  748. else
  749. load_abs_tool(item)
  750. end
  751. end
  752.  
  753. # load the abs tool
  754. def load_abs_tool(item)
  755. return if @knockdown_data[0] > 0
  756. PearlKernel.load_item(item)
  757.  
  758. return if self.is_a?(Game_Follower) and @targeted_character.nil?
  759.  
  760. if !@targeting[0] and self.battler.is_a?(Game_Actor)
  761. if item.is_a?(RPG::Skill) || item.is_a?(RPG::Item)
  762. # apply target to skills items
  763. if PearlKernel.tool_target == "true" || item.scope == 7 ||
  764. item.scope == 9
  765. load_target_selection(item)
  766. return
  767. end
  768. else
  769. # apply target parsing the invoked skill to weapons and armors
  770. invoke = PearlKernel.tool_invoke
  771. if invoke != nil && invoke > 0 && invoke != 1 && invoke != 2
  772. invokeskill = $data_skills[invoke]
  773. if PearlKernel.tool_target == "true" || invokeskill.scope == 7 ||
  774. invokeskill.scope == 9
  775. load_target_selection(item)
  776. return
  777. end
  778. # apply target to normal weapon and armor without invoking
  779. else
  780. if PearlKernel.tool_target == "true"
  781. load_target_selection(item)
  782. return
  783. end
  784. end
  785. end
  786. end
  787. if item.is_a?(RPG::Skill) || item.is_a?(RPG::Item)
  788. battler.use_item(item)
  789. else
  790. if PearlKernel.tool_invoke != 0
  791. battler.use_item($data_skills[PearlKernel.tool_invoke])
  792. end
  793. end
  794.  
  795. # if the tool has data continue
  796. if PearlKernel.has_data?
  797. consume_ammo_item(item) if battler.is_a?(Game_Actor) and
  798. PearlKernel.tool_itemcost != 0
  799. @anime_speed = PearlKernel.user_animespeed
  800. battler.apply_cooldown(item, PearlKernel.tool_cooldown)
  801. end
  802. create_projectile_object(item)
  803. create_anime_sprite_object(item)
  804. end
  805.  
  806. # projectile creator
  807. def create_projectile_object(item)
  808. if PearlKernel.tool_special == "hook"
  809. PearlKernel.tool_distance.times {|i|
  810. $game_player.projectiles.push(Projectile.new(self, item, i))}
  811. @hookshoting[0] = true
  812. elsif PearlKernel.tool_special == "triple" # loads 3 projectiles
  813. for i in [:uno, :dos, :tres]
  814. $game_player.projectiles.push(Projectile.new(self, item, i))
  815. end
  816. elsif PearlKernel.tool_special == "quintuple" #loads 5 projectiles
  817. for i in [:uno, :dos, :tres, :cuatro, :cinco]
  818. $game_player.projectiles.push(Projectile.new(self, item, i))
  819. end
  820. elsif PearlKernel.tool_special == "octuple" # loads 8 projectiles
  821. for i in [:uno, :dos, :tres, :cuatro, :cinco, :seis, :siete, :ocho]
  822. $game_player.projectiles.push(Projectile.new(self, item, i))
  823. end
  824. else # load default projectile
  825. $game_player.projectiles.push(Projectile.new(self, item))
  826. end
  827. end
  828.  
  829. # User anime sprite creation
  830. def create_anime_sprite_object(item)
  831. $game_player.anime_action.each {|i|
  832. if i.user == self
  833. if i.custom_graphic
  834. @transparent = false
  835. i.user.using_custom_g = false
  836. end
  837. $game_player.anime_action.delete(i)
  838. end}
  839.  
  840. if PearlKernel.user_graphic != "nil"
  841. return if PearlKernel.user_graphic.nil?
  842. $game_player.anime_action.push(Anime_Obj.new(self, item))
  843. end
  844.  
  845. # using iconset graphic
  846. if PearlKernel.user_graphic == "nil" and
  847. !item.tool_data("User Iconset = ", false).nil?
  848. return if PearlKernel.user_graphic.nil?
  849. $game_player.anime_action.push(Anime_Obj.new(self, item))
  850. end
  851. end
  852.  
  853. # consume ammo item
  854. def consume_ammo_item(item)
  855. itemcost = $data_items[PearlKernel.tool_itemcost]
  856. return if item.is_a?(RPG::Item) and item.consumable and item == itemcost
  857. battler.use_item(itemcost)
  858. end
  859.  
  860. alias falcaopearl_chaupdate update
  861. def update
  862. update_falcao_pearl_abs
  863. falcaopearl_chaupdate
  864. end
  865.  
  866. # Falcao pearl abs main update
  867. def update_falcao_pearl_abs
  868. if @user_move_distance[0] > 0 and not moving?
  869. move_forward ; @user_move_distance[0] -= 1
  870. end
  871. return if battler.nil?
  872. update_pearlabs_timing
  873. update_followers_attack if self.is_a?(Game_Follower) && self.visible?
  874. if @targeting[2] != nil
  875. load_abs_tool(@targeting[1]) if battler.is_a?(Game_Actor)
  876. @targeting = [false, item=nil, char=nil]
  877. end
  878. update_battler_collapse
  879. update_state_effects
  880.  
  881. @combodata.each {|combo|
  882. if combo[3] > 0
  883. combo[3] -= 1
  884. if combo[3] == 0
  885. perform_combo(combo[0], combo[1], combo[2])
  886. @combodata.delete(combo)
  887. end
  888. break
  889. end}
  890. end
  891.  
  892. def perform_combo(kind, id, jumpp)
  893. if jumpp == 'jump'
  894. jump(0, 0)
  895. move_forward
  896. end
  897. case kind
  898. when :weapon then use_weapon(id)
  899. when :armor then use_armor(id)
  900. when :item then use_item(id)
  901. when :skill then use_skill(id)
  902. end
  903. @doingcombo = 12
  904. end
  905.  
  906. #========================================================================
  907. # * followers attacks engine
  908.  
  909. def fo_tool
  910. return actor.equips[0] if actor.primary_use == 1
  911. return actor.equips[1] if actor.primary_use == 2
  912. return actor.assigned_item if actor.primary_use == 3
  913. return actor.assigned_item2 if actor.primary_use == 4
  914. return actor.assigned_skill if actor.primary_use == 5
  915. return actor.assigned_skill2 if actor.primary_use == 6
  916. return actor.assigned_skill3 if actor.primary_use == 7
  917. return actor.assigned_skill4 if actor.primary_use == 8
  918. end
  919.  
  920. # followers attack engine
  921. def update_followers_attack
  922. if fo_tool.nil? || battler.dead?
  923. @targeted_character = nil if @targeted_character != nil
  924. return
  925. end
  926. return if @stopped_movement > 0
  927. if @follower_attacktimer > 0
  928. @follower_attacktimer -= 1
  929. if @follower_attacktimer == 40 and !moving?
  930. r = rand(3)
  931. move_random if r == 0 || r == 1
  932. move_away_from_character(@targeted_character) if
  933. !@targeted_character.nil? and r == 2
  934. end
  935. end
  936.  
  937. # si la skill es para el player
  938. if @targeted_character != nil and @targeted_character.is_a?(Game_Player)
  939. if all_enemies_dead?
  940. delete_targetf
  941. return
  942. end
  943. use_predefined_tool
  944. return
  945. end
  946.  
  947. # si la skill es para un enemigo continuar
  948. if @targeted_character != nil
  949. use_predefined_tool
  950. return if @targeted_character.nil?
  951. # reset if the target is dead
  952. if @targeted_character.collapsing?
  953. force_cancel_actions
  954. delete_targetf
  955. end
  956. else
  957. # select a follower slected target
  958. $game_player.followers.each do |follower|
  959. if !follower.targeted_character.nil?
  960. next if follower.targeted_character.is_a?(Game_Player)
  961. if follower.stuck_timer >= 10
  962. follower.targeted_character = nil
  963. return
  964. end
  965. @targeted_character = follower.targeted_character
  966. break
  967. end
  968. end
  969. end
  970. end
  971.  
  972. # prepare the tool usage
  973. def setup_followertool_usage
  974. @range_view = 2
  975. @range_view = 6 if fo_tool.tool_data("Tool Target = ", false) == "true" ||
  976. fo_tool.tool_data("Tool Special = ", false) == "autotarget"
  977.  
  978. if fo_tool.is_a?(RPG::Skill) || fo_tool.is_a?(RPG::Item)
  979. if fo_tool.scope.between?(1, 6)
  980. setup_target
  981. else ; @targeted_character = $game_player
  982. @range_view = 6
  983. end
  984. # prepare tool for invoke follower
  985. elsif fo_tool.is_a?(RPG::Weapon) || fo_tool.is_a?(RPG::Armor)
  986. invoke = fo_tool.tool_data("Tool Invoke Skill = ")
  987. if invoke > 0
  988. if $data_skills[invoke].scope.between?(1, 6)
  989. setup_target
  990. else ; @targeted_character = $game_player
  991. @range_view = 6
  992. end
  993. else
  994. # no invoke skill just set up an enemy target
  995. setup_target
  996. end
  997. end
  998. end
  999.  
  1000. # use the predifined tool
  1001. def use_predefined_tool
  1002. update_follower_movement
  1003. return if @targeted_character.nil?
  1004. if obj_size?(@targeted_character, @range_view) && @follower_attacktimer == 0
  1005. turn_toward_character(@targeted_character)
  1006. use_weapon(fo_tool.id) if actor.primary_use == 1
  1007. use_armor(fo_tool.id) if actor.primary_use == 2
  1008. use_item(fo_tool.id) if actor.primary_use == 3 || actor.primary_use == 4
  1009. use_skill(fo_tool.id) if actor.primary_use==5 || actor.primary_use==6 ||
  1010. actor.primary_use == 7 || actor.primary_use == 8
  1011. if fo_tool.tool_data("User Graphic = ", false).nil?
  1012. @targeted_character = nil
  1013. turn_toward_player
  1014. end
  1015. @follower_attacktimer = 60
  1016. end
  1017. delete_targetf if self.actor.dead?
  1018. end
  1019.  
  1020. def all_enemies_dead?
  1021. for event in $game_map.event_enemies
  1022. if event.on_battle_screen? && event.enemy_ready?
  1023. return false if $game_player.obj_size?(event,PearlKernel::PlayerRange+1)
  1024. end
  1025. end
  1026. return true
  1027. end
  1028.  
  1029. def delete_targetf
  1030. @targeted_character = nil
  1031. end
  1032.  
  1033. #------------------------
  1034. # follower movement attack
  1035. def reset_targeting_settings(target)
  1036. target.being_targeted = false if target.is_a?(Game_Event)
  1037. delete_targetf
  1038. turn_toward_player
  1039. @stuck_timer = 0
  1040. end
  1041.  
  1042. def update_follower_movement
  1043. target = @targeted_character
  1044. if @stuck_timer >= 30
  1045. reset_targeting_settings(target)
  1046. return
  1047. end
  1048.  
  1049. # if the follower is unabble to use the tool
  1050. unless usable_test_passed?(fo_tool)
  1051. if SceneManager.scene_is?(Scene_Map)
  1052. reset_targeting_settings(target)
  1053. @balloon_id = PearlKernel::FailBalloon
  1054. return
  1055. end
  1056. end
  1057.  
  1058. return if target.nil?
  1059. @stuck_timer += 1 if !obj_size?(target, @range_view) and !moving?
  1060.  
  1061. if moving? || @anime_speed > 0 || @making_spiral || @hookshoting[0] ||
  1062. @knockdown_data[0] > 0
  1063. @stuck_timer = 0
  1064. end
  1065. return if moving?
  1066. if fo_tool.tool_data("Tool Target = ", false) == "true" ||
  1067. fo_tool.tool_data("Tool Special = ", false) == "autotarget" ||
  1068. target.is_a?(Game_Player)
  1069. # using skill con target true magical
  1070. cpu_reactiontype(1, target)
  1071. return
  1072. # target not exist
  1073. else
  1074.  
  1075. if fo_tool.is_a?(RPG::Skill) || fo_tool.is_a?(RPG::Item)
  1076. fo_tool.scope.between?(1, 6) ? cpu_reactiontype(2, target) : # to enemy
  1077. cpu_reactiontype(1, target) # benefical
  1078. else
  1079. # for weapon armor without target
  1080. cpu_reactiontype(2, target)
  1081. end
  1082. end
  1083. return if !obj_size?(target, @range_view)
  1084. return if target.is_a?(Game_Player)
  1085. case rand(40)
  1086. when 4 then move_backward
  1087. when 10 then move_random
  1088. end
  1089. end
  1090.  
  1091. # cpu reaction
  1092. def cpu_reactiontype(type, target)
  1093. unless on_battle_screen?
  1094. 3.times.each {|i| move_toward_player}
  1095. return
  1096. end
  1097. move_toward_character(target) if !obj_size?(target, @range_view) if type==1
  1098. if @follower_attacktimer == 0 || !obj_size?(target, @range_view)
  1099. move_toward_character(target) if type == 2
  1100. end
  1101. end
  1102. #-------------------------------------------------
  1103.  
  1104. # buff timer
  1105. def update_buff_timing
  1106. battler.buff_turns.each do |id, value|
  1107. if battler.buff_turns[id] > 0
  1108. battler.buff_turns[id] -= 1
  1109. if battler.buff_turns[id] <= 0
  1110. battler.remove_buff(id)
  1111. pop_damage
  1112. end
  1113. end
  1114. end
  1115. end
  1116.  
  1117. #blow power effect
  1118. def update_blow_power_effect
  1119. if @blowpower[4] > 0
  1120. @blowpower[4] -= 1
  1121. if @blowpower[4] == 0
  1122. @direction_fix = @blowpower[2]
  1123. @move_speed = @blowpower[3]
  1124. end
  1125. end
  1126. if @blowpower[0] > 0 and !moving?
  1127. @move_speed = 5.5
  1128. @direction_fix = true
  1129. move_straight(@blowpower[1]); @blowpower[0] -= 1
  1130. if @blowpower[0] == 0
  1131. @blowpower[4] = 10
  1132. end
  1133. end
  1134. end
  1135.  
  1136. # Pearl timing
  1137. def update_pearlabs_timing
  1138. @just_hitted -= 1 if @just_hitted > 0
  1139. @stopped_movement -= 1 if @stopped_movement > 0
  1140. @doingcombo -= 1 if @doingcombo > 0
  1141.  
  1142. # hookshooting
  1143. if @hookshoting[3] > 0
  1144. @hookshoting[3] -= 1
  1145. if @hookshoting[3] == 0
  1146. @hookshoting = [false, false, false, 0]
  1147. @user_move_distance[3].being_grabbed = false if
  1148. @user_move_distance[3].is_a?(Game_Event)
  1149. @user_move_distance[3] = nil
  1150. end
  1151. end
  1152. update_buff_timing
  1153. update_blow_power_effect
  1154. # anime
  1155. if @anime_speed > 0
  1156. @pattern = 0
  1157. @anime_speed -= 1
  1158. end
  1159. # casting
  1160. if @user_casting[0] > 0
  1161. @user_casting[0] -= 1
  1162. load_abs_tool(@user_casting[1]) if @user_casting[0] == 0
  1163. end
  1164. update_knockdown
  1165. end
  1166.  
  1167. # Update battler collapse
  1168.  
  1169. def check_for_dead_four
  1170. return if $game_party.members.size <= 4
  1171. SceneManager.goto(Scene_Gameover) if all_fourdead?
  1172. end
  1173.  
  1174. def all_fourdead?
  1175. m = $game_party.battle_members
  1176. return true if m[0].dead? && m[1].dead? && m[2].dead? && m[3].dead?
  1177. return false
  1178. end
  1179.  
  1180. def update_battler_collapse
  1181. if @colapse_time > 0
  1182. @colapse_time -= 1
  1183. force_cancel_actions
  1184. if battler.is_a?(Game_Actor)
  1185. Sound.play_actor_collapse if @secollapse.nil?
  1186. @secollapse = true
  1187.  
  1188. if @colapse_time == 0
  1189. @secollapse = nil
  1190. for event in $game_map.event_enemies
  1191. if event.agroto_f == self
  1192. event.agroto_f = nil
  1193. end
  1194. end
  1195.  
  1196. check_for_dead_four
  1197. member = $game_party.battle_members
  1198. # swap and reset player
  1199. if self.is_a?(Game_Player)
  1200. reset_knockdown_actors
  1201. battler.deadposing=$game_map.map_id if PearlKernel::FollowerDeadPose
  1202. $game_party.swap_order(0,3) if !member[3].nil? and !member[3].dead?
  1203. $game_party.swap_order(0,2) if !member[2].nil? and !member[2].dead?
  1204. $game_party.swap_order(0,1) if !member[1].nil? and !member[1].dead?
  1205. else
  1206. if PearlKernel::FollowerDeadPose
  1207. battler.deadposing = $game_map.map_id
  1208. if !$game_player.follower_fighting? and member.size > 2
  1209. swap_dead_follower
  1210. else
  1211. $game_player.reserved_swap << battler.id if member.size > 2
  1212. end
  1213. end
  1214. end
  1215. end
  1216.  
  1217. elsif battler.is_a?(Game_Enemy)
  1218. @die_through = @through if @die_through.nil?
  1219. @through = true
  1220. apply_collapse_anime(battler.collapse_type)
  1221. @secollapse = true
  1222. battler.object ? @transparent = true : @opacity -= 2 if !@deadposee
  1223. if @colapse_time == 0
  1224. self.kill_enemy
  1225. end
  1226. end
  1227. end
  1228. end
  1229.  
  1230. def swap_dead_follower
  1231. reset_knockdown_actors
  1232. member = $game_party.battle_members
  1233. member.each_with_index.each do |actorr, i|
  1234. next unless actorr.id == self.actor.id
  1235. case member.size
  1236. when 3
  1237. break if i == 2
  1238. $game_party.swap_order(i, 2)
  1239. when 4
  1240. break if i == 3
  1241. if !member[3].dead?
  1242. $game_party.swap_order(i, 3)
  1243. break
  1244. end
  1245. if !member[2].dead?
  1246. $game_party.swap_order(i, 2)
  1247. break
  1248. end
  1249. end
  1250. end
  1251. end
  1252.  
  1253. def apply_collapse_anime(type)
  1254. # sound and animation
  1255. if battler.die_animation != nil
  1256. @animation_id = battler.die_animation if @secollapse.nil?
  1257. else
  1258. Sound.play_enemy_collapse if @secollapse.nil? and !battler.object
  1259. end
  1260. return if battler.object
  1261. if @deadposee
  1262. @knockdown_data[0] = 8
  1263. return
  1264. end
  1265. type = PearlKernel::DefaultCollapse if type.nil?
  1266. case type.to_sym
  1267. when :zoom_vertical
  1268. @zoomfx_x -= 0.03
  1269. @zoomfx_y += 0.02
  1270. when :zoom_horizontal
  1271. @zoomfx_x += 0.03
  1272. @zoomfx_y -= 0.02
  1273. when :zoom_maximize
  1274. @zoomfx_x += 0.02
  1275. @zoomfx_y += 0.02
  1276. when :zoom_minimize
  1277. @zoomfx_x -= 0.02
  1278. @zoomfx_y -= 0.02
  1279. end
  1280. end
  1281.  
  1282. # konck down engine update
  1283. def update_knockdown
  1284. if @knockdown_data[0] > 0
  1285. @knockdown_data[0] -= 1
  1286. @knockdown_data[0] == 0 ? knowdown_effect(2) : knowdown_effect(1)
  1287. if @knockdown_data[1] != nil
  1288. @pattern = @knockdown_data[2]
  1289. @direction = @knockdown_data[3]
  1290. end
  1291. end
  1292. end
  1293.  
  1294. def knowdown_effect(type)
  1295. return if self.is_a?(Projectile)
  1296. if type[0] == 1
  1297. if @knockdown_data[1] == nil
  1298. if battler.is_a?(Game_Enemy)
  1299. if self.knockdown_enable
  1300. force_cancel_actions
  1301. self_sw = PearlKernel::KnockdownSelfW
  1302. $game_self_switches[[$game_map.map_id, self.id, self_sw]] = true
  1303. @knockdown_data[1] = self_sw
  1304. self.refresh
  1305. @knockdown_data[2] = self.page.graphic.pattern
  1306. @knockdown_data[3] = self.page.graphic.direction
  1307. $game_map.screen.start_shake(7, 4, 20)
  1308. end
  1309.  
  1310. @knockdown_data[0] = 0 if @knockdown_data[1] == nil
  1311. elsif battler.is_a?(Game_Actor)
  1312. if PearlKernel.knock_actor(self.actor) != nil and
  1313. if @knockdown_data[1] == nil
  1314. force_cancel_actions
  1315. @knockdown_data[1] = @character_name
  1316. @knockdown_data[4] = @character_index
  1317. @character_name = PearlKernel.knock_actor(self.actor)[0]
  1318. @character_index = PearlKernel.knock_actor(self.actor)[1]
  1319. @knockdown_data[2] = PearlKernel.knock_actor(self.actor)[2]
  1320. @knockdown_data[3] = PearlKernel.knock_actor(self.actor)[3]
  1321. $game_map.screen.start_shake(7, 4, 20) if battler.deadposing.nil?
  1322. end
  1323. end
  1324. @knockdown_data[0] = 0 if @knockdown_data[1] == nil
  1325. end
  1326. end
  1327. elsif type == 2
  1328. if battler.is_a?(Game_Enemy)
  1329. if @deadposee and battler.dead?
  1330. @knockdown_data[1] = nil
  1331. return
  1332. end
  1333. $game_self_switches[[$game_map.map_id, self.id,
  1334. @knockdown_data[1]]] = false if @knockdown_data[1] != nil
  1335. @knockdown_data[1] = nil
  1336. else
  1337. @character_name = @knockdown_data[1]
  1338. @character_index = @knockdown_data[4]
  1339. @knockdown_data[1] = nil
  1340. end
  1341. end
  1342. end
  1343.  
  1344. #================================
  1345. # states
  1346. def primary_state_ani
  1347. return nil if battler.states[0].nil?
  1348. return battler.states[0].tool_data("State Animation = ")
  1349. end
  1350.  
  1351. # higer priority state animation displayed
  1352. def update_state_effects
  1353. return if battler.nil?
  1354. @state_poptimer[0] += 1 unless primary_state_ani.nil?
  1355. if @state_poptimer[0] == 30
  1356. @animation_id = primary_state_ani
  1357. @animation_id = 0 if @animation_id.nil?
  1358. elsif @state_poptimer[0] == 180
  1359. @state_poptimer[0] = 0
  1360. end
  1361. update_state_action_steps
  1362. end
  1363.  
  1364. # update state actions
  1365. def update_state_action_steps
  1366. for state in battler.states
  1367. if state.remove_by_walking
  1368. if !battler.state_steps[state.id].nil? &&
  1369. battler.state_steps[state.id] > 0
  1370. battler.state_steps[state.id] -= 1
  1371. end
  1372. if battler.state_steps[state.id] == 0
  1373. battler.remove_state(state.id)
  1374. pop_damage
  1375. end
  1376. end
  1377. if state.restriction == 4
  1378. @stopped_movement = 10
  1379. @pattern = 2 if @knockdown_data[0] == 0
  1380. end
  1381. state.features.each do |feature|
  1382. if feature.code == 22
  1383. @knockdown_data[0] =10 if state.restriction == 4 && feature.data_id==1
  1384. next unless feature.data_id.between?(7, 9)
  1385. apply_regen_state(state, feature.data_id)
  1386. end
  1387. end
  1388. end
  1389. end
  1390.  
  1391. # apply regen for hp, mp and tp
  1392. def apply_regen_state(state, type)
  1393. random = state.tool_data("State Effect Rand Rate = ")
  1394. random = 120 if random.nil?
  1395. if rand(random) == 1
  1396. battler.regenerate_hp if type == 7
  1397. battler.regenerate_mp if type == 8
  1398. battler.regenerate_tp if type == 9
  1399. if type == 7 and battler.result.hp_damage == 0
  1400. @colapse_time = 80
  1401. battler.add_state(1)
  1402. return
  1403. end
  1404. type == 9 ? pop_damage("Tp Up!") : pop_damage
  1405. end
  1406. end
  1407.  
  1408. alias falcaopearl_update_anime_pattern update_anime_pattern
  1409. def update_anime_pattern
  1410. return if @anime_speed > 0 || @knockdown_data[0] > 0
  1411. falcaopearl_update_anime_pattern
  1412. end
  1413.  
  1414. #=============================================================================
  1415. # Reset Pearl ABS System
  1416.  
  1417. # reset from game player call
  1418. def reset_knockdown_actors
  1419. # reset knock down
  1420. if @knockdown_data[1] != nil
  1421. @knockdown_data[0] = 0
  1422. knowdown_effect(2)
  1423. end
  1424. # force clear knock down
  1425. $game_player.followers.each do |follower|
  1426. if follower.knockdown_data[1] != nil
  1427. follower.knockdown_data[0] = 0
  1428. follower.knowdown_effect(2)
  1429. end
  1430. end
  1431. end
  1432.  
  1433. # reset knockdown enemies game player call
  1434. def reset_knockdown_enemies
  1435. $game_map.events.values.each do |event|
  1436. if event.knockdown_data[1] != nil
  1437. event.knockdown_data[0] = 0
  1438. event.knowdown_effect(2)
  1439. end
  1440. if event.deadposee and event.killed
  1441. $game_self_switches[[$game_map.map_id, event.id,
  1442. PearlKernel::KnockdownSelfW]] = false
  1443. end
  1444. end
  1445. end
  1446.  
  1447. # glabal reseting
  1448. def pearl_abs_global_reset
  1449. force_cancel_actions
  1450. battler.remove_state(9) if @battler_guarding[0]
  1451. @battler_guarding = [false, nil]
  1452. @making_spiral = false
  1453. set_hook_variables
  1454. @using_custom_g = false
  1455. $game_player.followers.each do |f|
  1456. f.targeted_character = nil if !f.targeted_character.nil?
  1457. f.stuck_timer = 0 if f.stuck_timer > 0
  1458. f.follower_attacktimer = 0 if f.follower_attacktimer > 0
  1459. f.force_cancel_actions unless f.visible?
  1460. f.battler.remove_state(9) if f.battler_guarding[0]
  1461. f.battler_guarding = [false, nil]
  1462. f.set_hook_variables
  1463. f.making_spiral = false
  1464. end
  1465. reset_knockdown_actors
  1466. reset_knockdown_enemies
  1467. $game_player.projectiles.clear
  1468. $game_player.damage_pop.clear
  1469. $game_player.anime_action.clear
  1470. $game_player.enemy_drops.clear
  1471. @send_dispose_signal = true
  1472. end
  1473. end
  1474.  
  1475. #===============================================================================
  1476. # Evets as enemies registration
  1477.  
  1478. class Game_Event < Game_Character
  1479. attr_accessor :enemy, :move_type, :page, :deadposee
  1480. attr_accessor :being_targeted, :agroto_f, :draw_drop, :dropped_items
  1481. attr_accessor :start_delay, :epassive, :erased, :killed, :boom_grabdata
  1482. attr_reader :token_weapon, :token_armor,:token_item,:token_skill,:boom_start
  1483. attr_reader :hook_pull, :hook_grab, :event, :knockdown_enable, :boom_grab
  1484. attr_reader :respawn_anim
  1485. alias falcaopearlabs_iniev initialize
  1486. def initialize(map_id, event)
  1487. @inrangeev = nil
  1488. @being_targeted = false
  1489. @agroto_f = nil
  1490. @draw_drop = false
  1491. @dropped_items = []
  1492. @epassive = false
  1493. @touch_damage = 0
  1494. @start_delay = 0
  1495. @touch_atkdelay = 0
  1496. @killed = false
  1497. @knockdown_enable = false
  1498. @deadposee = false
  1499. @respawn_anim = 0
  1500. create_token_arrays
  1501. falcaopearlabs_iniev(map_id, event)
  1502. register_enemy(event)
  1503. end
  1504.  
  1505. def create_token_arrays
  1506. @token_weapon = []
  1507. @token_armor = []
  1508. @token_item = []
  1509. @token_skill = []
  1510. end
  1511.  
  1512. alias falcaopearl_setup_page_settings setup_page_settings
  1513. def setup_page_settings
  1514. create_token_arrays
  1515. falcaopearl_setup_page_settings
  1516. wtag = string_data("<start_with_weapon: ")
  1517. @token_weapon = wtag.split(",").map { |s| s.to_i } if wtag != nil
  1518. atag = string_data("<start_with_armor: ")
  1519. @token_armor = atag.split(",").map { |s| s.to_i } if atag != nil
  1520. itag = string_data("<start_with_item: ")
  1521. @token_item = itag.split(",").map { |s| s.to_i } if itag != nil
  1522. stag = string_data("<start_with_skill: ")
  1523. @token_skill = stag.split(",").map { |s| s.to_i } if stag != nil
  1524. @hook_pull = string_data("<hook_pull: ") == "true"
  1525. @hook_grab = string_data("<hook_grab: ") == "true"
  1526. @boom_grab = string_data("<boom_grab: ") == "true"
  1527. @boom_start = string_data("<boomed_start: ") == "true"
  1528. @direction_fix = false if @hook_grab
  1529. if has_token? || @hook_pull || @hook_grab || @boom_grab || @boom_start
  1530. $game_map.events_withtags.push(self) unless
  1531. $game_map.events_withtags.include?(self)
  1532. end
  1533. end
  1534.  
  1535. def has_token?
  1536. !@token_weapon.empty? || !@token_armor.empty? || !@token_item.empty? ||
  1537. !@token_skill.empty?
  1538. end
  1539.  
  1540. def register_enemy(event)
  1541.  
  1542. if !$game_system.remain_killed[$game_map.map_id].nil? and
  1543. $game_system.remain_killed[$game_map.map_id].include?(self.id)
  1544. return
  1545. end
  1546.  
  1547. @enemy = Game_Enemy.new(0, $1.to_i) if event.name =~ /<enemy: (.*)>/i
  1548. if @enemy != nil
  1549. passive = @enemy.enemy.tool_data("Enemy Passive = ", false)
  1550. @epassive = true if passive == "true"
  1551. touch = @enemy.enemy.tool_data("Enemy Touch Damage Range = ")
  1552. @sensor = @enemy.esensor
  1553. @touch_damage = touch if touch != nil
  1554. $game_map.event_enemies.push(self) # new separate enemy list
  1555. $game_map.enemies.push(@enemy) # just enemies used in the cooldown
  1556. @event.pages.each do |page|
  1557. if page.condition.self_switch_valid and
  1558. page.condition.self_switch_ch == PearlKernel::KnockdownSelfW
  1559. @knockdown_enable = true
  1560. break
  1561. end
  1562. end
  1563. pose = @enemy.enemy.tool_data("Enemy Dead Pose = ", false) == "true"
  1564. @deadposee = true if pose and @knockdown_enable
  1565. end
  1566. end
  1567.  
  1568. def update_state_effects
  1569. @killed ? return : super
  1570. end
  1571.  
  1572. def collapsing?
  1573. return true if @killed || @colapse_time > 0
  1574. return false
  1575. end
  1576.  
  1577. def enemy_ready?
  1578. return false if @enemy.nil? || @page.nil? || collapsing? || @enemy.object
  1579. return true
  1580. end
  1581.  
  1582. def battler
  1583. return @enemy
  1584. end
  1585.  
  1586. def apply_respawn
  1587. return if @colapse_time > 0
  1588. @draw_drop = false
  1589. @dropped_items.clear
  1590. @through = @die_through
  1591. @through = false if @through.nil?
  1592. @die_through = nil
  1593. @secollapse = nil
  1594. @colapse_time = 0
  1595. @erased = false ; @opacity = 255
  1596. @zoomfx_x = 1.0 ; @zoomfx_y = 1.0
  1597. @killed = false
  1598. @priority_type = 1 if @deadposee
  1599. resetdeadpose
  1600. refresh
  1601. end
  1602.  
  1603. def resetdeadpose
  1604. if @deadposee
  1605. $game_self_switches[[$game_map.map_id, @id,
  1606. PearlKernel::KnockdownSelfW]] = false
  1607. end
  1608. end
  1609.  
  1610. def kill_enemy
  1611. @secollapse = nil
  1612. @killed = true
  1613. @priority_type = 0 if @deadposee
  1614. gain_exp
  1615. gain_gold
  1616. etext = 'Exp ' + @enemy.exp.to_s if @enemy.exp > 0
  1617. gtext = 'Gold ' + @enemy.gold.to_s if @enemy.gold > 0
  1618. $game_player.pop_damage("#{etext} #{gtext}") if etext || gtext
  1619. make_drop_items
  1620. run_assigned_commands
  1621. end
  1622.  
  1623. def run_assigned_commands
  1624. transform = @enemy.enemy.tool_data("Enemy Die Transform = ")
  1625. switch = @enemy.enemy.tool_data("Enemy Die Switch = ")
  1626. $game_switches[switch] = true if switch != nil
  1627. variable = @enemy.enemy.tool_data("Enemy Die Variable = ")
  1628. $game_variables[variable] += 1 if variable != nil
  1629. self_sw = @enemy.enemy.tool_data("Enemy Die Self Switch = ", false)
  1630. #$game_map.event_enemies.delete(self) if @enemy.object
  1631. #$game_map.enemies.delete(@enemy) if @enemy.object
  1632. if self_sw.is_a?(String)
  1633. $game_self_switches[[$game_map.map_id, self.id, self_sw]] = true
  1634. apply_respawn
  1635. $game_map.event_enemies.delete(self)
  1636. $game_map.enemies.delete(@enemy)
  1637. unless $game_system.remain_killed.has_key?($game_map.map_id)
  1638. $game_system.remain_killed[$game_map.map_id] = []
  1639. end
  1640. $game_system.remain_killed[$game_map.map_id].push(self.id) unless
  1641. $game_system.remain_killed[$game_map.map_id].include?(self.id)
  1642. @enemy = nil
  1643. else
  1644. erase unless @deadposee
  1645. respawn = @enemy.enemy.tool_data("Enemy Respawn Seconds = ")
  1646. animation = @enemy.enemy.tool_data("Enemy Respawn Animation = ")
  1647. @respawn_count = respawn * 60 unless respawn.nil?
  1648.  
  1649. @respawn_anim = animation unless animation.nil?
  1650.  
  1651. end
  1652. if transform != nil
  1653. @enemy = Game_Enemy.new(0, transform)
  1654. apply_respawn
  1655. end
  1656. end
  1657.  
  1658. def make_drop_items
  1659. @dropped_items = @enemy.make_drop_items
  1660. unless @dropped_items.empty?
  1661. $game_player.enemy_drops.push(self)
  1662. $game_map.events_withtags.push(self) unless
  1663. $game_map.events_withtags.include?(self)
  1664. end
  1665. end
  1666.  
  1667. def gain_exp
  1668. return if @enemy.exp == 0
  1669. $game_party.all_members.each do |actor|
  1670. actor.gain_exp(@enemy.exp)
  1671. end
  1672. end
  1673.  
  1674. def gain_gold
  1675. return if @enemy.gold == 0
  1676. $game_party.gain_gold(@enemy.gold)
  1677. end
  1678.  
  1679. alias falcaopearlabs_updatev update
  1680. def update
  1681. @start_delay -= 1 if @start_delay > 0
  1682. @touch_atkdelay -= 1 if @touch_atkdelay > 0
  1683. update_enemy_sensor unless @enemy.nil?
  1684. update_enemy_touch_damage unless @enemy.nil?
  1685. falcaopearlabs_updatev
  1686. end
  1687.  
  1688. def update_enemy_touch_damage
  1689. return unless @touch_damage > 0
  1690. return unless @character_name != ""
  1691. return if @epassive || @killed
  1692. return if @touch_atkdelay > 0
  1693. unless @enemy.object
  1694. @agroto_f.nil? ? target = $game_player : target = @agroto_f
  1695. else
  1696. target = $game_player
  1697. $game_player.followers.each do |follower|
  1698. next unless follower.visible?
  1699. if obj_size?(follower, @touch_damage) and !follower.battler.dead?
  1700. execute_touch_damage(follower)
  1701. end
  1702. end
  1703. end
  1704. execute_touch_damage(target) if obj_size?(target, @touch_damage)
  1705. end
  1706.  
  1707. def execute_touch_damage(target)
  1708. target.battler.attack_apply(@enemy)
  1709. target.pop_damage
  1710. @touch_atkdelay = 50
  1711. target.colapse_time = 60 if target.battler.dead?
  1712. return if target.battler.result.hp_damage == 0
  1713. target.jump(0, 0)
  1714. end
  1715.  
  1716. # enemy sensor
  1717. def update_enemy_sensor
  1718. return if @hookshoting[0]
  1719. return if @epassive
  1720. if @sensor != nil
  1721. @agroto_f.nil? ? target = $game_player : target = @agroto_f
  1722. if obj_size?(target, @sensor)
  1723. data = [$game_map.map_id, @id, PearlKernel::Enemy_Sensor]
  1724. if @inrangeev.nil? and !$game_self_switches[[data[0], data[1],
  1725. data[2]]]
  1726. $game_self_switches[[data[0], data[1], data[2]]] = true
  1727. @inrangeev = true
  1728. end
  1729. elsif @inrangeev != nil
  1730. data = [$game_map.map_id, @id, PearlKernel::Enemy_Sensor]
  1731. if $game_self_switches[[data[0], data[1], data[2]]]
  1732. $game_self_switches[[data[0], data[1], data[2]]] = false
  1733. @inrangeev = nil
  1734. end
  1735. end
  1736. end
  1737. end
  1738.  
  1739. # on battle pixel, take a lot of time procesing, but it is very exact
  1740. def on_battle_pixel?(out=0)
  1741. w = Graphics.width + out; h = Graphics.height + out
  1742. return true if screen_x.between?(0 - out,w) and screen_y.between?(0 - out,h)
  1743. return false
  1744. end
  1745.  
  1746. def cmt_data(comment)
  1747. return 0 if @list.nil? or @list.size <= 0
  1748. for item in @list
  1749. if item.code == 108 or item.code == 408
  1750. return $1.to_i if item.parameters[0] =~ /#{comment}(.*)>/i
  1751. end
  1752. end
  1753. return 0
  1754. end
  1755.  
  1756. def string_data(comment)
  1757. return nil if @list.nil? or @list.size <= 0
  1758. for item in @list
  1759. if item.code == 108 or item.code == 408
  1760. return $1.to_s if item.parameters[0] =~ /#{comment}(.*)>/i
  1761. end
  1762. end
  1763. return nil
  1764. end
  1765.  
  1766. # stop event movement
  1767. alias falcaopearl_update_self_movement update_self_movement
  1768. def update_self_movement
  1769. return if !@boom_grabdata.nil?
  1770. return if force_stopped? || @colapse_time > 0 || @blowpower[0] > 0
  1771. falcaopearl_update_self_movement
  1772. end
  1773. end
  1774.  
  1775.  
  1776. class Game_System
  1777. attr_accessor :remain_killed
  1778. alias falcao_fantastic_store_ini initialize
  1779. def initialize
  1780. falcao_fantastic_store_ini
  1781. @remain_killed = {}
  1782. end
  1783. end
  1784.  
  1785. #===============================================================================
  1786.  
  1787. # mist
  1788. class Game_Map
  1789. attr_reader :map
  1790. attr_accessor :event_enemies, :enemies, :events_withtags
  1791. alias falcaopearl_enemycontrol_ini initialize
  1792. def initialize
  1793. @event_enemies = []
  1794. @enemies = []
  1795. @events_withtags = []
  1796. falcaopearl_enemycontrol_ini
  1797. end
  1798.  
  1799. alias falcaopearl_enemycontrol_setup setup
  1800. def setup(map_id)
  1801. @event_enemies.clear
  1802. @enemies.clear
  1803. @events_withtags.clear
  1804. falcaopearl_enemycontrol_setup(map_id)
  1805. if $game_temp.loadingg != nil
  1806. @event_enemies.each do |event|
  1807. event.resetdeadpose
  1808. end
  1809. $game_temp.loadingg = nil
  1810. end
  1811. end
  1812.  
  1813. alias falcaopearl_damage_floor damage_floor?
  1814. def damage_floor?(x, y)
  1815. return if $game_player.hookshoting[1]
  1816. falcaopearl_damage_floor(x, y)
  1817. end
  1818. end
  1819.  
  1820. class Game_Temp
  1821. attr_accessor :pop_windowdata, :loadingg
  1822. def pop_w(time, name, text)
  1823. return unless @pop_windowdata.nil?
  1824. @pop_windowdata = [time, text, name]
  1825. end
  1826. end
  1827.  
  1828. class Game_Party < Game_Unit
  1829. alias falcaopearl_swap_order swap_order
  1830. def swap_order(index1, index2)
  1831. unless SceneManager.scene_is?(Scene_Map)
  1832. if $game_player.in_combat_mode?
  1833. $game_temp.pop_w(180, 'Pearl ABS',
  1834. 'You cannot switch player while in combat!')
  1835. return
  1836. elsif $game_player.any_collapsing?
  1837. $game_temp.pop_w(180, 'Pearl ABS',
  1838. 'You cannot switch player while collapsing!')
  1839. return
  1840. elsif $game_party.battle_members[index2].deadposing != nil
  1841. $game_temp.pop_w(180, 'Pearl ABS',
  1842. 'You cannot move a dead ally!')
  1843. return
  1844. end
  1845. end
  1846. falcaopearl_swap_order(index1, index2)
  1847. end
  1848. end
  1849.  
  1850. class << DataManager
  1851. alias falcaopearl_extract extract_save_contents
  1852. def DataManager.extract_save_contents(contents)
  1853. falcaopearl_extract(contents)
  1854. $game_temp.loadingg = true
  1855. end
  1856. end
Add Comment
Please, Sign In to add comment