Advertisement
Scinaya

Fancy Deaths (English) by Shanghai

Apr 28th, 2011
1,285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 12.80 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # Shanghai Simple Script - Fancy Deaths
  4. # Last Date Updated: 2010.05.09
  5. # Level: Normal
  6. #
  7. # This makes certain enemies die a fancy way if they have the fancy death tags
  8. # inside of their notebox. These were made for the default animations. If you
  9. # are using different animations, you can change the IDs these fancy deaths use.
  10. # Works for default battle system, Battle Engine Melody, and Tankentai.
  11. #===============================================================================
  12. # Instructions
  13. # -----------------------------------------------------------------------------
  14. # To install this script, open up your script editor and copy/paste this script
  15. # to an open slot below ▼ Materials but above ▼ Main. Remember to save.
  16. #
  17. # <fancy death: string>
  18. # Replace string with one of the ones below:
  19. # fire  - Makes the enemy die in a fancy fiery death.
  20. # ice   - Makes the enemy freeze and die.
  21. # elec  - Makes the enemy spark and die.
  22. # water - Makes the enemy melt and die.
  23. # stone - Makes the enemy change to stone.
  24. # wind  - Makes the enemy vanish with the wind.
  25. # holy  - Makes the enemy disappear into light.
  26. # dark  - Makes the enemy disappear into darkness.
  27. #===============================================================================
  28.  
  29. $imported = {} if $imported == nil
  30. $imported["FancyDeaths"] = true
  31.  
  32. module SSS
  33.   # Fiery death animation IDs.
  34.   FIERY_DEATH_ANI1 = 2
  35.   FIERY_DEATH_ANI2 = 79
  36.   # Icy death animation IDs.
  37.   ICY_DEATH_ANI1 = 62
  38.   ICY_DEATH_ANI2 = 3
  39.   # Electric death animation IDs.
  40.   ELECTRIC_DEATH_ANI1 = 18
  41.   ELECTRIC_DEATH_ANI2 = 4
  42.   # Watery death animation ID.
  43.   WATERY_DEATH_ANI = 69
  44.   # Stone death animation ID.
  45.   STONE_DEATH_ANI = 40
  46.   # Wind death animation ID.
  47.   WINDY_DEATH_ANI1 = 73
  48.   WINDY_DEATH_ANI2 = 31
  49.   # Holy death animation ID.
  50.   HOLY_DEATH_ANI1 = 42
  51.   HOLY_DEATH_ANI2 = 75
  52.   # Dark death animation ID.
  53.   DARK_DEATH_ANI1 = 77
  54.   DARK_DEATH_ANI2 = 51
  55. end
  56.  
  57. #==============================================================================
  58. # RPG::Enemy
  59. #==============================================================================
  60.  
  61. class RPG::Enemy
  62.   #--------------------------------------------------------------------------
  63.   # fancy death
  64.   #--------------------------------------------------------------------------
  65.   def fancy_death
  66.     return @fancy_death if @fancy_death != nil
  67.     @fancy_death = 0
  68.     self.note.split(/[\r\n]+/).each { |line|
  69.       case line
  70.       when /<(?:FANCY_DEATH|fancy death):[ ](.*)>/i
  71.         case $1.upcase
  72.         when "FIRE"
  73.           @fancy_death = 1
  74.         when "ICE"
  75.           @fancy_death = 2
  76.         when "ELEC"
  77.           @fancy_death = 3
  78.         when "WATER"
  79.           @fancy_death = 4
  80.         when "STONE"
  81.           @fancy_death = 5
  82.         when "WIND"
  83.           @fancy_death = 6
  84.         when "HOLY"
  85.           @fancy_death = 7
  86.         when "DARK"
  87.           @fancy_death = 8
  88.         end
  89.       end
  90.     }
  91.     return @fancy_death
  92.   end
  93. end
  94.  
  95. #==============================================================================
  96. # ** Sprite_Battler
  97. #==============================================================================
  98.  
  99. class Sprite_Battler < Sprite_Base
  100.   #--------------------------------------------------------------------------
  101.   # * Public Instance Variables
  102.   #--------------------------------------------------------------------------
  103.   attr_accessor :effect_duration
  104.   #--------------------------------------------------------------------------
  105.   # * Set New Effect
  106.   #--------------------------------------------------------------------------
  107.   alias setup_new_effect_sss_fancy_deaths setup_new_effect unless $@
  108.   def setup_new_effect
  109.     if @battler.collapse and @battler.is_a?(Game_Enemy)
  110.       if @battler.enemy.fancy_death > 0
  111.         @battler.collapse = false
  112.         @battler_visible = false
  113.         case @battler.enemy.fancy_death
  114.         when 1 # Fiery Death
  115.           @effect_type = 574897410001
  116.           @effect_duration = 169
  117.           return
  118.         when 2 # Icy Death
  119.           @effect_type = 574897410002
  120.           @effect_duration = 125
  121.           return
  122.         when 3 # Electric Death
  123.           @effect_type = 574897410003
  124.           @effect_duration = 97
  125.           return
  126.         when 4 # Watery Death
  127.           @effect_type = 574897410004
  128.           @effect_duration = 101
  129.           return
  130.         when 5 # Stone Death
  131.           @effect_type = 574897410005
  132.           @effect_duration = 81
  133.           return
  134.         when 6 # Windy Death
  135.           @effect_type = 574897410006
  136.           @effect_duration = 91
  137.           return
  138.         when 7 # Holy Death
  139.           @effect_type = 574897410007
  140.           @effect_duration = 106
  141.           return
  142.         when 8 # Dark Death
  143.           @effect_type = 574897410008
  144.           @effect_duration = 91
  145.           return
  146.         end
  147.       end
  148.     end
  149.     setup_new_effect_sss_fancy_deaths
  150.   end
  151.   #--------------------------------------------------------------------------
  152.   # * Update Effect
  153.   #--------------------------------------------------------------------------
  154.   alias update_effect_sss_fancy_deaths update_effect unless $@
  155.   def update_effect
  156.     if @effect_duration > 0
  157.       case @effect_type
  158.       when 574897410001
  159.         update_fiery_death
  160.         return
  161.       when 574897410002
  162.         update_icy_death
  163.         return
  164.       when 574897410003
  165.         update_electric_death
  166.         return
  167.       when 574897410004
  168.         update_watery_death
  169.         return
  170.       when 574897410005
  171.         update_stone_death
  172.         return
  173.       when 574897410006
  174.         update_windy_death
  175.         return
  176.       when 574897410007
  177.         update_holy_death
  178.         return
  179.       when 574897410008
  180.         update_dark_death
  181.         return
  182.       end
  183.     end
  184.     update_effect_sss_fancy_deaths
  185.   end
  186.   #--------------------------------------------------------------------------
  187.   # * Start Death Animation
  188.   #--------------------------------------------------------------------------
  189.   def start_death_animation(animation, mirror)
  190.     if $imported["BattleEngineMelody"]
  191.       start_sub_animation(animation, mirror)
  192.     else
  193.       start_animation(animation, mirror)
  194.     end
  195.   end
  196.   #--------------------------------------------------------------------------
  197.   # * Update Fiery Death
  198.   #--------------------------------------------------------------------------
  199.   def update_fiery_death
  200.     @effect_duration -= 1
  201.     self.blend_type = 1
  202.     case @effect_duration
  203.     when 168, 138, 108, 78
  204.       self.color.set(255, 128, 128, 128)
  205.       start_death_animation($data_animations[SSS::FIERY_DEATH_ANI1], false)
  206.     when 48
  207.       start_death_animation($data_animations[SSS::FIERY_DEATH_ANI2], false)
  208.     when 0..47
  209.       self.opacity = 256 - (48 - @effect_duration) * 6
  210.     end
  211.   end
  212.   #--------------------------------------------------------------------------
  213.   # * Update Icy Death
  214.   #--------------------------------------------------------------------------
  215.   def update_icy_death
  216.     @effect_duration -= 1
  217.     self.blend_type = 1
  218.     case @effect_duration
  219.     when 124
  220.       self.color.set(128, 128, 255, 128)
  221.       start_death_animation($data_animations[SSS::ICY_DEATH_ANI1], false)
  222.     when 48
  223.       start_death_animation($data_animations[SSS::ICY_DEATH_ANI2], false)
  224.     when 0..47
  225.       self.opacity = 256 - (48 - @effect_duration) * 6
  226.     end
  227.   end
  228.   #--------------------------------------------------------------------------
  229.   # * Update Electric Death
  230.   #--------------------------------------------------------------------------
  231.   def update_electric_death
  232.     @effect_duration -= 1
  233.     self.blend_type = 1
  234.     case @effect_duration
  235.     when 96
  236.       self.color.set(255, 255, 128, 128)
  237.       start_death_animation($data_animations[SSS::ELECTRIC_DEATH_ANI1], false)
  238.     when 48
  239.       start_death_animation($data_animations[SSS::ELECTRIC_DEATH_ANI2], false)
  240.     when 0..47
  241.       self.opacity = 256 - (48 - @effect_duration) * 6
  242.     end
  243.   end
  244.   #--------------------------------------------------------------------------
  245.   # * Update Watery Death
  246.   #--------------------------------------------------------------------------
  247.   def update_watery_death
  248.     @effect_duration -= 1
  249.     self.blend_type = 1
  250.     case @effect_duration
  251.     when 100
  252.       self.color.set(64, 64, 255, 128)
  253.       self.wave_amp = 10
  254.       self.wave_speed = 3600
  255.     when 61..99
  256.       self.wave_speed += 100
  257.     when 60
  258.       start_death_animation($data_animations[SSS::WATERY_DEATH_ANI], false)
  259.     when 0..47
  260.       self.opacity = 256 - (48 - @effect_duration) * 6
  261.     end
  262.   end
  263.   #--------------------------------------------------------------------------
  264.   # * Update Stone Death
  265.   #--------------------------------------------------------------------------
  266.   def update_stone_death
  267.     @effect_duration -= 1
  268.     case @effect_duration
  269.     when 80
  270.       start_death_animation($data_animations[SSS::STONE_DEATH_ANI], false)
  271.     when 0..79
  272.       opacity = [(80 - @effect_duration) * 4, 200].min
  273.       self.color.set(200, 200, 200, opacity)
  274.     end
  275.   end
  276.   #--------------------------------------------------------------------------
  277.   # * Update Windy Death
  278.   #--------------------------------------------------------------------------
  279.   def update_windy_death
  280.     @effect_duration -= 1
  281.     self.blend_type = 1
  282.     case @effect_duration
  283.     when 90
  284.       self.color.set(128, 255, 128, 128)
  285.       start_death_animation($data_animations[SSS::WINDY_DEATH_ANI1], false)
  286.     when 45
  287.       start_death_animation($data_animations[SSS::WINDY_DEATH_ANI2], false)
  288.       self.visible = false
  289.     when 0
  290.       self.opacity = 0
  291.       self.visible = true
  292.     end
  293.   end
  294.   #--------------------------------------------------------------------------
  295.   # * Update Holy Death
  296.   #--------------------------------------------------------------------------
  297.   def update_holy_death
  298.     @effect_duration -= 1
  299.     self.blend_type = 1
  300.     case @effect_duration
  301.     when 105
  302.       self.color.set(255, 255, 255, 128)
  303.       start_death_animation($data_animations[SSS::HOLY_DEATH_ANI1], false)
  304.     when 45
  305.       start_death_animation($data_animations[SSS::HOLY_DEATH_ANI2], false)
  306.     when 0..44
  307.       self.opacity = 256 - (48 - @effect_duration) * 6
  308.     end
  309.   end
  310.   #--------------------------------------------------------------------------
  311.   # * Update Dark Death
  312.   #--------------------------------------------------------------------------
  313.   def update_dark_death
  314.     @effect_duration -= 1
  315.     self.blend_type = 1
  316.     case @effect_duration
  317.     when 90
  318.       self.color.set(0, 0, 0, 128)
  319.       start_death_animation($data_animations[SSS::DARK_DEATH_ANI1], false)
  320.     when 60
  321.       self.visible = false
  322.     when 45
  323.       start_death_animation($data_animations[SSS::DARK_DEATH_ANI2], false)
  324.     when 0
  325.       self.opacity = 0
  326.       self.visible = true
  327.     end
  328.   end
  329. end
  330.  
  331. #==============================================================================
  332. # ** Spriteset_Battle
  333. #==============================================================================
  334.  
  335. class Spriteset_Battle
  336.   #--------------------------------------------------------------------------
  337.   # * Public Instance Variables
  338.   #--------------------------------------------------------------------------
  339.   attr_accessor :enemy_sprites
  340. end
  341.  
  342. #==============================================================================
  343. # ** Scene_Battle
  344. #==============================================================================
  345.  
  346. class Scene_Battle < Scene_Base
  347.   #--------------------------------------------------------------------------
  348.   # * wait_for_deaths
  349.   #--------------------------------------------------------------------------
  350.   def wait_for_deaths
  351.     update_basic
  352.     loop do
  353.       amount = 0
  354.       for sprite in @spriteset.enemy_sprites
  355.         amount += 1 if sprite.effect_duration <= 0
  356.       end
  357.       break if amount >= @spriteset.enemy_sprites.size
  358.       update_basic
  359.     end
  360.   end
  361.   #--------------------------------------------------------------------------
  362.   # * Process Victory
  363.   #--------------------------------------------------------------------------
  364.   alias process_victory_sss_fancy_deaths process_victory unless $@
  365.   def process_victory
  366.     if $imported["BattleEngineMelody"]
  367.       @judge_win_loss = true
  368.       pause_atb(true, true)
  369.       @enemy_gauge_window.dispose if @enemy_gauge_window != nil
  370.       @hide_battlecursor = true
  371.       @party_input_flag = true
  372.       @message_window.visible = true
  373.     end
  374.     wait_for_deaths
  375.     process_victory_sss_fancy_deaths
  376.   end
  377. end
  378.  
  379. #===============================================================================
  380. #
  381. # END OF FILE
  382. #
  383. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement