Vlue

Critical Flash + SE

Aug 5th, 2012
2,162
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Critical Flash + Sound Effect v1.3
  2. #----------#
  3. #Features: Provides the ability to have the screen flash and a se to play
  4. #          upon any critical strike
  5. #
  6. #Usage:    None! Plug and play.
  7. #
  8. #Customization follows in the script, can edit filename, volume and pitch of se
  9. #   and color and duration of flash
  10. #----------#
  11. #-- Script by: V.M of D.T
  12. #
  13. #- Questions or comments can be:
  14. #    given by email: sumptuaryspade@live.ca
  15. #    provided on facebook: http://www.facebook.com/DaimoniousTailsGames
  16. #   All my other scripts and projects can be found here: http://daimonioustails.weebly.com/
  17. #
  18. #--- Free to use in any project, commercial or non-commercial, with credit given
  19. # - - Though a donation's always a nice way to say thank you~ (I also accept actual thank you's)
  20.  
  21.  
  22. #class Scene_Battle < Scene_Base
  23. class Game_Battler < Game_BattlerBase
  24.   #---------#
  25.   #PLAYSE to true to play SE. Filename (in quotes), Volume (0-100), Pitch, (0-150)
  26.   #---------#
  27.   PLAYSE       = true
  28.   CSE_FILENAME = "Skill3"
  29.   CSE_VOLUME   = 100
  30.   CSE_PITCH    = 100
  31.  
  32.   #Here we go if you wish to have a random assortment of Se's play:
  33.   USE_RANDOM   = false
  34.   #Array format: [ [ "filename" , volume , pitch ] , ]
  35.   RANDOM_SE    = [["Skill1",100,100],["Skill2",100,100],["Skill3",100,100]]
  36.   #---------#
  37.   #FLASH to true to execute flash
  38.   #Color in (Red,Green,Blue,Alpha) format (0-255), Duration in frames
  39.   #---------#
  40.   FLASH        = true
  41.   FLASHCOLOR   = Color.new(255,255,255,255)
  42.   FLASHDURAT   = 30
  43.  
  44.   #Want to set it up so you have to time a button press to land a critical?
  45.   #Well some people do, and for you people, there's this:
  46.   #Total time is time to press button and min <> max is window to press it right
  47.   PRESS_FOR_CRITICAL = false
  48.   TOTAL_TIME_TO_PRESS = 30
  49.   MIN_TIME_FOR_CRIT = 10
  50.   MAX_TIME_FOR_CRIT = 20
  51.   CRIT_INPUT_TRIGGER = :C
  52.   #---------#END
  53.   alias crit_item_apply item_apply
  54.   def item_apply(user, item)
  55.     if self.is_a?(Game_Actor)
  56.       crit_item_apply(user,item)
  57.     else
  58.       @result.clear
  59.       if PRESS_FOR_CRITICAL
  60.         TOTAL_TIME_TO_PRESS.times do |i|
  61.           Input.update
  62.           Graphics.update
  63.           if(Input.trigger?(CRIT_INPUT_TRIGGER))
  64.             if i > MIN_TIME_FOR_CRIT && i < MAX_TIME_FOR_CRIT
  65.               @result.critical = true
  66.             end
  67.             break
  68.           end
  69.         end
  70.       end
  71.       @result.used = item_test(user, item)
  72.       @result.missed = (@result.used && rand >= item_hit(user, item))
  73.       @result.evaded = (!@result.missed && rand < item_eva(user, item))
  74.       if @result.hit?
  75.         unless item.damage.none?
  76.           @result.critical = (rand < item_cri(user, item)) unless PRESS_FOR_CRITICAL
  77.           make_damage_value(user, item)
  78.           execute_damage(user)
  79.         end
  80.         item.effects.each {|effect| item_effect_apply(user, item, effect) }
  81.         item_user_effect(user, item)
  82.       end
  83.     end
  84.     play_critical_flash if @result.critical
  85.   end
  86.   def play_critical_flash
  87.     $game_troop.screen.start_flash(FLASHCOLOR, FLASHDURAT) if FLASH
  88.     play_critical_se if PLAYSE
  89.   end
  90.   def play_critical_se
  91.     if !USE_RANDOM
  92.       Audio.se_play('Audio/SE/' + CSE_FILENAME,CSE_VOLUME,CSE_PITCH)
  93.     else
  94.       id = rand(RANDOM_SE.size)
  95.       Audio.se_play("Audio/SE/" + RANDOM_SE[id][0],RANDOM_SE[id][1],RANDOM_SE[id][2])
  96.     end
  97.   end
  98. end
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×