Guest User

Galv's Actor Duel Mini Game

a guest
Oct 24th, 2015
516
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 45.87 KB | None | 0 0
  1. #-------------------------------------------------------------------------------
  2. # Galv's Actor Duel Mini Game
  3. #-------------------------------------------------------------------------------
  4. # For: RPGMAKER VX ACE
  5. # Version 1.5
  6. #-------------------------------------------------------------------------------
  7. # 2013-09-11 - Version 1.5 - fixed <fse: > tag for skills. Ooops!
  8. # 2013-07-13 - Version 1.4 - fixed a bug with changing music script call
  9. # 2013-07-11 - Version 1.3 - added compatibility with victor's animated battler
  10. # - added tag for actor to play victory pose once
  11. # 2013-07-11 - Version 1.2 - fixed (hopefully) a crash with AI battle. Updated
  12. # AI to use skills more often.
  13. # 2013-07-10 - Version 1.1 - added state icons, button combo moves, working
  14. # - regen, poisons, buffs, projectile attacks.
  15. # 2013-07-08 - Version 1.0 - release
  16. #-------------------------------------------------------------------------------
  17. # Holder's animated battler spritesheets can be found here:
  18. # http://animatedbattlers.wordpress.com/
  19. #-------------------------------------------------------------------------------
  20. # This script adds a scene where you can face two actors against each other in
  21. # a mini-game duel that plays similar to a fighting game.
  22. # You can do Player1 VS AI or Player1 VS Player2 (on same computer)
  23. #
  24. # The actors use their statistics and hp in the duel. They can move, jump,
  25. # block, attack and use button combo skills that you create using notetags
  26. # on skills. Normal attack damage formula is taken from skill 1 by default.
  27. #
  28. # Actors have stamina that regenerates during the fight. Each attack uses a
  29. # certain amount of stamina and the fighter cannot attack or use a skill if he
  30. # doesn't have enough left.
  31. #
  32. # Fighters can be affected by buffs and states, however a few things have no
  33. # effect in an actor duel such as blinds or stuns. Poisons, regen, parameter
  34. # boosting stats do work.
  35. #
  36. #-------------------------------------------------------------------------------
  37. # BASIC INSTRUCTIONS
  38. #-------------------------------------------------------------------------------
  39. # 1. Get holder style battlers (http://animatedbattlers.wordpress.com/)
  40. # 2. Import battlers into /Graphics/Battlers folder
  41. # 3. Copy /Graphics/Battlers/FightSkills.png from the demo into your project
  42. # 4. Copy /Graphics/System/kombat_bar.png from the demo into your project
  43. # 5. Put this script below Materials and above main.
  44. # 6. Read all instructions and settings
  45. # 7. Remember to start a NEW GAME instead of loading a save file that was made
  46. # prior to adding this script
  47. #-------------------------------------------------------------------------------
  48.  
  49. #-------------------------------------------------------------------------------
  50. # SCRIPT CALLS
  51. #-------------------------------------------------------------------------------
  52. #
  53. # set_fighters(id1,id2) # Starts a kombat between actors with id1 & id2
  54. #
  55. # set_fbacks("back1","back2") # Change battlebacks for next kombat. "back1"
  56. # # is from /Graphics/Battlebacks1/ and "back2"
  57. # # is from /Graphics/Battlebacks2/
  58. #
  59. # set_fmusic("MusicName") # Change the kombat music
  60. #
  61. # set_fmode(x) # 0 = P1 vs AI 1 = P1 vs P2 (Default 0)
  62. #
  63. # add_fskill(a_id,s_id,[btns]) # a_id = actor id... s_id = skill id
  64. # # [btns] is the button combo array which can
  65. # # include: :l :r :u :d
  66. # # (See explanation below)
  67. #
  68. #-------------------------------------------------------------------------------
  69. # btn info
  70. # -----------------------------
  71. # :l Left key for whomever is on the left. 'away from enemy' key.
  72. # :r Right key for whomever is on the left. 'toward the enemy' key.
  73. # :u Up key
  74. # :d Down key
  75. #
  76. # EXAMPLE OF SCRIPT CALL TO ADD A SKILL:
  77. # add_fskill(1,80,[:l,:l,:r]) # This will give actor 1 a button combo:
  78. # # Left, Left, Right, Attack (while on left)
  79. # # (Right, Right, Left, Attack while on right)
  80. # # Which will activate skill 80
  81. #
  82. #-------------------------------------------------------------------------------
  83.  
  84. #-------------------------------------------------------------------------------
  85. # Note tag for ACTORS required
  86. #-------------------------------------------------------------------------------
  87. #
  88. # <fimage: imagename> # The name of the holder-style spritesheet
  89. # # image from /Graphics/Battlers/
  90. #
  91. #-------------------------------------------------------------------------------
  92. # Note tag for ACTORS to override Defaults
  93. #-------------------------------------------------------------------------------
  94. #
  95. # <fatks: x,x,x,x> # The rows in the spritesheet to use for the
  96. # # actor's normal attacks. Default is COMBO below
  97. #
  98. # <fse miss: sename> # SE to use for attacking and missing
  99. #
  100. # <fhit: x> # Animation played when hitting enemy with attack
  101. #
  102. # <frange: x> # How close need to be to make contact with attack
  103. #
  104. # <fviconeanim> # This notetag will mean the actor's victory pose
  105. # # will only play once instead of repeat.
  106. #
  107. #-------------------------------------------------------------------------------
  108.  
  109. #-------------------------------------------------------------------------------
  110. # Note tag for SKILLS
  111. #-------------------------------------------------------------------------------
  112. #
  113. # <fpose: x> # The pose row used for actor when using this skill.
  114. # # Will default to row 7 if no tag added.
  115. #
  116. # <fcost: x> # Stamina required to use skill
  117. #
  118. # <fse: sename> # SE that plays when using the skill
  119. #
  120. # <fp: p,s,a,t,r> # Use this tag if the skill will be a projectile.
  121. # # p = pose row of SKILLIMAGE spritesheet
  122. # # s = speed projectile travels
  123. # # a = animation_id when projectile is created
  124. # # t = time before projectile disappears (60 per second)
  125. # # r = How close projectile needs to be to make contact
  126. # # Skill's 'scope' must be set to enemy for this to work
  127. #
  128. #
  129. #
  130. #-------------------------------------------------------------------------------
  131. # BUTTON COMBO NOTE
  132. # If a skill has scope of ally, the animation in the database skill is played
  133. # on the user. If not, the animation is played when the skill hits the enemy.
  134. #-------------------------------------------------------------------------------
  135.  
  136. #-------------------------------------------------------------------------------
  137. # DEFAULT SPRITESHEET POSES (HOLDER SETUP)
  138. #-------------------------------------------------------------------------------
  139. # ROW POSE USED IN DEFAULT SCRIPT
  140. #
  141. # 0 Idle Yes
  142. # 1 Guard Yes
  143. # 2 Poor Status Yes
  144. # 3 Get hit Yes
  145. # 4 Normal Attack Yes
  146. # 5 Use Item
  147. # 6 Use Skill
  148. # 7 Use Magic Yes
  149. # 8 Move toward Yes
  150. # 9 Move back Yes
  151. # 10 Victory Yes
  152. # 11 Battle Start
  153. # 12 Dead Yes
  154. # 13 Spritesheet Info
  155. #-------------------------------------------------------------------------------
  156.  
  157. ($imported ||= {})["Galv_ActorDuel"] = true
  158. module GALVFIGHT
  159.  
  160. #-------------------------------------------------------------------------------
  161. #
  162. # ** SETTINGS
  163. #
  164. #-------------------------------------------------------------------------------
  165.  
  166. FONT = "Arial" # Font used in script
  167. VICTOR_VAR = 1 # Variable used to store the winner's ID in. 0 if nobody wins.
  168.  
  169. QUIT_SWITCH = 1 # Turn this swith ON to disable the quit menu. OFF to enable
  170.  
  171. CMD_QUIT = "Quit Match" # To quit the fight
  172. CMD_CANCEL = "Cancel" # When cancelling the quit menu
  173.  
  174. # Spritesheet
  175.  
  176. COLS = 4 # Number of animation columns in spritesheet
  177. ROWS = 14 # Number of rows in spritesheet
  178. SIZE = 2 # Size of the battlers (2 = 2x zoom. 1 = normal)
  179.  
  180. SKILLIMAGE = "FightSkills" # name of skill spritesheet in /Graphics/Battlers/
  181. SKILLCOLS = 4 # Number of animation columns in skill spritesheet
  182. SKILLROWS = 14 # Number of rows in skill spritesheet
  183.  
  184.  
  185. # Actor Defaults
  186.  
  187. COMBO = [4] # Array of spritesheet rows that cycle with attacks
  188. # eg. [4,5,6] will cycle rows 4,5 and 6 when attacking
  189. MISS_SE = "Wind7" # "SE_Name" for missing and attack sound
  190. HIT_ANIM = 115 # Animation played when hitting enemy.
  191. GUARD_ANIM = 116 # Animation played when guarded a hit
  192. RANGE = 45 # Distance from opponent before attack makes contact
  193.  
  194. JUMP_POSE = 8 # Pose used when jumping
  195.  
  196. SKILLSE = "Wind7" # "SE_Name" played when using a skill
  197.  
  198.  
  199. # Level Defaults
  200.  
  201. MUSIC = "Battle6" # Default battle BGM
  202. VICTORY_ME = "Victory1" # Default victory ME
  203.  
  204. BATTLEBACK1 = "Ship" # Default battleback 1 from /Graphics/Battlebacks1/
  205. BATTLEBACK2 = "Ship" # Default battleback 2 from /Graphics/Battlebacks2/
  206.  
  207. P1_X = 100 # Starting X position of player 1
  208. P2_X = 455 # Starting X position of player 2
  209. Y = 310 # Grounded Y position
  210.  
  211.  
  212. # Fighting
  213.  
  214. MAX_STAMINA = 500 # Stamina each fighter has
  215. STAMINA_COST = 100 # Amount of stamina out of 1000 that attacking uses
  216. REGEN_RATE = 1.3 # Speed that stamina regenerates
  217.  
  218. GUARD_DAMAGE = 0.25 # Normal damage is multiplied by this when guarding.
  219.  
  220. ATTACK_SKILL = 1 # Skill to use for basic attacks
  221.  
  222. TURNTIMER = 150 # Number of frames before it counts as a new turn for
  223. # buffs and states
  224.  
  225.  
  226. # Text
  227.  
  228. START1 = "Ready?" # Text that appears at the start
  229. START2 = "FIGHT!"
  230.  
  231. NOWINNER = "MATCH OVER!" # Message when player quits from the match
  232. WINS = " WINS!" # Message that comes after winner's name
  233.  
  234.  
  235.  
  236. #-------------------------------------------------------------------------------
  237. # CONTROLS - PLAYER 1
  238. #-------------------------------------------------------------------------------
  239. P1_UP = :UP # Jump
  240. P1_DOWN = :DOWN # Block
  241. P1_LEFT = :LEFT # Move left
  242. P1_RIGHT = :RIGHT # Move right
  243. P1_ACTION = :C # (Spacebar key) Attack
  244.  
  245. #-------------------------------------------------------------------------------
  246. # CONTROLS - PLAYER 2
  247. #-------------------------------------------------------------------------------
  248. P2_UP = :R # (W key) Jump
  249. P2_DOWN = :Y # (S key) Block
  250. P2_LEFT = :X # (A key) Move Left
  251. P2_RIGHT = :Z # (D key) Move Right
  252. P2_ACTION = :CTRL # Attack
  253.  
  254. #-------------------------------------------------------------------------------
  255.  
  256. end
  257.  
  258. #-------------------------------------------------------------------------------
  259. #
  260. # ** END SETTINGS
  261. #
  262. #-------------------------------------------------------------------------------
  263.  
  264.  
  265. #---------------#
  266. #---| GFIGHT_AI |-----------------------------------------------------------
  267. #---------------#
  268.  
  269. module GFIGHT_AI
  270. def update_f2_ai
  271. update_ai_random
  272. update_ai_decision
  273. update_ai_action
  274. update_timer
  275. update_victorcheck
  276. end
  277.  
  278. def p1; @f1; end
  279. def ai; @f2; end
  280.  
  281. def update_ai_random
  282. if !ai_timer_running?
  283. @chance = (rand(10) + 1).to_i
  284. @schance = (rand(10) + 1).to_i
  285. end
  286. end
  287.  
  288. def update_ai_decision
  289. if ai.in_range_x
  290. update_ai_in_range
  291. else
  292. update_ai_out_of_range
  293. end
  294. end
  295.  
  296. def update_ai_in_range
  297. if p1.attacking?
  298. # IF PLAYER IS ATTACKING
  299. if ai.getting_hit? && @chance > 2
  300. @ai_move = :down
  301. @ai_action = false
  302. @ai_timer = rand(50) + 10 if !ai_timer_running?
  303. else
  304. if @chance > 5
  305. @ai_move = :down
  306. @ai_action = false
  307. @ai_timer = rand(50) + 10 if !ai_timer_running?
  308. elsif @chance > 2
  309. ai_melee_action
  310. @ai_timer = rand(20) + 5 if !ai_timer_running?
  311. else
  312. @ai_move = random_move_in_range
  313. @ai_timer = rand(50) + 10 if !ai_timer_running?
  314. end
  315. end
  316. else
  317. # IF PLAYER IS NOT ATTACKING
  318. if @chance > 4
  319. ai_melee_action
  320. @ai_timer = rand(20) + 10 if !ai_timer_running?
  321. elsif @chance > 2
  322. @ai_move = :down
  323. @ai_action = false
  324. @ai_timer = rand(40) + 20 if !ai_timer_running?
  325. else
  326. @ai_move = random_move_in_range
  327. @ai_timer = rand(40) + 20 if !ai_timer_running?
  328. end
  329. end
  330. end
  331.  
  332. def update_ai_out_of_range
  333. @ai_move = random_move_out_of_range
  334. @ai_action = false
  335. @ai_raction = true
  336. end
  337.  
  338. def ai_jump
  339. if ai.fjumping?
  340. @ai_move = :none
  341. else
  342. @ai_move = :up
  343. ai.fight_pose = 0
  344. end
  345. end
  346.  
  347. def random_move_in_range
  348. if ai.fight_x <= 20 + 10
  349. return @chance > 7 ? :right : :none
  350. elsif ai.fight_x >= Graphics.width - 20 - 10
  351. return @chance > 7 ? :left : :none
  352. elsif @chance >= 8
  353. return :right
  354. elsif @chance >= 5
  355. return :left
  356. elsif @chance == 1
  357. return ai.fjumping? ? :left : :up
  358. elsif @chance == 2
  359. return ai.fjumping? ? :right : :up
  360. else
  361. return :none
  362. end
  363. end
  364.  
  365. def random_move_out_of_range
  366. if ai.fight_x <= 20 + 10
  367. @ai_timer = rand(30) + 10 if !ai_timer_running?
  368. return @chance > 4 ? :right : :none
  369. elsif ai.fight_x >= Graphics.width - 20 - 10
  370. @ai_timer = rand(30) + 10 if !ai_timer_running?
  371. return @chance > 4 ? :left : :none
  372. elsif @chance >= 7
  373. @ai_timer = rand(40) + 10 if !ai_timer_running?
  374. return ai_advance
  375. elsif @chance >= 4
  376. @ai_timer = rand(40) + 10 if !ai_timer_running?
  377. return ai_retreat
  378. else
  379. @ai_timer = rand(30) + 10 if !ai_timer_running?
  380. return :none
  381. end
  382. end
  383.  
  384. def ai_timer_running?
  385. @ai_timer > 0
  386. end
  387.  
  388. def update_ai_action
  389. ai.fight_move(@ai_move)
  390. ai_melee_action if @ai_action
  391. ai_range_action if @ai_raction
  392. end
  393.  
  394. def ai_melee_action
  395. if @schance <= 2
  396. bcs = get_ai_random_skill
  397. ai.fight_combo_skill(bcs) if bcs > 0
  398. else
  399. ai.fight_action
  400. end
  401. end
  402.  
  403. def ai_range_action
  404. if @schance <= 3
  405. bcs = get_ai_projectile_skill
  406. ai.fight_combo_skill(bcs) if bcs > 0
  407. end
  408. end
  409.  
  410. def get_ai_projectile_skill
  411. ai.combo_skills.each { |combo|
  412. return combo[1] if $data_skills[combo[1]].fproj
  413. }
  414. return 0
  415. end
  416.  
  417. def get_ai_random_skill
  418. cskills = ai.combo_skills.to_a
  419. rskill = cskills.sample
  420. @ai_raction = false
  421. return 0 if rskill.nil?
  422. return rskill[1] <= 0 ? 0 : rskill[1]
  423. end
  424.  
  425. def ai_make_attack
  426. if ai.fstamina < GALVFIGHT::STAMINA_COST
  427. @ai_move = :down
  428. else
  429. @ai_action = true
  430. @ai_move = random_move_in_range
  431. end
  432. end
  433.  
  434. def ai_retreat
  435. return ai.fight_x > p1.fight_x ? :right : :left
  436. end
  437.  
  438. def ai_advance
  439. return ai.fight_x < p1.fight_x ? :right : :left
  440. end
  441.  
  442. def update_timer
  443. @ai_timer -= 1
  444. end
  445.  
  446. def update_victorcheck
  447. if p1.dead?
  448. @phase = 2
  449. @victor = ai
  450. end
  451. end
  452. end # GFIGHT_AI
  453.  
  454.  
  455. #----------------------#
  456. #---| GAME_INTERPRETER |----------------------------------------------------
  457. #----------------------#
  458.  
  459. class Game_Interpreter
  460. def set_fighters(player1,player2)
  461. $game_system.save_bgm
  462. command_221
  463. a = $game_actors[player1]
  464. b = $game_actors[player2]
  465. $game_system.fighters = [a,b]
  466. SceneManager.call(Scene_ActorDuel)
  467. wait(1)
  468. command_222
  469. $game_system.replay_bgm
  470. end
  471.  
  472. def set_fbacks(back1,back2)
  473. $game_system.fbacks = [back1,back2]
  474. end
  475.  
  476. def set_fmusic(music)
  477. $game_system.fmusic[0] = music
  478. end
  479.  
  480. def set_fmode(mode)
  481. $game_system.fmode = mode
  482. end
  483.  
  484. def add_skill(a_id,s_id,btns)
  485. $game_actors[a_id].combo_skills[btns] = s_id
  486. end
  487. end
  488.  
  489.  
  490. #------------------#
  491. #---| RPG BASEITEM |--------------------------------------------------------
  492. #------------------#
  493.  
  494. class RPG::BaseItem
  495. def f_atks
  496. if @f_atks.nil?
  497. if @note =~ /<fatks:[ ](.*)>/i
  498. @f_atks = $1.to_s.split(",").map {|i| i.to_i}
  499. else
  500. @f_atks = GALVFIGHT::COMBO
  501. end
  502. end
  503. @f_atks
  504. end
  505. end # RPG::Item
  506.  
  507. class RPG::Skill
  508. def fpose
  509. if @fpose.nil?
  510. if @note =~ /<fpose:[ ](.*)>/i
  511. @fpose = $1.to_i
  512. else
  513. @fpose = 7
  514. end
  515. end
  516. @fpose
  517. end
  518. def fcost
  519. if @fcost.nil?
  520. if @note =~ /<fcost:[ ](.*)>/i
  521. @fcost = $1.to_i
  522. else
  523. @fcost = GALVFIGHT::STAMINA_COST
  524. end
  525. end
  526. @fcost
  527. end
  528. def fproj
  529. if @fproj.nil?
  530. if @note =~ /<fp:[ ](.*)>/i
  531. @fproj = $1.to_s.split(",").map {|i| i.to_i}
  532. else
  533. @fproj = nil
  534. end
  535. end
  536. @fproj
  537. end
  538. def fse
  539. if @fse.nil?
  540. if @note =~ /<fse:[ ](.*)>/i
  541. @fse = $1.to_s
  542. else
  543. @fse = GALVFIGHT::SKILLSE
  544. end
  545. end
  546. @fse
  547. end
  548. end # RPG::Skill
  549.  
  550.  
  551. #----------------#
  552. #---| GAME_ACTOR |----------------------------------------------------------
  553. #----------------#
  554.  
  555. class Game_Actor < Game_Battler
  556. attr_reader :fhit_anim
  557. attr_reader :frange
  558. attr_accessor :fight_x
  559. attr_accessor :fight_y
  560. attr_accessor :fight_pose
  561. attr_accessor :fight_sprite
  562. attr_accessor :fight_speed
  563. attr_accessor :fight_mspeed
  564. attr_accessor :fstamina
  565. attr_accessor :combo_skills
  566. attr_accessor :fprojectiles
  567. attr_accessor :fvicpose
  568.  
  569. alias galv_fight_gagb_setup setup
  570. def setup(actor_id)
  571. galv_fight_gagb_setup(actor_id)
  572. init_fight_vars
  573. @fight_sprite = actor.note =~ /<fimage: (.*)>/i ? $1 : ""
  574. @combo = actor.f_atks
  575. @combo_skills = {}
  576. @fse_miss = actor.note =~ /<fse miss: (.*)>/i ? $1 : GALVFIGHT::MISS_SE
  577. @fhit_anim = actor.note =~ /<fhit: (.*)>/i ? $1.to_i : GALVFIGHT::HIT_ANIM
  578. @frange = actor.note =~ /<frange: (.*)>/i ? $1.to_i : GALVFIGHT::RANGE
  579. @fvicpose = actor.note =~ /<fviconeanim>/i ? true : false # true = one play
  580. end
  581.  
  582. def init_fight_vars
  583. @fight_x = 0
  584. @fight_y = GALVFIGHT::Y
  585. @fight_pose = 0
  586. @fight_speed = 0.to_f
  587. @fight_mspeed = 4
  588. @attack_timer = 0
  589. @skill_timer = 0
  590. @takehit_timer = 0
  591. @jump = 0
  592. @fstamina = GALVFIGHT::MAX_STAMINA
  593. @btn_combo = []
  594. @btn_timer = 0
  595. @fprojectiles = []
  596. end
  597.  
  598. def fight_move(direction)
  599. case direction
  600. when :up
  601. fight_jump
  602. fight_slowing
  603. when :down
  604. fight_guard
  605. fight_slowing
  606. when :left
  607. if !attacking?
  608. if @fight_x < fight_target.fight_x
  609. @fight_pose = 9
  610. else
  611. @fight_pose = 8
  612. end
  613. end
  614. return @fight_speed = 0 if fight_left_limit
  615. @fight_speed -= 0.4
  616. @fight_speed = -@fight_mspeed if @fight_speed <= -@fight_mspeed
  617. when :right
  618. if !attacking?
  619. if @fight_x < fight_target.fight_x
  620. @fight_pose = 8
  621. else
  622. @fight_pose = 9
  623. end
  624. end
  625. return @fight_speed = 0 if fight_right_limit
  626. @fight_speed += 0.4
  627. @fight_speed = @fight_mspeed if @fight_speed >= @fight_mspeed
  628. when :none
  629. if !attacking?
  630. @fight_pose = fjumping? ? GALVFIGHT::JUMP_POSE : fight_idle_pose
  631. end
  632. fight_slowing
  633. end
  634. end
  635.  
  636. def fight_right_limit; @fight_x >= Graphics.width - 20; end
  637. def fight_left_limit; @fight_x <= 20; end
  638.  
  639. def fight_idle_pose
  640. hp < mhp * 0.25 ? 2 : 0
  641. end
  642.  
  643. def fight_slowing
  644. if moving_right?
  645. return @fight_speed = 0 if @fight_x >= Graphics.width - 20
  646. @fight_speed -= [0 + @fight_speed,0.3].min
  647. elsif moving_left?
  648. return @fight_speed = 0 if @fight_x <= 20
  649. @fight_speed += [0 - @fight_speed,0.3].min
  650. end
  651. end
  652.  
  653. def fight_action
  654. return if attacking? || guarding? || getting_hit?
  655. bcs = get_combo_skill
  656. if bcs.nil?
  657. fight_normal_attack
  658. else
  659. fight_combo_skill(bcs)
  660. end
  661. end
  662.  
  663. def get_combo_skill
  664. @combo_skills.each { |combo|
  665. if @btn_combo.reverse[0..(combo[0].size - 1)] == combo[0].reverse
  666. return combo[1]
  667. end
  668. }
  669. return nil
  670. end
  671.  
  672. def fight_normal_attack
  673. return if @fstamina < GALVFIGHT::STAMINA_COST
  674. @fskill_used = nil
  675. @fstamina -= GALVFIGHT::STAMINA_COST
  676. se = @fse_miss
  677. vol = 80 + rand(20)
  678. pit = 100 + rand(50)
  679. RPG::SE.new(se,vol,pit).play
  680. @combo = @combo.rotate
  681. @fight_pose = @combo[0]
  682. @attack_timer = 22
  683. end
  684.  
  685. def fight_combo_skill(skill)
  686. sk = $data_skills[skill]
  687. return if @fstamina < sk.fcost #fight_normal_attack if @fstamina < sk.fcost
  688. return if attacking?
  689. @fstamina -= sk.fcost
  690. se = sk.fse
  691. vol = 80 + rand(20)
  692. pit = 100 + rand(50)
  693. RPG::SE.new(se,vol,pit).play
  694. if sk.fproj
  695. # Create Projectile Here
  696. @fprojectiles << FightProjectile.new(sk,self)
  697. self.animation_id = sk.fproj[2]
  698. @skill_timer = 22
  699. elsif sk.scope >= 7
  700. self.animation_id = sk.animation_id
  701. self.fight_item_apply(self, sk)
  702. @skill_timer = 22
  703. else
  704. @fskill_used = sk
  705. @attack_timer = 22
  706. end
  707. @fight_pose = sk.fpose
  708. end
  709.  
  710. def fight_item_apply(user, item)
  711. @result.clear
  712. @result.used = item_test(user, item)
  713. @result.missed = (@result.used && rand >= item_hit(user, item))
  714. @result.evaded = ([email protected] && rand < item_eva(user, item))
  715. if @result.hit?
  716. @result.critical = (rand < item_cri(user, item))
  717. damage = fight_damage_value(self, $data_skills[item.id])
  718. fight_target.do_damage(guarding?,item.id,damage)
  719. item.effects.each {|effect| item_effect_apply(user, item, effect) }
  720. item_user_effect(user, item)
  721. end
  722. end
  723.  
  724. def fight_guard
  725. return if attacking?
  726. @fight_pose = 1
  727. end
  728.  
  729. def fight_jump
  730. return if fjumping? || in_air?
  731. @jump = -10 - GALVFIGHT::SIZE / 2
  732. end
  733.  
  734. def fjumping?; @jump < 0; end
  735. def in_air?; @fight_y < GALVFIGHT::Y; end
  736. def attacking?; @attack_timer > 0 || @skill_timer > 0; end
  737. def guarding?; @fight_pose == 1; end
  738. def getting_hit?; @takehit_timer > 0; end
  739. def moving_right?; @fight_speed > 0; end
  740. def moving_left?; @fight_speed < 0; end
  741. def away(amount)
  742. if fight_x < fight_target.fight_x
  743. return amount
  744. else
  745. return -amount
  746. end
  747. end
  748.  
  749. def move_pose(direction)
  750. return 1 if @fight_x < fight_target.fight_x
  751. end
  752.  
  753. def update_fight
  754. @takehit_timer -= 1
  755. update_fight_movement
  756. update_gravity
  757. return @fight_pose = 12 if dead?
  758. return @fight_pose = 3 if getting_hit? && !guarding?
  759. update_btn_combo
  760. update_stamina
  761. update_hit
  762. @attack_timer -= 1
  763. @skill_timer -= 1
  764. end
  765.  
  766. def update_stamina
  767. @fstamina += GALVFIGHT::REGEN_RATE if @fstamina < GALVFIGHT::MAX_STAMINA
  768. end
  769.  
  770. def update_fight_movement
  771. if moving_right?
  772. @fight_x += [@fight_speed,@fight_mspeed].min
  773. elsif moving_left?
  774. @fight_x += [@fight_speed,-@fight_mspeed].max
  775. end
  776. end
  777.  
  778. def update_gravity
  779. if fjumping? || in_air?
  780. @fight_y += @jump + $game_system.gravity
  781. @jump += 0.2
  782. else
  783. @fight_y = GALVFIGHT::Y
  784. @jump = 0
  785. end
  786. end
  787.  
  788. def fight_target
  789. if $game_system.fighters[0].id == @actor_id
  790. return $game_system.fighters[1]
  791. else
  792. return $game_system.fighters[0]
  793. end
  794. end
  795.  
  796. def update_hit
  797. if @attack_timer == 8
  798. if make_contact?
  799. if fight_target.guarding?
  800. fight_target.animation_id = GALVFIGHT::GUARD_ANIM
  801. s = @fskill_used ? @fskill_used : $data_skills[GALVFIGHT::ATTACK_SKILL]
  802. damage = fight_damage_value(self,s)
  803. do_damage(true,s.id,damage)
  804. @fskill_used = nil
  805. else
  806. if @fskill_used
  807. anim = @fskill_used.animation_id
  808. s = @fskill_used
  809. else
  810. anim = @fhit_anim
  811. s = $data_skills[GALVFIGHT::ATTACK_SKILL]
  812. end
  813. fight_target.animation_id = anim
  814. damage = fight_damage_value(self,s)
  815. do_damage(false,GALVFIGHT::ATTACK_SKILL,damage)
  816. @fskill_used = nil
  817. end
  818. end
  819. end
  820. end
  821.  
  822. def proj_hit(skill)
  823. if fight_target.guarding?
  824. fight_target.animation_id = GALVFIGHT::GUARD_ANIM
  825. else
  826. fight_target.animation_id = skill.animation_id
  827. end
  828. fight_target.fight_item_apply(self,skill)
  829. end
  830.  
  831. def do_damage(guard,s_id,damage,proj = false)
  832. if guard
  833. damage *= GALVFIGHT::GUARD_DAMAGE
  834. if damage > 0
  835. fight_target.fight_speed += away(2) * GALVFIGHT::SIZE
  836. @fight_speed += fight_target.away(2) * GALVFIGHT::SIZE if proj
  837. end
  838. else
  839. fight_target.fight_speed += away(4) * GALVFIGHT::SIZE if damage > 0
  840. end
  841. fight_target.fight_damage(damage)
  842. end
  843.  
  844. def fight_damage_value(user, item)
  845. value = item.damage.eval(user, self, $game_variables)
  846. value *= item_element_rate(user, item)
  847. value *= pdr if item.physical?
  848. value *= mdr if item.magical?
  849. value *= rec if item.damage.recover?
  850. value = apply_variance(value, item.damage.variance)
  851. return value
  852. end
  853.  
  854. def fight_damage(damage)
  855. change_hp(-damage.to_i,true) if SceneManager.scene.phase == 1
  856. @attack_timer = 0
  857. @skill_timer = 0
  858. if damage > 0
  859. @takehit_timer = 18
  860. remove_states_by_damage
  861. end
  862. end
  863.  
  864. def reach; @frange * GALVFIGHT::SIZE; end
  865. def range; (fight_target.fight_x - @fight_x).abs; end
  866. def in_range_x; (fight_target.fight_x - @fight_x).abs < reach; end
  867. def in_range_y; ((fight_target.fight_y - @fight_y).abs) * 1.2 < reach ;end
  868. def near_range_x; ((fight_target.fight_x - @fight_x).abs) / 1.5 < reach; end
  869.  
  870. def make_contact?
  871. return true if in_range_x && in_range_y
  872. end
  873.  
  874. def reset_fight
  875. erase_state(death_state_id)
  876. @hp = 1 if @hp <= 0
  877. init_fight_vars
  878. end
  879.  
  880. def end_match
  881. @fight_pose = 0 if !dead?
  882. end
  883.  
  884. def sta_rate
  885. @fstamina.to_f / GALVFIGHT::MAX_STAMINA
  886. end
  887.  
  888. def update_btn_combo
  889. @btn_combo = [] if @btn_timer == 0
  890. @btn_timer -= 1
  891. end
  892.  
  893. def add_combo(direction)
  894. @btn_timer = 20
  895. @btn_combo << direction
  896. end
  897. end # Game_Actor < Game_Battler
  898.  
  899.  
  900. #-----------------#
  901. #---| GAME_SYSTEM |---------------------------------------------------------
  902. #-----------------#
  903.  
  904. class Game_System
  905. attr_accessor :fighters
  906. attr_accessor :fmode
  907. attr_accessor :gravity
  908. attr_accessor :fbacks
  909. attr_accessor :fmusic
  910.  
  911. alias galv_fight_gs_initialize initialize
  912. def initialize
  913. galv_fight_gs_initialize
  914. @gravity = 5
  915. @fbacks = [GALVFIGHT::BATTLEBACK1,GALVFIGHT::BATTLEBACK2]
  916. @fmusic = [GALVFIGHT::MUSIC,GALVFIGHT::VICTORY_ME]
  917. @fmode = 0 # 0 is Player vs AI 1 is Player vs Player
  918. end
  919. end # Game_System
  920.  
  921.  
  922. #---------------------#
  923. #---| SCENE_ACTORDUEL |-----------------------------------------------------
  924. #---------------------#
  925.  
  926. class Scene_ActorDuel < Scene_Base
  927. attr_accessor :spriteset
  928. attr_reader :phase
  929. include GFIGHT_AI
  930.  
  931. def start
  932. super
  933. init_fvariables
  934. determine_fighters
  935. create_spriteset
  936. create_windows
  937. end
  938.  
  939. def init_fvariables
  940. $game_variables[GALVFIGHT::VICTOR_VAR] = 0
  941. @phase = 0
  942. @ai_move = :none
  943. @ai_action = false
  944. @ai_timer = 0
  945. @bufftimer = 0
  946. RPG::BGM.new($game_system.fmusic[0],100,100).play
  947. end
  948.  
  949. def determine_fighters
  950. @f1,@f2 = $game_system.fighters
  951. @f1.fight_x = GALVFIGHT::P1_X
  952. @f2.fight_x = GALVFIGHT::P2_X
  953. end
  954.  
  955. def create_spriteset
  956. @spriteset = Spriteset_ActorDuel.new
  957. end
  958.  
  959. def create_windows
  960. @hp_window = Window_FightHealth.new
  961. @info_window = Window_Fight.new
  962. @command_window = Window_FightCommand.new
  963. @command_window.deactivate.hide
  964. @command_window.set_handler(:ok, method(:on_ok))
  965. @command_window.set_handler(:cancel, method(:on_cancel))
  966. end
  967.  
  968. def on_ok
  969. @phase = 2
  970. @command_window.hide.deactivate
  971. @f1.end_match
  972. @f2.end_match
  973. end
  974.  
  975. def on_cancel
  976. @command_window.hide.deactivate
  977. end
  978.  
  979. #--------| UPDATE
  980.  
  981. def update
  982. super
  983. update_graphics
  984. case @phase
  985. when 0
  986. update_begin
  987. when 1
  988. return if @command_window.active
  989. update_fighter1
  990. update_fighter2
  991. update_other
  992. when 2
  993. update_common(@f2)
  994. update_common(@f1)
  995. @f1.fight_speed = 0
  996. @f2.fight_speed = 0
  997. update_end
  998. end
  999. end
  1000.  
  1001. def update_begin
  1002. return while @info_window.active
  1003. @phase = 1
  1004. end
  1005.  
  1006. def update_end
  1007. RPG::ME.new($game_system.fmusic[1],100,100).play if !@end_timer
  1008. @end_timer ||= 60
  1009. @victor.fight_pose = 10 if @victor
  1010. @end_timer -= 1
  1011. return if @end_timer > 0
  1012. @info_window.victory(@victor) if @end_timer == 0
  1013. return while @info_window.active
  1014. $game_system.fighters.each { |actor| actor.reset_fight }
  1015. $game_variables[GALVFIGHT::VICTOR_VAR] = @victor ? @victor.id : 0
  1016. SceneManager.return
  1017. end
  1018.  
  1019. def update_graphics
  1020. @spriteset.update
  1021. end
  1022.  
  1023. def update_other
  1024. if Input.trigger?(:B) && !$game_switches[GALVFIGHT::QUIT_SWITCH]
  1025. @command_window.show.activate
  1026. end
  1027. if @bufftimer >= GALVFIGHT::TURNTIMER
  1028. @f1.on_turn_end
  1029. @f2.on_turn_end
  1030. @f1.remove_buffs_auto
  1031. @f2.remove_buffs_auto
  1032. @bufftimer = 0
  1033. end
  1034. @bufftimer += 1
  1035. end
  1036.  
  1037. def update_fighter1
  1038. update_f1_movement
  1039. update_f1_action
  1040. update_common(@f1)
  1041. end
  1042.  
  1043. def update_f1_movement
  1044. if Input.press?(GALVFIGHT::P1_DOWN)
  1045. @f1.fight_move(:down)
  1046. @f1.add_combo(:d) if Input.trigger?(GALVFIGHT::P1_DOWN)
  1047. elsif Input.trigger?(GALVFIGHT::P1_UP)
  1048. @f1.fight_move(:up)
  1049. @f1.add_combo(:u)
  1050. elsif Input.press?(GALVFIGHT::P1_LEFT)
  1051. @f1.fight_move(:left)
  1052. @f1.add_combo(get_back_dir(@f1)) if Input.trigger?(GALVFIGHT::P1_LEFT)
  1053. elsif Input.press?(GALVFIGHT::P1_RIGHT)
  1054. @f1.fight_move(:right)
  1055. @f1.add_combo(get_forward_dir(@f1)) if Input.trigger?(GALVFIGHT::P1_RIGHT)
  1056. else
  1057. @f1.fight_move(:none)
  1058. end
  1059. end
  1060.  
  1061. def get_back_dir(player)
  1062. return player.fight_x < player.fight_target.fight_x ? :l : :r
  1063. end
  1064.  
  1065. def get_forward_dir(player)
  1066. return player.fight_x < player.fight_target.fight_x ? :r : :l
  1067. end
  1068.  
  1069. def update_f1_action
  1070. @f1.fight_action if Input.trigger?(GALVFIGHT::P1_ACTION) &&
  1071. if @f2.dead?
  1072. @phase = 2
  1073. @victor = @f1
  1074. end
  1075. end
  1076.  
  1077. def update_fighter2
  1078. if $game_system.fmode == 1
  1079. update_f2_movement
  1080. update_f2_action
  1081. else
  1082. update_f2_ai
  1083. end
  1084. update_common(@f2)
  1085. end
  1086.  
  1087. def update_f2_movement
  1088. if Input.press?(GALVFIGHT::P2_DOWN)
  1089. @f2.fight_move(:down)
  1090. @f2.add_combo(:d) if Input.trigger?(GALVFIGHT::P2_DOWN)
  1091. elsif Input.trigger?(GALVFIGHT::P2_UP)
  1092. @f2.fight_move(:up)
  1093. @f2.add_combo(:u)
  1094. elsif Input.press?(GALVFIGHT::P2_LEFT)
  1095. @f2.fight_move(:left)
  1096. @f2.add_combo(get_back_dir(@f2)) if Input.trigger?(GALVFIGHT::P2_LEFT)
  1097. elsif Input.press?(GALVFIGHT::P2_RIGHT)
  1098. @f2.fight_move(:right)
  1099. @f2.add_combo(get_forward_dir(@f2)) if Input.trigger?(GALVFIGHT::P2_RIGHT)
  1100. else
  1101. @f2.fight_move(:none)
  1102. end
  1103. end
  1104.  
  1105. def update_f2_action
  1106. @f2.fight_action if Input.trigger?(GALVFIGHT::P2_ACTION) && [email protected]? && [email protected]?
  1107. if @f1.dead?
  1108. @phase = 2
  1109. @victor = @f2
  1110. end
  1111. end
  1112.  
  1113. def update_common(fighter)
  1114. fighter.update_fight
  1115. end
  1116.  
  1117. #--------| DESTROY
  1118.  
  1119. def dispose_spriteset
  1120. @spriteset.dispose
  1121. end
  1122.  
  1123. def terminate
  1124. super
  1125. dispose_spriteset
  1126. @f1.on_battle_end
  1127. @f2.on_battle_end
  1128. end
  1129. end # Scene_Kombat < Scene_Base
  1130.  
  1131.  
  1132. #-------------------------#
  1133. #---| SPRITESET_ACTORDUEL |-------------------------------------------------
  1134. #-------------------------#
  1135.  
  1136. class Spriteset_ActorDuel
  1137. attr_accessor :viewport3
  1138.  
  1139. def initialize
  1140. create_viewports
  1141. create_battleback1
  1142. create_battleback2
  1143. create_fighters
  1144. create_face1
  1145. create_face2
  1146. create_bars
  1147. update
  1148. end
  1149.  
  1150. #-------- | CREATE STUFF
  1151.  
  1152. def create_viewports
  1153. @viewport1 = Viewport.new
  1154. @viewport2 = Viewport.new
  1155. @viewport3 = Viewport.new
  1156. @viewport1.z = 20
  1157. @viewport2.z = 50
  1158. @viewport3.z = 150
  1159. end
  1160.  
  1161. def create_battleback1
  1162. return if !$game_system.fbacks[0]
  1163. @back1_sprite = Sprite.new(@viewport1)
  1164. @back1_sprite.bitmap = Cache.battleback1($game_system.fbacks[0])
  1165. @back1_sprite.z = -1
  1166. center_sprite(@back1_sprite)
  1167. end
  1168.  
  1169. def create_battleback2
  1170. return if !$game_system.fbacks[1]
  1171. @back2_sprite = Sprite.new(@viewport1)
  1172. @back2_sprite.bitmap = Cache.battleback2($game_system.fbacks[1])
  1173. @back2_sprite.z = 0
  1174. center_sprite(@back2_sprite)
  1175. end
  1176.  
  1177. def create_fighters
  1178. @fighters = []
  1179. @shadows = []
  1180. $game_system.fighters.each { |f|
  1181. @shadows << Sprite_FightShadow.new(@viewport2,f)
  1182. @fighters << Sprite_Fighter.new(@viewport2,f)
  1183. }
  1184. end
  1185.  
  1186. def create_face1
  1187. face_index = $game_system.fighters[0].face_index
  1188. @face1 = Sprite.new(@viewport2)
  1189. @face1.bitmap = Cache.face($game_system.fighters[0].face_name)
  1190. rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, 96, 96)
  1191. @face1.src_rect.set(rect)
  1192. end
  1193.  
  1194. def create_face2
  1195. face_index = $game_system.fighters[1].face_index
  1196. @face2 = Sprite.new(@viewport2)
  1197. @face2.bitmap = Cache.face($game_system.fighters[1].face_name)
  1198. rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, 96, 96)
  1199. @face2.src_rect.set(rect)
  1200. @face2.x = Graphics.width - 96
  1201. @face2.mirror = true
  1202. end
  1203.  
  1204. def create_bars
  1205. @bar1 = Sprite.new(@viewport3)
  1206. @bar1.bitmap = Cache.system("kombat_bar") rescue Cache.system("")
  1207. @bar2 = Sprite.new(@viewport3)
  1208. @bar2.bitmap = Cache.system("kombat_bar") rescue Cache.system("")
  1209. @bar2.x = Graphics.width - @bar2.bitmap.width
  1210. @bar2.mirror = true
  1211. end
  1212.  
  1213. #-------- | UPDATE STUFF
  1214.  
  1215. def update
  1216. @fighters.each { |s| s.update }
  1217. @shadows.each { |s| s.update }
  1218. @viewport1.update
  1219. @viewport2.update
  1220. @viewport3.update
  1221. update_projectiles
  1222. end
  1223.  
  1224. def update_projectiles
  1225. $game_system.fighters.each { |f|
  1226. f.fprojectiles.each_with_index { |p,i|
  1227. if p.finished?
  1228. p.dispose if !p.nil?
  1229. p = nil
  1230. else
  1231. p.update
  1232. end
  1233. }
  1234. f.fprojectiles.compact!
  1235. }
  1236. end
  1237.  
  1238. #-------- | DESTROY STUFF
  1239.  
  1240. def dispose
  1241. dispose_viewports
  1242. dispose_fighters
  1243. dispose_background
  1244. dispose_faces
  1245. dispose_projectiles
  1246. end
  1247.  
  1248. def dispose_viewports
  1249. @viewport1.dispose
  1250. @viewport2.dispose
  1251. @viewport3.dispose
  1252. end
  1253.  
  1254. def dispose_fighters
  1255. @fighters.each { |s| s.dispose }
  1256. @shadows.each { |s| s.dispose }
  1257. @bar1.dispose
  1258. @bar2.dispose
  1259. end
  1260.  
  1261. def dispose_background
  1262. @back1_sprite.dispose if @back1_sprite
  1263. @back2_sprite.dispose if @back2_sprite
  1264. end
  1265.  
  1266. def dispose_faces
  1267. @face1.dispose
  1268. @face2.dispose
  1269. end
  1270.  
  1271. def dispose_projectiles
  1272. $game_system.fighters.each { |f|
  1273. f.fprojectiles.each { |p| p.dispose }
  1274. }
  1275. end
  1276.  
  1277. def center_sprite(sprite)
  1278. sprite.ox = sprite.bitmap.width / 2
  1279. sprite.oy = sprite.bitmap.height / 2
  1280. sprite.x = Graphics.width / 2
  1281. sprite.y = Graphics.height / 2
  1282. end
  1283. end # Spriteset_ActorDuel
  1284.  
  1285.  
  1286. #-------------------#
  1287. #---| SPRITE_FIGHTER |-------------------------------------------------------
  1288. #-------------------#
  1289.  
  1290. class Sprite_Fighter < Sprite_Battler
  1291. def initialize(viewport, battler = nil)
  1292. super(viewport,battler)
  1293. init_fvariables
  1294. end
  1295.  
  1296. def init_fvariables
  1297. @pattern = 0
  1298. @speed_timer = 0
  1299. @pose = 0
  1300. if $game_system.fighters[0].id == @battler.id
  1301. player = 0; opponent = 1
  1302. else
  1303. player = 1; opponent = 0
  1304. end
  1305. @player = $game_system.fighters[player]
  1306. @opponent = $game_system.fighters[opponent]
  1307. end
  1308.  
  1309. def update
  1310. if @battler.fight_sprite
  1311. update_bitmap
  1312. update_pose
  1313. update_src_rect
  1314. update_anim
  1315. update_position
  1316. update_facing
  1317. end
  1318. super
  1319. end
  1320.  
  1321. def update_bitmap
  1322. new_bitmap = Cache.battler(@battler.fight_sprite,
  1323. @battler.battler_hue)
  1324. if bitmap != new_bitmap
  1325. self.bitmap = new_bitmap
  1326. spritesheet_normal
  1327. init_visibility
  1328. self.zoom_x = GALVFIGHT::SIZE
  1329. self.zoom_y = GALVFIGHT::SIZE
  1330. end
  1331. end
  1332.  
  1333. def spritesheet_normal
  1334. @cw = bitmap.width / GALVFIGHT::COLS
  1335. @ch = bitmap.height / GALVFIGHT::ROWS
  1336. self.ox = @cw / 2
  1337. self.oy = @ch
  1338. end
  1339.  
  1340. def update_pose
  1341. if @pose != @battler.fight_pose
  1342. @pattern = 0
  1343. @pose = @battler.fight_pose
  1344. end
  1345. end
  1346.  
  1347. def update_src_rect
  1348. if @pattern >= GALVFIGHT::COLS
  1349. if @battler.fight_pose == 10 && @battler.fvicpose
  1350. @pattern = GALVFIGHT::COLS - 1
  1351. else
  1352. @pattern = 0
  1353. end
  1354. end
  1355. sx = @pattern * @cw
  1356. sy = @battler.fight_pose * @ch
  1357. self.src_rect.set(sx, sy, @cw, @ch)
  1358. end
  1359.  
  1360. def update_origin;end
  1361.  
  1362. def update_anim
  1363. @speed_timer += 1
  1364. if @speed_timer > 6
  1365. @pattern += 1
  1366. @speed_timer = 0
  1367. end
  1368. end
  1369.  
  1370. def update_facing
  1371. self.mirror = @player.fight_x > @opponent.fight_x ? false : true
  1372. end
  1373.  
  1374. def update_position
  1375. self.x = @battler.fight_x
  1376. self.y = @battler.fight_y
  1377. end
  1378.  
  1379. def make_animation_sprites
  1380. @ani_sprites = []
  1381. if !@@ani_spr_checker.include?(@animation)
  1382. 16.times do
  1383. sprite = ::Sprite.new(viewport)
  1384. sprite.visible = false
  1385. @ani_sprites.push(sprite)
  1386. end
  1387. if @animation.position == 3
  1388. @@ani_spr_checker.push(@animation)
  1389. end
  1390. end
  1391. @ani_duplicated = @@ani_checker.include?(@animation)
  1392. if !@ani_duplicated && @animation.position == 3
  1393. @@ani_checker.push(@animation)
  1394. end
  1395. end
  1396. end # Sprite_Fighter < Sprite_Battler
  1397.  
  1398.  
  1399. #------------------#
  1400. #---| SPRITE_SHADOW |--------------------------------------------------------
  1401. #------------------#
  1402.  
  1403. class Sprite_FightShadow < Sprite
  1404. def initialize(viewport, player)
  1405. super(viewport)
  1406. @player = player
  1407. create_shadow
  1408. end
  1409.  
  1410. def dispose
  1411. bitmap.dispose if bitmap
  1412. super
  1413. end
  1414.  
  1415. def update
  1416. super
  1417. update_position
  1418. end
  1419.  
  1420. def create_shadow
  1421. self.bitmap = Cache.system("Shadow")
  1422. self.ox = self.bitmap.width / 2
  1423. self.oy = self.bitmap.height
  1424. self.z = 0
  1425. self.zoom_x = GALVFIGHT::SIZE
  1426. self.zoom_y = GALVFIGHT::SIZE
  1427. end
  1428.  
  1429. def update_position
  1430. self.x = @player.fight_x
  1431. self.y = GALVFIGHT::Y
  1432. end
  1433. end # Sprite_FightShadow < Sprite
  1434.  
  1435.  
  1436. #-----------------------#
  1437. #---| WINDOW_FIGHTHEALTH |---------------------------------------------------
  1438. #-----------------------#
  1439.  
  1440. class Window_FightHealth < Window_Base
  1441. def initialize
  1442. super(0, 0, Graphics.width, 140)
  1443. self.opacity = 0
  1444. refresh
  1445. end
  1446.  
  1447. def player; $game_system.fighters; end
  1448.  
  1449. def update
  1450. super
  1451. refresh
  1452. end
  1453.  
  1454. def refresh
  1455. contents.clear
  1456. contents.font.name = GALVFIGHT::FONT
  1457. draw_player1
  1458. draw_player2
  1459. end
  1460.  
  1461. def draw_player1
  1462. pl = player[0]
  1463. draw_hp(pl, 100, 15, false)
  1464. draw_stamina(pl, 100, 40, false)
  1465. draw_text(100,0,100,line_height,pl.name,0)
  1466. draw_actor_icons(pl, 100, 65, 240)
  1467. end
  1468.  
  1469. def draw_player2
  1470. pl = player[1]
  1471. draw_hp(pl, contents.width - 224, 15, true)
  1472. draw_stamina(pl, contents.width - 224, 40, true)
  1473. draw_text(contents.width - 200,0,100,line_height,pl.name,2)
  1474. draw_actor_icons(pl, contents.width - 224, 65, 240)
  1475. end
  1476.  
  1477. def draw_hp(actor, x, y, r)
  1478. draw_gauge(x, y, 124, actor.hp_rate, hp_gauge_color1, hp_gauge_color2, r, 12)
  1479. end
  1480.  
  1481. def draw_stamina(actor, x, y, r)
  1482. draw_gauge(x, y, 124, actor.sta_rate, mp_gauge_color1, mp_gauge_color2, r, 6)
  1483. end
  1484.  
  1485. def draw_gauge(x, y, width, rate, color1, color2, reverse, height)
  1486. fill_w = (width * rate).to_i
  1487. gauge_y = y + line_height - 8
  1488. contents.fill_rect(x, gauge_y, width, height, gauge_back_color)
  1489. if reverse
  1490. contents.gradient_fill_rect(x + width - fill_w, gauge_y, fill_w, height,
  1491. color1, color2)
  1492. else
  1493. contents.gradient_fill_rect(x, gauge_y, fill_w, height, color1, color2)
  1494. end
  1495. end
  1496. end # Window_FightHealth < Window_Base
  1497.  
  1498.  
  1499. #-----------------#
  1500. #---| WINDOW_FIGHT |---------------------------------------------------------
  1501. #-----------------#
  1502.  
  1503. class Window_Fight < Window_Base
  1504. attr_accessor :phase
  1505. attr_accessor :victor
  1506.  
  1507. def initialize
  1508. super(0, 0, Graphics.width, Graphics.height)
  1509. self.opacity = 0
  1510. @phase = 0
  1511. @timer = 0
  1512. end
  1513.  
  1514. def update
  1515. case @phase
  1516. when 0
  1517. contents.clear
  1518. contents.font.name = GALVFIGHT::FONT
  1519. contents.font.size += 1
  1520. draw_text(0,0,width,height,GALVFIGHT::START1,1)
  1521. when 2
  1522. contents.clear
  1523. contents.font.name = GALVFIGHT::FONT
  1524. contents.font.size = 80
  1525. draw_text(0,0,width,height,GALVFIGHT::START2,1)
  1526. when 3
  1527. contents.clear
  1528. deactivate
  1529. when 4
  1530. contents.clear
  1531. contents.font.size = 60
  1532. if @victor
  1533. contents.font.name = GALVFIGHT::FONT
  1534. txt = @victor.name.upcase + GALVFIGHT::WINS
  1535. draw_text(0,0,width,height,txt,1)
  1536. else
  1537. contents.font.name = GALVFIGHT::FONT
  1538. draw_text(0,0,width,height,GALVFIGHT::NOWINNER,1)
  1539. end
  1540. when 5
  1541. contents.clear
  1542. deactivate
  1543. end
  1544. @timer += 1
  1545. @phase = 1 if @timer == 40
  1546. @phase = 2 if @timer == 100
  1547. @phase = 3 if @timer == 130
  1548. @phase = 5 if @timer == 300
  1549. end
  1550.  
  1551. def victory(victor)
  1552. @victor = victor
  1553. @phase = 4
  1554. @timer = 150
  1555. activate
  1556. end
  1557. end # Window_Fight < Window_Base
  1558.  
  1559.  
  1560. #------------------------#
  1561. #---| WINDOW_FIGHTCOMMAND |--------------------------------------------------
  1562. #------------------------#
  1563.  
  1564. class Window_FightCommand < Window_Command
  1565. def initialize
  1566. super(Graphics.width / 2 - window_width / 2, Graphics.height / 2 - 80)
  1567. end
  1568.  
  1569. def window_width; return 160; end
  1570. def visible_line_number; return 2; end
  1571.  
  1572. def make_command_list
  1573. add_command(GALVFIGHT::CMD_QUIT, :quit, true)
  1574. add_command(GALVFIGHT::CMD_CANCEL, :cancel, true)
  1575. end
  1576.  
  1577. def update; super; end
  1578. def select_last; select(0); end
  1579. end # Window_FightCommand < Window_Command
  1580.  
  1581.  
  1582. #---------------------------#
  1583. #---| SPRITE_FIGHTPROJECTILE |-----------------------------------------------
  1584. #---------------------------#
  1585.  
  1586. class FightProjectile < Sprite_Base
  1587. attr_accessor :skill
  1588. def initialize(skill, owner)
  1589. @owner = owner
  1590. @target = owner.fight_target
  1591. @skill = skill
  1592. super(SceneManager.scene.spriteset.viewport3)
  1593. init_fvariables
  1594. create_bitmap
  1595. end
  1596.  
  1597. def init_fvariables
  1598. self.x = @owner.fight_x
  1599. self.y = @owner.fight_y
  1600. self.opacity = 0
  1601. @pattern = 0
  1602. @pose = @skill.fproj[0]
  1603. @speed_timer = 0
  1604. @range_limit = @skill.fproj[3]
  1605. @range = 0
  1606. @reach = @skill.fproj[4]
  1607. end
  1608.  
  1609. def update
  1610. update_src_rect
  1611. update_anim
  1612. update_position
  1613. update_hit
  1614. super
  1615. end
  1616.  
  1617. def create_bitmap
  1618. self.bitmap = Cache.battler(GALVFIGHT::SKILLIMAGE, 0)
  1619. @cw = bitmap.width / GALVFIGHT::SKILLCOLS
  1620. @ch = bitmap.height / GALVFIGHT::SKILLROWS
  1621. self.ox = @cw / 2
  1622. self.oy = @ch
  1623. self.mirror = @owner.fight_x > @target.fight_x ? false : true
  1624. end
  1625.  
  1626. def update_src_rect
  1627. if @pattern >= GALVFIGHT::SKILLCOLS
  1628. @pattern = 0
  1629. end
  1630. sx = @pattern * @cw
  1631. sy = @pose * @ch
  1632. self.src_rect.set(sx, sy, @cw, @ch)
  1633. end
  1634.  
  1635. def update_anim
  1636. @speed_timer += 1
  1637. if @speed_timer > 6
  1638. @pattern += 1
  1639. @speed_timer = 0
  1640. end
  1641. end
  1642.  
  1643. def update_position
  1644. self.x += self.mirror ? @skill.fproj[1] : [email protected][1]
  1645. self.opacity += 20
  1646. @range += 1
  1647. end
  1648.  
  1649. def make_animation_sprites
  1650. @ani_sprites = []
  1651. if !@@ani_spr_checker.include?(@animation)
  1652. 16.times do
  1653. sprite = ::Sprite.new(viewport)
  1654. sprite.visible = false
  1655. @ani_sprites.push(sprite)
  1656. end
  1657. if @animation.position == 3
  1658. @@ani_spr_checker.push(@animation)
  1659. end
  1660. end
  1661. @ani_duplicated = @@ani_checker.include?(@animation)
  1662. if !@ani_duplicated && @animation.position == 3
  1663. @@ani_checker.push(@animation)
  1664. end
  1665. end
  1666.  
  1667. def dispose; super; end
  1668.  
  1669. def finished?; @range >= @range_limit; end
  1670.  
  1671. def in_range_x; (@target.fight_x - self.x).abs < @reach; end
  1672. def in_range_y; (@target.fight_y - self.y).abs < @reach + 60; end
  1673.  
  1674. def make_contact?; return true if in_range_x && in_range_y; end
  1675.  
  1676. def update_hit
  1677. if make_contact?
  1678. @owner.proj_hit(@skill)
  1679. @range = @range_limit
  1680. end
  1681. end
  1682. end # FightProjectile < Sprite_Base
Advertisement
Add Comment
Please, Sign In to add comment