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.

Multiple Poisons

Multiple Poisons
Version: 1.1.0

Introduction

This script allows a game to have different types of poisons. Whether the poison is a minor infection, or a serious disease, this script will suit your need for poisons.

Features

  • Plug-and-play!
  • Easy to make new poison damages
  • Can set a negative damage to get a curative state!
  • Damage is taken for all poison states, not just one
  • Damage can be taken from HP or SP

Screenshots

No screenshots needed.

Demo

No demo needed. Script is plug and play.

Script

Code:
#==============================================================================
#  ** Multiple Poisons
#------------------------------------------------------------------------------
#  Scripted by: Yeyinde
#  Version 1.1.0
#  February 1 & 2, 2007
#==============================================================================

#--------------------------------------------------------------------------
# * Initialize Constants
#--------------------------------------------------------------------------

SP_POISONS = [] # Add the state ids of SP draining poisons here
BATTLE_DAMAGE = {} # Format: state_id => damage_division
BATTLE_DAMAGE.default = 10 # Do not change
MAP_DAMAGE = {} # Format: state_id => damage_division
MAP_DAMAGE.default = 100 # Do not change

# Damage correction (To prevent /0 errors)
# DO NOT EDIT!
BATTLE_DAMAGE.each do |state_id, damage|
  BATTLE_DAMAGE[state_id] = BATTLE_DAMAGE.default if damage == 0
end
MAP_DAMAGE.each do |state_id, damage|
  MAP_DAMAGE[state_id] = MAP_DAMAGE.default if damage == 0
end

#==============================================================================
# ** Game_Battler
#------------------------------------------------------------------------------
#  This class deals with battlers. It's used as a superclass for the Game_Actor
#  and Game_Enemy classes.
#==============================================================================

class Game_Battler
  #--------------------------------------------------------------------------
  # * Application of Slip Damage Effects - Overwrite
  #--------------------------------------------------------------------------
  def slip_damage_effect
    # Set damage
    self.damage = 0
    sp_damage = 0
    # Branch per state held
    @states.each do |i|
      # If the state has slip damage
      if $data_states[i].slip_damage
        # Add to damage
        if SP_POISONS.include?(i)
          sp_damage += self.maxsp / BATTLE_DAMAGE[i]
        else
          self.damage += self.maxhp / BATTLE_DAMAGE[i]
        end
      end
    end
    # Dispersion
    if self.damage.abs > 0
      amp = [self.damage * 15 / 100, 1].max
      self.damage += rand(amp+1) + rand(amp+1) - amp
    end
    if sp_damage.abs > 0
      amp = [sp_damage * 15 / 100, 1].max
      sp_damage += rand(amp+1) + rand(amp+1) - amp
    end
    # Subtract damage from HP and SP
    self.hp -= self.damage
    self.sp -= sp_damage
    # End Method
    return true
  end
end


#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
#  This class handles the party. It includes information on amount of gold 
#  and items. Refer to "$game_party" for the instance of this class.
#==============================================================================

class Game_Party
  #--------------------------------------------------------------------------
  # * Slip Damage Check (for map) - Overwrite
  #--------------------------------------------------------------------------
  def check_map_slip_damage
    # Branch per actor
    @actors.each do |actor|
      # If actor has more than 0 HP and has a slip damage state
      if actor.hp > 0 and actor.slip_damage?
        # Set damage
        damage = 0
        sp_damage = 0
        # Branch per state held
        actor.states.each do |i|
          # If the state has slip damage
          if $data_states[i].slip_damage
            # Add to damage
            if SP_POISONS.include?(i)
              sp_damage += actor.maxsp / MAP_DAMAGE[i]
            else
              damage += actor.maxhp / MAP_DAMAGE[i]
            end
          end
        end
        # Take damage
        if damage > 0
          actor.hp -= [damage, 1].max
        elsif damage < 0
          actor.hp -= [damage, -1].min
        end
        # Take SP damage
        if sp_damage > 0
          actor.sp -= [sp_damage, 1].max
        elsif sp_damage < 0
          actor.sp -= [sp_damage, -1].min
        end
        # If the actor has no more HP
        if actor.hp == 0
          # Play the actor collapse SE
          $game_system.se_play($data_system.actor_collapse_se)
        end
        # Flash the screen to indicate damage
        if damage > 0 or sp_damage > 0
          $game_screen.start_flash(Color.new(255,0,0,128), 4)
        elsif damage < 0 or sp_damage < 0
          $game_screen.start_flash(Color.new(0,255,0,128), 4)
        end
        # Go to game over if the party is all dead
        $game_temp.gameover = $game_party.all_dead?
      end
    end
  end
