Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[DONE!]Blood Splatter effect for Last Man's Stand

As many of you know now, I am making a zombie shooting game called Last Man's Stand (see signature) that uses my own evented battle system. You can't have a shooting game without blood effects. I am requesting a script that splatters blood behind the character/enemy when they are hit. I know that this can be done with events (and I know that it has been done before), but I want the blood splatters to stay where they are for a few minutes, before they fade away. I already have a blood characterset to use:
http://img362.imageshack.us/img362/4027 ... od1lt8.png[/img]
(not mine)

Let me explain how I would like it to work:
You shoot the enemy (or the enemy bites you) and one of those blood tiles appear one tile behind the enemy. It then stays there for about 1 and a half minutes, before it slowly starts to fade away. It should be so blood stains continue to appear everytime you shoot the enemy. The battle system is already made, so it would be perfect if a blood splatter could appear every time you called the script:

$game = blood.new

or something like that. But if that is asking to much, just the system will be fine.

Thanks.
 
I think the 'right' way to do this would be to just create a new Sprite object with each hit. The object would be defined within the scope of the scene (Scene_Map), so if the map goes out of scope before the sprites are finished fading, the sprites would also be disposed. then we just set a 'age' parameter on the sprite. At a certain 'age' (in seconds), we start to fade, and when the fade is done, we dispose the sprite.
We could also randomize the cell from the character set above that gets displayed with each sprite.

In it's simplest form, you would call...

$scene.bloodsprite(x, y)

Where x, y is the map location. (duration, randomization, etc... would be hard coded, and you provide the target tile to display the sprite. i.e the tile behind/beyond the character getting hit.)

Give me a little time to work on this, and I'll post something later.
 
Brewmeister":13m3bz85 said:
I think the 'right' way to do this would be to just create a new Sprite object with each hit. The object would be defined within the scope of the scene (Scene_Map), so if the map goes out of scope before the sprites are finished fading, the sprites would also be disposed. then we just set a 'age' parameter on the sprite. At a certain 'age' (in seconds), we start to fade, and when the fade is done, we dispose the sprite.
We could also randomize the cell from the character set above that gets displayed with each sprite.

In it's simplest form, you would call...

$scene.bloodsprite(x, y)

Where x, y is the map location. (duration, randomization, etc... would be hard coded, and you provide the target tile to display the sprite. i.e the tile behind/beyond the character getting hit.)

Give me a little time to work on this, and I'll post something later.

And somebody finally posts an intelligent, script-related answer. That's exactly how you'd do it, although if you wanted one to appear with every shot, it would have to have a self-timer in an update method. Easily done, and fairly easily used. The real problem with this would be choosing the proper graphic to use, or at least rotating the graphic to the proper position.
 
I Think I had the same idea reading through the posts. Though I'm not hip with the lingo so I'll be suggesting it in laymen terms. Pretty much you make the "Zombie" sprite larger than it is, and do graphics on the same sprite for multiple blood splatters on each Charset (having multiple charsets for each enemy). Then set it up so that IF bullet hits "This Event"(Zombie 1) who is facing Down, and if the bullet is its own event IF Bullet is facing up, then display graphic "Zombie_Facing_Down_WithABloodSplatterBehindHim.png". If the bullets didn't have they're own event you could base the second condition on which way the player is facing, though this may have blood spraying out at odd angles if you turn to quickly. This way you could also add in bullet-holes in the zombies if they get hit; with the approperate amount of blood behind them. You could also have a conditional branch for "If shotgun is equipped" and then swap to specific charsets with more gore.

Me being an idiot I only just realized the biggest problem with this.... being that the blood splatters would follow the zombies >.>. Ah well... perhaps with an event slicer script? *Cowers with hands above head* Please don't hit me!
 
@Brewmeister: Thanks alot. That's pretty much exactly what I need, so I'd be very greatful if you could get that to work.
@Glitchfinder: I should probably be able to handle the graphics for it, if I understand you correctly. Again, thanks for replying.
@Damaris: Yeah, it's a nice idea, but considering the already massive amount of eventing in each enemy, that would lag something terrible. And then there's the fact that the blood would walk around as well, as you said. But thanks for trying anyway.
 
I'll give it a try =)

/edit: I hope this is what you wanted:

Code:
#============================================================================

# ** Blood Splatter

#----------------------------------------------------------------------------

# Neo-Bahamut

# V 1.0

# 30.05.2009

#----------------------------------------------------------------------------

# This script lets you add blood to the map.

# To add a splatter call (in a call script) add_blood_splatter(splatter)

# splatter has to be an instance of Game_BloodSplatter.

# splatter.setup has to be called before.

#============================================================================

 

module NeoBahamutBloodSplatterOptions

  

  # The graphics of the blood (Graphics/Blood Splatter/)

  Blood = ["chablood1lt8"]

  

  # Frames the blood needs to fade

  Fade_Time = 60

  

end

 

#=============================================================================

# ** Game_BloodSplatter

#-----------------------------------------------------------------------------

#  This class holds the data of a BloodSplatter.

#=============================================================================

 

class Game_BloodSplatter

  

  attr_reader :bitmap

  attr_reader :active

  attr_reader :x

  attr_reader :y

  attr_reader :opacity

  

  def initialize

    @graphics = NeoBahamutBloodSplatterOptions::Blood

    @fade = NeoBahamutBloodSplatterOptions::Fade_Time

    @x = 0

    @y = 0

    @opacity = 0

  end

  

  def setup(x, y, graphic = rand(@graphics.size))

    @x = x

    @y = y

    @bitmap = graphic

    @active = true

    @opacity = 255

  end

  

  def update

    return if !@active

    @active = false if @opacity <= 0

    time = 255.0/@fade

    @opacity -= time

  end

  

end

 

#=============================================================================

# ** Sprite_BloodSplatter

#-----------------------------------------------------------------------------

#  This class displays a Sprite with blood onto the map.

#=============================================================================

 

class Sprite_BloodSplatter < Sprite

  

  def initialize(game, viewport)

    @game = game

    super(viewport)

    options = NeoBahamutBloodSplatterOptions::Blood

    self.bitmap = RPG::Cache.blood(options[@game.bitmap])

  end

  

  def update

    return if !@game.active

    self.x = @game.x - $game_map.display_x/4

    self.y = @game.y - $game_map.display_y/4

    self.z = 0

    self.opacity = @game.opacity

  end

  

end

 

class Game_Map

  

  attr_accessor :blood_splatter

  

  alias_method :neo_bahamut_alias_blood_splatter_game_map_setup, :setup

  alias_method :neo_bahamut_alias_blood_splatter_game_map_update, :update

  

  def setup(*args)

    neo_bahamut_alias_blood_splatter_game_map_setup(*args)

    @blood_splatter = []

  end

  

  def update(*args)

    neo_bahamut_alias_blood_splatter_game_map_update(*args)

    dispose = []

    @blood_splatter.each {|i| i.update; if !i.active then dispose << i end}

    dispose.each {|i| @blood_splatter.delete(i)}

  end

  

end

 

 

class Spriteset_Map

  

  alias_method :neo_bahamut_alias_blood_splatter_spriteset_map_initialize, :initialize

  alias_method :neo_bahamut_alias_blood_splatter_spriteset_map_dispose, :dispose

  alias_method :neo_bahamut_alias_blood_splatter_spriteset_map_update, :update

  

  def initialize(*args)

    @blood_splatter = []

    neo_bahamut_alias_blood_splatter_spriteset_map_initialize(*args)

  end

  

  def dispose(*args)

    neo_bahamut_alias_blood_splatter_spriteset_map_dispose(*args)

    @blood_splater.each {|i| i.dispose}

  end

  

  def update(*args)

    neo_bahamut_alias_blood_splatter_spriteset_map_update(*args)

    dispose = []

    @blood_splatter.each {|i| if i.disposed? then dispose << i else i.update end}

    dispose.each {|i| @blood_splatter.delete(i)}

  end

  

  def add_blood_splatter(sprite)

    @blood_splatter << sprite

  end

  

end

 

 

class Scene_Map

  attr_reader :spriteset

end

class Spriteset_Map

  attr_reader :viewport1

end

 

class Interpreter

  

  def add_blood_splatter(splatter)

    spriteset = $scene.spriteset

    sprite = Sprite_BloodSplatter.new(splatter, spriteset.viewport1)

    $game_map.blood_splatter << splatter

    spriteset.add_blood_splatter(sprite)

  end

  

end

 

 

module RPG::Cache

  def self.blood(filename)

    self.load_bitmap("Graphics/Blood Splatter/", filename)

  end

end

There is one bug and I don't know how to fix it :/
The blood is over all tiles with priority 0 even stones and such things :/
 
Hey Neo-Bahamut I dont understand how to set up the coding on the map itself to call the bloodsplatter. I might use this for my next project when finished with falloftheliving

can you give an example coding?
 
I can, since I'm using it.

In an event, get the call script box up, then copy and paste this into it:

splatter = Game_BloodSplatter.new
splatter.setup(x,y)
add_blood_splatter(splatter)

x and y obviously correspond to where in pixels you want the blood to be. Hope that helps.

Oh, and since the forums messed up, I never thanked Neo-Bahamut. So yeah, thanks man.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top