Guest User

Script3 Falcao

a guest
Jan 22nd, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 34.27 KB | None | 0 0
  1. #===============================================================================
  2. # * Falcao Pearl ABS script shelf # 2
  3. #
  4. # This script handles all the Projectiles in pearl ABS, this class is the
  5. # responsable of manage each tool settings, do not touch anything or your
  6. # pc will explode
  7. #===============================================================================
  8.  
  9. class Projectile < Game_Character
  10. attr_accessor :draw_it, :destroy_it, :user, :tool_retracting, :customsteps
  11. attr_accessor :tool_distance, :original_distance, :agroto_f, :pick_able
  12. attr_accessor :tool_destroy_delay
  13. def initialize(user, item, custom=nil)
  14. super()
  15. PearlKernel.load_item(item)
  16. @tool_special = PearlKernel.tool_special
  17. @draw_it = false
  18. @destroy_it = false
  19. @user = user
  20. @item = item
  21. @step_anime = true
  22. @through = true if PearlKernel.tool_through == "true"
  23. @through = true if PearlKernel.tool_through.nil?
  24. moveto(user.x, user.y)
  25. set_direction(user.direction)
  26. @customsteps = custom if custom.is_a?(Fixnum)
  27. @original_item = @item
  28. @target_effect = [false, target=nil]
  29. set_targeting
  30. return if PearlKernel.user_graphic.nil?
  31. load_item_data
  32. jump(0, 0) if @user.passable?(@user.x, @user.y, @user.direction) and
  33. PearlKernel.tool_shortjump == "true"
  34. if @tool_special == "triple"
  35. @triple = custom
  36. move_forward if @tool_distance > 2
  37. elsif @tool_special == "quintuple"
  38. @quintuple = custom
  39. move_forward if @tool_distance > 2
  40. elsif @tool_special == "octuple"
  41. @octuple = custom
  42. if @octuple == :seis || @octuple == :siete || @octuple == :ocho
  43. @direction = 8 if @user.direction == 2
  44. @direction = 6 if @user.direction == 4
  45. @direction = 4 if @user.direction == 6
  46. @direction = 2 if @user.direction == 8
  47. end
  48. elsif @tool_special.split(" ").include?('common_event')
  49. @commonevent_id = @tool_special.sub("common_event ","").to_i
  50. for i in $data_common_events[@commonevent_id].list
  51. if i.code == 205
  52. force_move_route(i.parameters[1])
  53. end
  54. end
  55. @tool_distance = 0
  56. end
  57. @move_speed == 6 ? @mini_opacity = 7 : @mini_opacity = 9
  58. @opacity = 0
  59. check_combo_effect
  60. apply_item_transform if @item.is_a?(RPG::Weapon) || @item.is_a?(RPG::Armor)
  61. end
  62.  
  63. # combo
  64. def check_combo_effect
  65. c = PearlKernel.tool_combo
  66. return if c == 'nil' || c.nil?
  67. c = c.split(", ")
  68. return unless rand(101) <= c[2].to_i
  69. case c[0]
  70. when 'weapon' then @user.combodata << [:weapon, c[1].to_i, c[3], 20]
  71. when 'armor' then @user.combodata << [:armor, c[1].to_i, c[3], 20]
  72. when 'item' then @user.combodata << [:item, c[1].to_i, c[3], 20]
  73. when 'skill' then @user.combodata << [:skill, c[1].to_i, c[3], 20]
  74. end
  75. @has_combo = true
  76. end
  77.  
  78. # Get projectile battler, it take the properies of the user
  79. def battler
  80. return nil if @commonevent_id.nil?
  81. return @user.battler
  82. end
  83.  
  84. # make target
  85. def set_targeting
  86. return if @tool_special == "hook" || @tool_special == "boomerang" ||
  87. @tool_special == "shield" || @tool_special == "spiral" ||
  88. @tool_special == "triple" || @tool_special == "quintuple" ||
  89. @tool_special == "autotarget" || @tool_special == "random" ||
  90. @commonevent_id != nil
  91. if @user.targeting[0]
  92. @target_effect = [@user.targeting[0], @user.targeting[2]]
  93. @user.turn_toward_character(@target_effect[1])
  94. end
  95. if PearlKernel.tool_target == "true" and @user.battler.is_a?(Game_Enemy)
  96. target = $game_player
  97. target = @user.agroto_f if @user.agroto_f != nil
  98. @user.targeting = [true, nil, target]
  99. @target_effect = [@user.targeting[0], @user.targeting[2]]
  100. @user.turn_toward_character(target)
  101. end
  102. end
  103.  
  104. # Load item variables
  105. def load_item_data
  106. @character_name = PearlKernel.tool_graphic
  107. if @character_name == "nil"
  108. @character_name = @user.character_name
  109. @transparent = true
  110. end
  111. @character_index = PearlKernel.tool_index
  112. @tool_size = PearlKernel.tool_size
  113. @tool_distance = PearlKernel.tool_distance
  114. @tool_effect_delay = PearlKernel.tool_effectdelay
  115. @tool_destroy_delay = PearlKernel.tool_destroydelay
  116. @move_speed = PearlKernel.tool_speed
  117. @tool_blow_power = PearlKernel.tool_blowpower
  118. @tool_piercing = PearlKernel.tool_piercing
  119. @tool_piercing = PearlKernel.tool_piercing == "true"
  120. @tool_end_anime = PearlKernel.tool_animation
  121. if @tool_end_anime.split(" ").include?('delay')
  122. @tool_end_anime = @tool_end_anime.sub("delay ","").to_i
  123. end
  124. @tool_animerepeat = PearlKernel.tool_anirepeat == "true"
  125. @tool_invoke = PearlKernel.tool_invoke
  126. @tool_guardrate = PearlKernel.tool_guardrate
  127. @tool_knockdownrate = PearlKernel.tool_knockdown
  128. @tool_selfdamage = PearlKernel.tool_selfdamage == "true"
  129. @tool_hitshake = PearlKernel.tool_hitshake == "true"
  130. sound = PearlKernel.tool_soundse
  131. RPG::SE.new(sound, 80).play rescue nil # SOUND
  132. @original_distance = @tool_distance
  133. @mnganime = 0
  134. if @customsteps != nil
  135. @pattern = 0
  136. @tool_distance = @customsteps
  137. @pattern = 1 if @customsteps + 1 == @original_distance
  138. @transparent = true if @customsteps == 0
  139. @user.battler_chain.push(self)
  140. end
  141. @tool_retracting = false
  142. if @tool_special == "area" and @target_effect[0]
  143. @user.turn_toward_character(@target_effect[1])
  144. moveto(@target_effect[1].x, @target_effect[1].y)
  145. end
  146. @originaldestory_delay = @tool_destroy_delay
  147. @priority_type = PearlKernel.tool_priority
  148. if @tool_special == "spiral"
  149. @spintimer = 0
  150. @dir_was = @user.direction
  151. moveto(@user.x + @user.adjustcxy[0], @user.y + @user.adjustcxy[1]) if
  152. @spintimes = @tool_distance
  153. @tool_distance = 0
  154. @user.making_spiral = true
  155. end
  156.  
  157. PearlKernel.check_iconset(@item, "Projectile Iconset = ", self)
  158.  
  159. @character_name = "" if @pro_iconset != nil
  160.  
  161. @pick_able = @item.note.include?('<pick up>')
  162. @ignore_followers = @item.note.include?('<ignore_followers>')
  163. if @tool_special != "shield" and [email protected]?('<ignore_voices>')
  164. voices = PearlKernel.voices(@user.battler)
  165. RPG::SE.new(voices[rand(voices.size)], 80).play unless voices.nil?
  166. end
  167. apply_item_transform if @item.is_a?(RPG::Weapon) || @item.is_a?(RPG::Armor)
  168. end
  169.  
  170. # After loading tool variables check if the tool can be transformed (w/a)
  171. def apply_item_transform
  172. if @tool_invoke > 0 and @tool_invoke != 1 and @tool_invoke != 2
  173. @item = $data_skills[@tool_invoke]
  174. end
  175. end
  176.  
  177. def magical_item?
  178. return true if @item.is_a?(RPG::Skill) || @item.is_a?(RPG::Item)
  179. return false
  180. end
  181.  
  182. # Frame update
  183. def update
  184. super
  185. if magical_item?
  186. case @item.scope
  187. when 0 # scope 0 apply the effect to the user
  188. apply_self_effect(@user, true)
  189. return
  190. when 7 # heal one ally
  191. apply_effectto_selection
  192. return
  193. when 8 # heall all
  194. apply_effectto_all_allies
  195. return
  196. when 9 # revive one ally
  197. apply_effectto_selection
  198. return
  199. when 10 # revive all
  200. apply_effectto_all_allies
  201. return
  202. when 11 # to the user
  203. apply_self_effect(@user, true)
  204. return
  205. end
  206. end
  207. @precombi = @user.doingcombo > 0 if @precombi.nil?
  208. update_tool_token
  209. # continue when the scopes has not benefical effects
  210. if @target_effect[0]
  211. follow_char(@target_effect[1]) if !moving?
  212. @tool_distance = 0
  213. end
  214. @tool_distance = 0 if @tool_special == "area"
  215. update_timer
  216.  
  217. #---------------------------------------------------------------------------
  218. # Tool special shield engine
  219.  
  220. if @item.is_a?(RPG::Armor) and @tool_special == "shield"
  221. if [email protected]_guarding[0]
  222. if @tool_invoke > 0
  223. @user.battler.melee_attack_apply(@user.battler,@tool_invoke)
  224. else
  225. @user.battler.item_apply(@user.battler, $data_skills[2])
  226. end
  227. @user.battler_guarding[0] = true
  228. @user.battler_guarding[1] = @tool_guardrate
  229. # shield directions
  230. elsif @user.battler_guarding[0]
  231. if @user.battler.is_a?(Game_Actor)
  232. if @user.is_a?(Game_Player)
  233. if PearlKey.press?(Key::Armor[0]) and
  234. @tool_destroy_delay <= @originaldestory_delay - 16
  235. @tool_destroy_delay = 10
  236. @user.anime_speed = 10
  237. end
  238. @user.direction = 2 if Input.dir4 == 2
  239. @user.direction = 4 if Input.dir4 == 4
  240. @user.direction = 6 if Input.dir4 == 6
  241. @user.direction = 8 if Input.dir4 == 8
  242. end
  243. else
  244. if @user.is_a?(Game_Event) and @user.agroto_f != nil
  245. @user.turn_toward_character(@user.agroto_f)
  246. else
  247. @user.turn_toward_character($game_player)
  248. end
  249. end
  250. end
  251. if @tool_destroy_delay == 0
  252. @user.battler.remove_state(9)
  253. @user.battler_guarding = [false, nil]
  254. end
  255. return
  256. end
  257.  
  258. # if not shield given continue
  259. update_hookshotdef if @customsteps != nil # update hookshot
  260. update_boomerand if @tool_special == "boomerang" # update boomerang
  261. update_spiral if @tool_special == "spiral" # update spiral
  262. return if @transparent and @customsteps != nil # return is tranparent
  263. update_damage # update damage
  264. end
  265.  
  266. #=============================================================================
  267. # hookshot mode
  268. def update_hookshotdef
  269. @tool_destroy_delay = 1000 ; @tool_size = 1
  270. @move_speed = 6 if @move_speed != 6
  271. @tool_piercing = true if !@tool_piercing
  272. for event in $game_map.events_withtags
  273. if obj_size?(event, @tool_size)
  274. if event.hook_pull && [email protected][1]
  275. break if @transparent
  276. break if event.x == @user.x and event.y == @user.y
  277. @user.hookshoting[1] = true
  278. @tool_distance = 0
  279. @user.user_move_distance[0] = @customsteps
  280. @user.user_move_distance[1] = @user.move_speed
  281. @user.user_move_distance[2] = @user.through
  282. @user.user_move_distance[3] = [@x, @y]
  283. @user.move_speed = @move_speed
  284. @user.through = true
  285. @user.battler_chain.each {|c| c.tool_distance = 0
  286. if c.customsteps == c.original_distance - 1 # this is the last chain
  287. if c.in_frontof?(self)
  288. self.pattern = c.pattern # pattern change for convenience
  289. c.pattern = 0
  290. end
  291. end
  292. }
  293.  
  294. elsif event.hook_grab and [email protected][2]
  295. break if event.being_grabbed
  296. break if @user.in_frontof?(event)
  297. event.being_grabbed = true
  298. @user.hookshoting[2] = true
  299. @user.battler_chain.each {|i|
  300. i.pattern = 1 if i.customsteps == @customsteps - 2
  301. next if i.customsteps < @customsteps - 1
  302. i.transparent = true} # make trnparent when grabing
  303. event.user_move_distance[0] = @customsteps
  304. event.user_move_distance[1] = event.move_speed
  305. event.user_move_distance[2] = event.through
  306. @user.user_move_distance[3] = event
  307. event.move_speed = @move_speed - 0.3
  308. event.through = true
  309. event.turn_toward_character(@user)
  310. end
  311. end
  312. end
  313.  
  314. # if the user being pulled
  315. if @user.hookshoting[1]
  316. @user.battler_chain.each do |pr|
  317. if pr.x == @user.x and pr.y == @user.y
  318. pr.destroy_it = true
  319. if @user.user_move_distance[3][0] == @user.x and
  320. @user.user_move_distance[3][1] == @user.y
  321. @user.battler_chain.clear
  322. @user.move_speed = @user.user_move_distance[1]
  323. @user.through = @user.user_move_distance[2]
  324. @user.hookshoting[3] = 30
  325. @user.hookshoting[1] = false
  326. if @user.is_a?(Game_Player) and [email protected]_fighting?
  327. @user.followers.gather
  328. end
  329. end
  330. end
  331. end
  332. return
  333. # if the user is grabbing
  334. elsif @user.hookshoting[2]
  335. event = @user.user_move_distance[3]
  336. if @user.in_frontof?(event)
  337. event.move_speed = event.user_move_distance[1]
  338. event.through = event.user_move_distance[2]
  339. @user.hookshoting[2] = false
  340. event.user_move_distance[0] = 0
  341. @user.hookshoting[3] = 70
  342. end
  343. end
  344.  
  345. # retracting engine hookshot
  346. if @customsteps + 1 == @original_distance && @tool_distance == 0 && !moving?
  347. @user.battler_chain.each do |projectile|
  348. next if projectile.tool_retracting
  349. projectile.tool_retracting = true
  350. projectile.direction_fix = true
  351. end
  352. end
  353.  
  354. # retraction
  355. @user.battler_chain.each do |pr|
  356. if pr.tool_retracting
  357. pr.destroy_it = true if @user.facing_corners?
  358. pr.move_toward_character(@user) if !pr.moving?
  359. if pr.x == @user.x and pr.y == @user.y
  360. pr.destroy_it = true
  361. if pr.customsteps == pr.original_distance - 1
  362. @user.battler_chain.clear
  363. @user.hookshoting[3] = 10
  364. end
  365. end
  366. end
  367. end
  368. end
  369.  
  370. # Special Boomerang
  371. def update_boomerand
  372. $game_map.events_withtags.each do |event|
  373. if event.boom_grab || !event.dropped_items.empty?
  374. if event.boom_grabdata.nil? and obj_size?(event, @tool_size)
  375. event.boom_grabdata = [event.move_speed, event.through]
  376. event.move_speed = 6
  377. event.through = true
  378. end
  379. end
  380.  
  381. # event being grabbed by boomerang
  382. if !event.boom_grabdata.nil?
  383. event.x, event.y = @x, @y
  384. if event.obj_size?(@user, 2)
  385. reset_boomed(event)
  386. unless event.jumping?
  387. event.jumpto_tile(@user.x, @user.y)
  388. event.direction = event.page.graphic.direction rescue 2
  389. event.start if event.boom_start && !event.killed
  390. end
  391. end
  392. reset_boomed(event) if @tool_destroy_delay == 1 and obj_size?(event, 1)
  393. end
  394. end
  395.  
  396. # prepare the tool to be destoryed when colliding with user
  397. if @tool_destroy_delay <= @originaldestory_delay - 50
  398. move_toward_character(@user) if !moving?
  399. if @x == @user.x and @y == @user.y
  400. @user.anime_speed = 0
  401. @destroy_it = true
  402. end
  403. end
  404. end
  405.  
  406. def reset_boomed(event)
  407. event.move_speed = event.boom_grabdata[0]
  408. event.through = event.boom_grabdata[1]
  409. event.boom_grabdata = nil
  410. end
  411.  
  412. # Special Spiral
  413. def update_spiral
  414. @spintimer += 1
  415. case @spintimer
  416. when 6 then make_rounds(1)
  417. when 12 then make_rounds(2)
  418. when 18 then make_rounds(3)
  419. when 24 then make_rounds(4)
  420. if @spintimes > 1
  421. @spintimer = 0
  422. @spintimes -= 1
  423. end
  424. when 40
  425. @destroy_it = true
  426. @user.anime_speed = 0
  427. end
  428. end
  429.  
  430. # move the tool and the user to fforn direction
  431. def movetofront(dir, conditional)
  432. @user.direction = dir if @user.direction == conditional
  433. moveto(@user.x + @user.adjustcxy[0], @user.y + @user.adjustcxy[1]) if
  434. @direction = @user.direction
  435. end
  436.  
  437. # make round depending of the user direction
  438. def make_rounds(type)
  439. case type
  440. when 1
  441. movetofront(4, 2) if @dir_was == 2 ; movetofront(8, 4) if @dir_was == 4
  442. movetofront(2, 6) if @dir_was == 6 ; movetofront(6, 8) if @dir_was == 8
  443. when 2
  444. movetofront(8, 4) if @dir_was == 2 ; movetofront(6, 8) if @dir_was == 4
  445. movetofront(4, 2) if @dir_was == 6 ; movetofront(2, 6) if @dir_was == 8
  446. when 3
  447. movetofront(6, 8) if @dir_was == 2 ; movetofront(2, 6) if @dir_was == 4
  448. movetofront(8, 4) if @dir_was == 6 ; movetofront(4, 2) if @dir_was == 8
  449. when 4
  450. movetofront(2, 6) if @dir_was == 2 ; movetofront(4, 2) if @dir_was == 4
  451. movetofront(6, 8) if @dir_was == 6 ; movetofront(8, 4) if @dir_was == 8
  452. end
  453. end
  454.  
  455. #============================================================================
  456. # Apply benefical effects to users and allies
  457.  
  458. # apply effect to a single selection
  459. def apply_effectto_selection
  460.  
  461. # if the battler is a game actor the effect going to a target
  462. if @user.battler.is_a?(Game_Actor)
  463. apply_self_effect(@target_effect[1], true)
  464. else
  465.  
  466. # Enemies choose a random target ally
  467. all = []
  468. for event in $game_map.event_enemies
  469. if event.on_battle_screen?
  470. next if event.battler.object
  471. if @item.scope == 9 and event.killed
  472. all.push(event)
  473. apply_self_effect(event, true)
  474. event.apply_respawn
  475. return
  476. end
  477. all.push(event)
  478. end
  479. end
  480.  
  481. # if scope for the user
  482. if @item.scope == 9
  483. apply_self_effect(@user, true)
  484. return
  485. end
  486. all.push(@user)
  487. target = all[rand(all.size)]
  488. apply_self_effect(target, true) if !target.nil?
  489. apply_self_effect(@user, true) if target.nil?
  490. end
  491. end
  492.  
  493. # effect to all allies
  494. def apply_effectto_all_allies
  495.  
  496. # apply effect to all battle menbers actors
  497. if @user.battler.is_a?(Game_Actor)
  498. $game_player.followers.each {|i|
  499. next unless i.visible?
  500. next if i.battler.dead? and @item.scope == 8
  501. apply_self_effect(i, pop=true)}
  502. apply_self_effect($game_player, pop=true)
  503.  
  504. # Apply effect to all enemies allies
  505. elsif @user.battler.is_a?(Game_Enemy)
  506. for event in $game_map.event_enemies
  507. if event.on_battle_screen?
  508. next if event.battler.object || event.page.nil?
  509. next if @item.scope == 8 and event.battler.dead?
  510. if event.battler.dead?
  511. @item.scope == 10 ? event.apply_respawn : next
  512. end
  513. event.battler.item_apply(event.battler, @item)
  514. $game_player.damage_pop.push(DamagePop_Obj.new(event))
  515. event.animation_id = animation
  516. end
  517. end
  518. apply_self_effect(@user, true)
  519. end
  520. end
  521.  
  522. # direct effect
  523. def apply_self_effect(target, pop=true)
  524. target.battler.item_apply(target.battler, @item)
  525. target.animation_id = animation
  526. $game_player.damage_pop.push(DamagePop_Obj.new(target))
  527. @destroy_it = true
  528. end
  529.  
  530. #============================================================================
  531. # update damage depending if the user is an enemy or actor
  532. def update_damage
  533. if @user.battler.is_a?(Game_Actor)
  534. apply_damageto_enemy
  535. if @tool_selfdamage
  536. apply_damageto_player
  537. apply_damageto_followers unless @ignore_followers
  538. end
  539. elsif @user.battler.is_a?(Game_Enemy)
  540.  
  541. if $game_player.normal_walk?
  542. apply_damageto_player
  543. apply_damageto_followers unless @ignore_followers
  544. end
  545.  
  546. apply_damageto_enemy if @tool_selfdamage
  547. end
  548. end
  549.  
  550. # Timer updater
  551. def update_timer
  552. update_tool_movement
  553. @mini_opacity -= 1 if @mini_opacity > 0
  554. @opacity = 255 if @mini_opacity == 1
  555. @tool_effect_delay -= 1 if @tool_effect_delay > 0
  556. if @tool_distance == 0
  557. @tool_destroy_delay -= 1 if @tool_destroy_delay > 0
  558. @destroy_it = true if @tool_destroy_delay == 0
  559. end
  560. update_animation_setting
  561. end
  562.  
  563. #=============================================================================
  564. # * movement
  565. def make_diagonal_a
  566. move_diagonal(4, 2) if @direction == 2
  567. move_diagonal(4, 8) if @direction == 4
  568. move_diagonal(6, 8) if @direction == 6
  569. move_diagonal(4, 8) if @direction == 8
  570. end
  571.  
  572. def make_diagonal_b
  573. move_diagonal(6, 2) if @direction == 2
  574. move_diagonal(4, 2) if @direction == 4
  575. move_diagonal(6, 2) if @direction == 6
  576. move_diagonal(6, 8) if @direction == 8
  577. end
  578.  
  579. def make_direction_a
  580. @direction = 4 if @user.direction == 2
  581. @direction = 8 if @user.direction == 4
  582. @direction = 2 if @user.direction == 6
  583. @direction = 6 if @user.direction == 8
  584. @direction_done = true
  585. end
  586.  
  587. def make_direction_b
  588. @direction = 6 if @user.direction == 2
  589. @direction = 2 if @user.direction == 4
  590. @direction = 8 if @user.direction == 6
  591. @direction = 4 if @user.direction == 8
  592. @direction_done = true
  593. end
  594.  
  595. def update_tool_movement
  596. if @tool_distance > 0 and not moving?
  597. if @triple != nil # tripple definition
  598. case @triple
  599. when :uno then make_diagonal_a
  600. when :dos then move_forward
  601. when :tres then make_diagonal_b
  602. end
  603. @tool_distance -= 1
  604.  
  605. elsif @quintuple != nil # quintuple definition
  606. case @quintuple
  607. when :uno ; make_direction_a if @direction_done.nil?; move_forward
  608. when :dos ; make_diagonal_a
  609. when :tres ; move_forward
  610. when :cuatro ; make_diagonal_b
  611. when :cinco ; make_direction_b if @direction_done.nil? ; move_forward
  612. end
  613. @tool_distance -= 1
  614.  
  615. elsif @octuple != nil # octuple
  616. case @octuple
  617. when :uno ; make_direction_a if @direction_done.nil?; move_forward
  618. when :dos ; make_diagonal_a
  619. when :tres ; move_forward
  620. when :cuatro ; make_diagonal_b
  621. when :cinco ; make_direction_b if @direction_done.nil? ; move_forward
  622. when :seis ; make_diagonal_a
  623. when :siete ; move_forward
  624. when :ocho ; make_diagonal_b
  625. end
  626. @tool_distance -= 1
  627.  
  628. elsif @tool_special == "autotarget" # autotarget
  629. if @autotargeting.nil?
  630. @autotargeting = []
  631. # chose any event enemy on the map if the user is an actor
  632. if @user.battler.is_a?(Game_Actor)
  633. for event in $game_map.event_enemies
  634. if @user.is_a?(Game_Follower) and @user.targeted_character != nil
  635. @autotargeting = [true, @user.targeted_character]
  636. #@user.turn_toward_character(@user.targeted_character)
  637. move_forward
  638. return
  639. end
  640. if event.enemy_ready? and event.on_battle_screen? and
  641. obj_size?(event, 8)
  642. @autotargeting = [true, event]
  643. #@user.turn_toward_character(event)
  644. move_forward
  645. return
  646. end
  647. end
  648. # choose a game actor if the user is an enemy
  649. elsif @user.battler.is_a?(Game_Enemy)
  650. @user.agroto_f.nil? ? target =$game_player : target = @user.agroto_f
  651. @autotargeting = [true, target] if obj_size?(target, 8)
  652. end
  653. end
  654.  
  655. if @autotargeting[0]
  656. follow_char(@autotargeting[1])
  657. @autotargeting.clear if @autotargeting[1].x == @x and
  658. @autotargeting[1].y == @y
  659. else
  660. move_forward
  661. end
  662. @tool_distance -= 1
  663. # random
  664. elsif @tool_special == "random"
  665. move_forward if @tool_distance == @original_distance - 1
  666. move_forward if @tool_distance == @original_distance - 2
  667. move_random if @tool_distance <= @original_distance - 3
  668. @tool_distance -= 1
  669.  
  670. # boomerang redirect movement
  671. elsif @tool_special == "boomerang"
  672.  
  673. if @user.is_a?(Game_Player)
  674. case Input.dir8
  675. when 1 then move_diagonal(4, 2)
  676. when 3 then move_diagonal(6, 2)
  677. when 7 then move_diagonal(4, 8)
  678. when 9 then move_diagonal(6, 8)
  679. else #not input just move straig
  680. move_forward
  681. end
  682. # not game player just move straight
  683. else
  684. move_forward
  685. end
  686. @tool_distance -= 1
  687.  
  688. # reserved for common event function
  689. elsif @commonevent_id != nil
  690.  
  691. else # normal move forward behavior
  692. move_forward ; @tool_distance -= 1
  693. end
  694. end
  695. end
  696.  
  697. # tool animation
  698. def update_animation_setting
  699. case @tool_end_anime
  700. when "end"
  701. if @tool_destroy_delay >= 8 and @tool_destroy_delay <= 16
  702. @animation_id = animation
  703. end
  704. when "acting"
  705. if @tool_animerepeat
  706. @animation_id = animation if @mnganime == 0
  707. @mnganime += 1
  708. @mnganime = 0 if @mnganime == 12
  709. else
  710. @animation_id = animation if @mnganime == 0
  711. @mnganime = 1
  712. end
  713. end
  714. if @tool_end_anime.is_a?(Fixnum)
  715. @animation_id = animation if @tool_destroy_delay == @tool_end_anime
  716. end
  717. end
  718.  
  719. # Get the animation to be played
  720. def animation
  721. if @item.is_a?(RPG::Armor)
  722. return $data_skills[@tool_invoke].animation_id if @tool_invoke > 0
  723. return 0
  724. end
  725. return @item.animation_id
  726. end
  727.  
  728. # apply damage to enemy
  729. def apply_damageto_enemy
  730. return if @tool_effect_delay > 0
  731. $game_map.event_enemies.each do |event|
  732. next if event.collapsing?
  733. if event.battler.body_sized > 0
  734. enabled = body_size?([event.x, event.y], @tool_size)
  735. enabled = body_size?([event.x - 1, event.y], @tool_size) if !enabled
  736. enabled = body_size?([event.x, event.y - 1], @tool_size) if !enabled
  737. enabled = body_size?([event.x + 1, event.y], @tool_size) if !enabled
  738. if event.battler.body_sized == 2
  739. enabled = body_size?([event.x-1, event.y-1], @tool_size) if !enabled
  740. enabled = body_size?([event.x, event.y - 2], @tool_size) if !enabled
  741. enabled = body_size?([event.x+1, event.y-1], @tool_size) if !enabled
  742. end
  743. else
  744. enabled = body_size?([event.x, event.y], @tool_size)
  745. end
  746. if enabled and event.just_hitted == 0
  747. event.just_hitted = 20
  748. next if event.page.nil?
  749. if !enable_dame_execution?(event.battler)
  750. unless event.battler.object
  751. RPG::SE.new(Key::GuardSe, 80).play
  752. event.pop_damage('Guard')
  753. play_hit_animation(event)
  754. end
  755. return
  756. end
  757. #-------------------------
  758. execute_damageto_enemy(event)
  759. end
  760. end
  761. end
  762.  
  763. # check wheter the enemy is killed by spefific items
  764. def enable_dame_execution?(enemy)
  765. weapon = enemy.kill_weapon if @original_item.is_a?(RPG::Weapon)
  766. armor = enemy.kill_armor if @original_item.is_a?(RPG::Armor)
  767. item = enemy.kill_item if @original_item.is_a?(RPG::Item)
  768. skill = enemy.kill_skill if @original_item.is_a?(RPG::Skill)
  769. if enemy.has_kill_with?
  770. return true if !weapon.nil? && weapon.include?(@original_item.id)
  771. return true if !armor.nil? && armor.include?(@original_item.id)
  772. return true if !item.nil? && item.include?(@original_item.id)
  773. return true if !skill.nil? && skill.include?(@original_item.id)
  774. return false
  775. end
  776. return true
  777. end
  778.  
  779. # execute damage to enemy
  780. def execute_damageto_enemy(event)
  781. event.being_targeted = false if event.being_targeted
  782. event.epassive = false if event.epassive
  783. if event.agroto_f.nil? and @user.is_a?(Game_Follower)
  784. event.agroto_f = @user if rand(5) == 1
  785. end
  786. if event.agroto_f != nil and @user.is_a?(Game_Player)
  787. event.agroto_f = nil if rand(2) == 1
  788. end
  789. if !event.battler.object
  790. return if guard_success?(event, 1)
  791. end
  792. execute_damage(event)
  793. return if event.battler.object
  794. $game_player.damage_pop.push(DamagePop_Obj.new(event)) unless
  795. guard_success?(event, 2)
  796. apply_blow_power(event) unless event.battler.k_back_dis
  797.  
  798. case (event.battler.hp.to_f / event.battler.mhp.to_f * 100.0)
  799. when 0..10 then activate_lhp_switch(event.battler.lowhp_10)
  800. when 0..25 then activate_lhp_switch(event.battler.lowhp_25)
  801. when 0..50 then activate_lhp_switch(event.battler.lowhp_50)
  802. when 0..75 then activate_lhp_switch(event.battler.lowhp_75)
  803. end
  804. end
  805.  
  806. def activate_lhp_switch(switch)
  807. $game_switches[switch] = true if !switch.nil? and !$game_switches[switch]
  808. end
  809.  
  810.  
  811. # apply damage to player
  812. def apply_damageto_player
  813. return if @tool_effect_delay > 0 || $game_player.battler.dead?
  814. if obj_size?($game_player, @tool_size) and $game_player.just_hitted == 0
  815. $game_player.just_hitted = 20
  816. return if guard_success?($game_player, 1)
  817. execute_damage($game_player)
  818. $game_player.damage_pop.push(DamagePop_Obj.new($game_player)) unless
  819. guard_success?($game_player, 2)
  820. apply_blow_power($game_player)
  821. end
  822. end
  823.  
  824. # Apply damage to followers
  825. def apply_damageto_followers
  826. return if @tool_effect_delay > 0
  827. # followers
  828. for actor in $game_player.followers
  829. next unless actor.visible?
  830. if obj_size?(actor, @tool_size) and actor.just_hitted == 0
  831. actor.just_hitted = 20
  832. next if actor.battler.dead?
  833. return if guard_success?(actor, 1)
  834. execute_damage(actor)
  835. $game_player.damage_pop.push(DamagePop_Obj.new(actor)) unless
  836. guard_success?(actor, 2)
  837. apply_blow_power(actor)
  838. end
  839. end
  840. end
  841.  
  842. def precombo(sym)
  843. @item.is_a?(RPG::Weapon) ? [email protected][0] : [email protected][1]
  844. return if e.nil?
  845. if sym == :apply
  846. @user.apply_weapon_param(e, false)
  847. @user.apply_weapon_param(@item, true)
  848. elsif sym == :remove
  849. @user.apply_weapon_param(@item, false)
  850. @user.apply_weapon_param(e, true)
  851. end
  852. end
  853.  
  854. # Execute damage to the target
  855. def execute_damage(target)
  856. if magical_item?
  857. target.battler.item_apply(@user.battler, @item)
  858. else
  859. @user.apply_weapon_param(@item, true) if @user.battler.is_a?(Game_Enemy)
  860. precombo(:apply) if @user.battler.is_a?(Game_Actor) && @precombi
  861. if @tool_invoke > 0
  862. target.battler.melee_attack_apply(@user.battler, @tool_invoke)
  863. else
  864. target.battler.attack_apply(@user.battler)
  865. end
  866. @user.apply_weapon_param(@item, false) if @user.battler.is_a?(Game_Enemy)
  867. precombo(:remove) if @user.battler.is_a?(Game_Actor) && @precombi
  868. end
  869.  
  870. target.colapse_time = 60 if target.battler.dead?
  871. return if target.battler.is_a?(Game_Enemy) and target.battler.object
  872. hp_d = target.battler.result.hp_drain
  873. @user.pop_damage(['Drain ' + hp_d.to_s, Color.new(10,220,45)]) if hp_d > 0
  874. mp_d = target.battler.result.mp_drain
  875. @user.pop_damage(['Drain ' + mp_d.to_s, Color.new(20,160,225)]) if mp_d > 0
  876. return if target.battler_guarding[0]
  877. return if target.battler.result.hp_damage < 0
  878. return if target.battler.result.hp_damage == 0
  879. target.jump(0, 0) if PearlKernel.jump_hit?(target.battler) and
  880. @tool_blow_power < 2
  881.  
  882. voices = PearlKernel.hitvoices(target.battler)
  883. RPG::SE.new(voices[rand(voices.size)], 80).play unless voices.nil?
  884.  
  885. $game_map.screen.start_shake(8, 6, 24) if @tool_hitshake
  886. return if target.hookshoting[0] || @user.making_spiral
  887. return if @tool_knockdownrate == 0
  888. if rand(101) <= @tool_knockdownrate
  889. target.knockdown_data[0] = 60
  890. end
  891. end
  892.  
  893. # Check guard if the user is using the shield
  894. def guard_success?(userr, type)
  895. if userr.battler_guarding[0]
  896. # guard
  897. if type == 1
  898. if rand(101) <= userr.battler_guarding[1]
  899. return false unless faceto_face?(userr)
  900. RPG::SE.new(Key::GuardSe, 80).play
  901. $game_player.damage_pop.push(DamagePop_Obj.new(userr, 2))
  902. unless @user.making_spiral
  903. @tool_distance = 0
  904. @tool_destroy_delay = 0
  905. end
  906. play_hit_animation(userr)
  907. return true
  908. end
  909. # block
  910. elsif type == 2
  911. return false unless faceto_face?(userr)
  912. $game_player.damage_pop.push(DamagePop_Obj.new(userr, 1))
  913. return true
  914. end
  915. end
  916. return false
  917. end
  918.  
  919. # this metthod make the tool wait for the animation to be displayed when hit
  920. def apply_passive_state
  921. @transparent = true
  922. @tool_effect_delay = 1000 * 1000
  923. @tool_destroy_delay = 60
  924. @animation_id = animation
  925. @tool_distance = 0
  926. end
  927.  
  928. # hit animation
  929. def play_hit_animation(target)
  930. if @target_effect[0] || !@tool_piercing
  931. @tool_end_anime == "hit" ? apply_passive_state : @destroy_it = true
  932. else
  933. target.animation_id = animation if @tool_end_anime == "hit"
  934. end
  935. end
  936.  
  937. # blow powers effects
  938. def apply_blow_power(target)
  939. play_hit_animation(target)
  940. return if target.battler.result.hp_damage < 1
  941. return if target.hookshoting[0] || @user.making_spiral
  942. target.blowpower = [@tool_blow_power, @direction, target.direction_fix,
  943. target.move_speed, 0] if target.blowpower[0] == 0 and
  944. target.blowpower[4] == 0
  945. #follower blow
  946. if target.is_a?(Game_Player)
  947. target.followers.each {|f|
  948. next unless f.visible?
  949. next if f.battler.dead?
  950. f.blowpower = [@tool_blow_power, @direction, f.direction_fix,
  951. f.move_speed, 0] if f.blowpower[0] == 0 and f.blowpower[4] == 0
  952. }
  953. end
  954. end
  955.  
  956. # pattern
  957. def update_anime_pattern
  958. return if @tool_special == "hook"
  959. super
  960. end
  961.  
  962. # Activate events by tool token id
  963. def update_tool_token
  964. return if @tool_effect_delay > 0
  965. $game_map.events_withtags.each do |event|
  966. if obj_size?(event, @tool_size) and event.start_delay == 0
  967. wid = event.token_weapon
  968. aid = event.token_armor
  969. iid = event.token_item
  970. sid = event.token_skill
  971. item = @original_item
  972. case item
  973. when RPG::Weapon; start_token(event) if wid.include?(item.id)
  974. when RPG::Armor ; start_token(event) if aid.include?(item.id)
  975. when RPG::Item ; start_token(event) if iid.include?(item.id)
  976. when RPG::Skill ; start_token(event) if sid.include?(item.id)
  977. end
  978. end
  979. end
  980. end
  981.  
  982. # trigger event
  983. def start_token(event)
  984. $game_map.events_withtags.delete(event)
  985. event.start
  986. event.start_delay = 30
  987. end
  988.  
  989. def move_straight(d, turn_ok = true)
  990. return if force_stopped?
  991. super
  992. end
  993. end
Add Comment
Please, Sign In to add comment