end

Instructions

Insert the script into a new section above Main. Edit the BATTLE_DAMAGE and MAP_DAMAGE constant Hashes with the following format: {state_id => damage_division} where state_id is the ID of the status in the database(no leading 0s), and damage_division is the number which maxhp will be divided by to get the damage for that state (example: 100 = maxhp / 100, 25 = maxhp / 25)
If you want damage to be taken from the actor's SP, add the state id to the SP_POISONS constant array. (SP_POISONS = [3, 6] would make states 3 and 6 remove from SP)

FAQ

No questions asked.

Compatibility

Compatible with the SDK.
NOT COMPATIBLE WITH RTAB! DO NOT ASK FOR IT TO BE MADE COMPATIBLE!
 
Trickster is going to be mad at someone... >_<

Looks good Yeyinde. And I learned something new. I didn't know there was a default Hash#default method. I had wondered about that about a week ago, since I had plans on making a method like that myself. Hahaha!
 

Shiro

Member

Just a suggestion if you want to take it or not.

Could you do it that MP is damaged by poison? Such as every turn, you lose 10% of your MP? Also the opposite where you can put -10 for gaining 10% every turn.

Even if you don't use my suggestions, I'm still yanking this script (with full credits of course!). =) Awesome job.
 
SephirothSpawn;147001 said:
Trickster is going to be mad at someone... >_<

Of course I am, and just when I started to trust him, but well we said we wanted to see more from him so everything's okay. I really don't care about it.

SephirothSpawn;147001 said:
Looks good Yeyinde. And I learned something new. I didn't know there was a default Hash#default method. I had wondered about that about a week ago, since I had plans on making a method like that myself. Hahaha!

What in the world are you talking about, I knew about this months ago (Look at the Setup sections for any of my scripts ;), Yeyinde probably stole that from me as well XD) and I was going to post that information in your tutorial but I lost the post information

Also there is Hash.default_proc you define a proc object for what happens if the key doesn't exist in the hash, but you can only define it when creating a hash

Hash.new {|hash, key| do something with either}

but if you do that then you can't create a hash using the hash literal and still define the block, and there is no Hash#default_proc= method, but there is Hash#merge you can make use of. What I would do is create a dummy hash with the block and have the setup hash next merge the hash with the block with the setup hash, and there you have a hash with both of these properties.
(hash_with_block).merge(setup_hash)

Even if you don't use my suggestions, I'm still yanking this script (with full credits of course!). =) Awesome job.

YOU STEAL MY PRAISE YEYINDE :( Hey... wait a sec aren't you supposed to be using a script I made for you in a request THIS ONE. Way to rub it in.

Ok now my real reply (Disregard the above portion of my post)

Well its almost the way I had in mind, I was thinking of showing each damage from every poison, a bit more complicated, but if you don't take up this challenge then :( not :) but :(. Also I would've done what I have done over here, gives the user more freedom over how much damage the poison deals. But well Nicely done
 

Shiro

Member

Trickster":1mi1aqoh said:
Hey... wait a sec aren't you supposed to be using a script I made for you in a request THIS ONE.
Well... I *HAVE* been using it, but now I can do multiple poisons and also regen by having it do negative damage. So yeah... I'm sorry? =P

Well, once you make your version of this script, I'll probably hop right on back to yours *laughs*
 
I agree with Shinjo about his mana draining poision; and I also need a small walkthrough and how to use this script, and how to add more than one state_id to this script. Thank you for your time.
 

TaCk

Member

Thanks for this script. It's a little old but I'm gonna bump it because it's nice. It's one of the scripts I was looking for (slow-curing potions rather than instant). Also it makes poison-users potentially dangerous with lots of stacking poisons.

Thanks again. I'll play test it a lot and see if I get any questions about it.
 
How about saying what is wrong so I can fix it?  Just saying something is not working will not speed the fixing of of whatever issue may be having.
 
Yeyinde":1yu5gy22 said:
How about saying what is wrong so I can fix it?  Just saying something is not working will not speed the fixing of of whatever issue may be having.

I'm sorry, I wish I could offer more information, but I don't know what the problem is.  I've installed the script and it's not doing anything.  I have SDK 2.3 and MACL.  The only changes I've made to the script itself are:

Code:
BATTLE_DAMAGE = {18 => 11} # Format: state_id => damage_division

and

Code:
MAP_DAMAGE = {18 => 101} # Format: state_id => damage_division

And I've created a state in slot 18, afflicted it to enemies as well as characters, but neither do anything at all.  Am I supposed to go into one of the default scripts and change something?
 

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