Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # XAS - Blood Effects
- #===============================================================================
- # by Mr_Wiggles
- # Version 2.3
- # 4/28/11
- #===============================================================================
- module Blood
- #-------------------------------------------------------------------------------
- # Blood splatter effects
- #-------------------------------------------------------------------------------
- # Number of seconds blood is shown for
- BLOOD_EARASE_TIME = 10
- # Make the blood slightly see through? (0 - 255)
- BLOOD_OPACITY = 180
- #-------------------------------------------------------------------------------
- # Monster blood colors. when A; return B ("A" monster ID, "B" hue [0 - 350] )
- # Hue colors: 0 = red; 40 = yellow; 120 = green; 190 = sky blue;
- # 220 = navy blue; 260 = purple; 310 = pink; 350 = red
- # (same for actors but id's are negative, so actor 4 is id -4)
- def blood_hues(id)
- case id
- # when (enemy id) then return (Hue value)
- when 2 then return 180
- when 5 then return 40
- else # this will return the default blood color
- return 0
- end
- end
- #-------------------------------------------------------------------------------
- # Monster blood character set.
- def blood_name(id)
- case id
- # when (enemy id) then return (IMG name)
- when 1 then return "Blood" #Ciructs
- else # Default IMG name
- return "Blood"
- end
- end
- end
- #-------------------------------------------------------------------------------
- # Tool id's that dont cause bleeding.
- NO_BLOOD_TOOL = []
- # Enemies that dont cause bleeding. (actor id's are negative)
- NO_BLOOD_ENEMY = []
- #-------------------------------------------------------------------------------
- # Blood screen effects
- #-------------------------------------------------------------------------------
- # Use screen blood effects
- USE_BLOODY_SCREEN = true
- # Number of seconds before blood fades off of screen
- BLOOD_DURATION = 10
- # Opacity of blood splatters on screen
- BLOOD_SCREEN_OPACITY = 200
- # Name of picture used for blood splaters
- BLOOD_SHEET = "Blood_Sheet"
- #===============================================================================
- # XRXS Battler Attachment
- #===============================================================================
- module XRXS_BattlerAttachment
- alias :be_action_effect :action_effect
- def self.action_effect(bullet, action_id)
- eff = be_action_effect(bullet, action_id)
- user = bullet.action.user
- skill = $data_skills[action_id]
- return if user.nil? or skill.nil?
- make_be = true
- if self.battler.is_a?(Game_Enemy) and
- (XAS_BA_ENEMY::ENEMY_OBJECT.include?(self.id) or
- XAS_BA_ENEMY::ITEM_ENEMY.include?(self.id))
- make_be = false
- end
- if make_be and !NO_BLOOD_TOOL.include?(skill.id)
- be_make_effect(user, skill)
- end
- return eff
- end
- alias :be_attack_effect :attack_effect
- def attack_effect(attacker)
- eff = be_attack_effect(attacker)
- make_be = true
- if self.battler.is_a?(Game_Enemy) and
- (XAS_BA_ENEMY::ENEMY_OBJECT.include?(self.id) or
- XAS_BA_ENEMY::ITEM_ENEMY.include?(self.id))
- make_be = false
- end
- if make_be and !NO_BLOOD_ENEMY.include?(attacker.id)
- be_make_effect(attacker)
- end
- return eff
- end
- end
- #===============================================================================
- # Game Character
- #===============================================================================
- class Game_Player < Game_Character
- def be_make_effect(user, skill = nil)
- @be_old_hp = 0 if @be_old_hp.nil?
- self_id = self.battler.id
- self_id *= -1 if self.battler.is_a?(Game_Actor)
- user_id = user.battler.id.to_i
- self_id *= -1 if user.battler.is_a?(Game_Actor)
- if @be_old_hp != self.battler.hp and (@be_old_hp - self.battler.hp > 0)
- SceneManager.scene.make_blood_effect(@real_x, @real_y, self_id)
- end
- @be_old_hp = self.battler.hp
- end
- end
- #===============================================================================
- # Blood Screen
- #===============================================================================
- class Bloody_Window < Window_Base
- def initialize
- super(-20, -20, 700, 600)
- self.contents = Bitmap.new(width - 32, height - 32)
- self.opacity = 0
- self.z = 900
- @blood_graphics = []
- @blood_sheet = Cache.picture("blood_sheet")
- @wt = @blood_sheet.width / 4
- @ht = @blood_sheet.height / 4
- update
- end
- def refresh
- self.contents.clear
- for blood in @blood_graphics
- rect = Rect.new(@wt * blood[2][0], blood[2][1] * @ht, @wt, @ht)
- self.contents.blt(blood[0], blood[1], @blood_sheet, rect, blood[4])
- end
- end
- def make_random_blood
- loop do
- stop_loop = true
- x = (rand(50) * 10) + 20
- y = (rand(40) * 10) + 20
- n = [rand(2)+rand(2), rand(2)+rand(2)]
- @blood_graphics.each {|b| stop_loop = false if b[2] == n}
- if stop_loop
- @blood_graphics.push([x, y, n, BLOOD_DURATION * 8, BLOOD_SCREEN_OPACITY])
- break
- end
- end
- end
- def update
- @actor = $game_party.members[0]
- @old_player_hp = @actor.hp if @old_player_hp.nil?
- if @old_player_hp != @actor.hp
- make_random_blood if (@old_player_hp - @actor.hp > 0)
- @old_player_hp = @actor.hp
- end
- return if @blood_graphics.empty?
- @blood_graphics.each {|blood| update_blood(blood)}
- refresh
- end
- def update_blood(blood)
- if blood[4] == 0
- @blood_graphics.delete(blood)
- return
- end
- blood[3] -= 5 if blood[3] > 0
- blood[4] -= 5 if blood[4] > 0 and blood[3] <= BLOOD_SCREEN_OPACITY
- end
- end
- #==============================================================================
- # Scene Map
- #==============================================================================
- class Scene_Map
- alias blood_window_main main
- def main
- if USE_BLOODY_SCREEN
- @blood_window = Bloody_Window.new
- @blood_update_pause = 5
- end
- blood_window_main
- @blood_window.dispose if USE_BLOODY_SCREEN
- end
- alias blood_window_update update
- def update
- blood_window_update
- return if @blood_update_pause.nil?
- @blood_update_pause -= 1 if @blood_update_pause > 0
- return if @blood_update_pause > 0
- @blood_window.update; @blood_update_pause = 5
- end
- def make_blood_effect(*args)
- @spriteset.make_blood_effect(*args)
- end
- end
- #==============================================================================
- # Spriteset Map
- #==============================================================================
- class Spriteset_Map
- alias :blood_effects_init :initialize
- def initialize
- @blood = []
- blood_effects_init
- end
- def make_blood_effect(x, y, id)
- @blood.push(Sprite_Blood.new(@viewport1, x, y, id))
- end
- alias :blood_effects_up :update
- def update
- blood_effects_up
- @blood.each{|blood| blood.update if !blood.disposed?}
- end
- alias :blood_effects_dis :dispose
- def dispose
- blood_effects_dis
- @blood.each{|blood| blood.dispose if !blood.disposed?}
- end
- end
- #==============================================================================
- # Sprite Blood
- #==============================================================================
- class Sprite_Blood < Sprite_Base
- include Blood
- def initialize(viewport, x, y, id)
- super(viewport)
- @x, @y, @id = x, y, id
- @duration = (BLOOD_EARASE_TIME * 40) + BLOOD_OPACITY
- set = blood_name(@id)
- bit = Cache.character(set, blood_hues(@id)) rescue nil
- if bit.nil?
- $blood_fails = [] if $blood_fails.nil?
- unless $blood_fails.include?(set)
- $blood_fails.push(set)
- print("Blood effect character set \"#{set}\" was not found!")
- end
- self.dispose
- return
- end
- self.bitmap = bit
- @cw, @ch = bitmap.width / 4, bitmap.height / 4
- sx, sy = rand(4) * @cw, rand(4) * @ch
- self.src_rect.set(sx, sy, @cw, @ch)
- self.opacity = BLOOD_OPACITY
- self.x = screen_x
- self.y = screen_y
- self.z = 1
- update
- end
- def screen_x
- return (@x - $game_map.display_x) / 4
- end
- def screen_y
- return (@y - $game_map.display_y) / 4
- end
- def update
- self.x = screen_x
- self.y = screen_y
- @duration -= 1
- self.opacity -= 1 if BLOOD_OPACITY <= @duration
- self.dispose if @duration == 0
- end
- end
RAW Paste Data