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.

[RESOLVED]Muliple Drops from Monsters

Script Title:
Multiple Monster Drops

RMXP or RMVX:
RPG Maker XP

Detailed Description:
I need a script that will allow monsters to drop 2 or more different items. It can not use the SDK, as the SDK screws up my other scripts.

Other Scripts I am using (in order):
Sideview Battle System Tankentai XP - viewtopic.php?f=11&t=60521
Zeriab's Quest Book - viewtopic.php?f=11&t=55666
Cold's Bestiary and Item Book (I know that this script has an option to make monsters drop multiple things, but it's not working properly.)
http://www.rpgrevolution.com/forums/ind ... =0&start=0
 

Atoa

Member

Non SDK for XP
Code:
#==============================================================================

# Multi_Drop

# by Atoa

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

# This script allows to add more than one item for the enemies

#

# Enemy_Drops[ID] = {"ITEM" => RATE}

#

# ID = Enemy ID

# ITEM = Item Type and ID. Must be written line "xY"

#  where x =  item type e Y = item ID

# x must be "a" for armors, "w" for weapons, "i" for items

# RATE = Drop rate. An value from 0.0 and 100.0

#   ex.: 5.4  = 5,4% drop rate

#

# E.g.:

# Enemy_Drops[15] = {"w6" => 22.5, "a9" => 12}

# That means the enemy ID 15 (Enemy_Drops[15])

# has 22,5% of droping the weapon ID 6 ("w6" => 22.5)

# and also has 12% of droping the armor ID 9 ("a9" => 12)

#

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

 

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

# Module Atoa

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

module Atoa

  Enemy_Drops = [] # dont remove this line

 

  # Add here the new enemies drops

  Enemy_Drops[1] = {"a1" => 15.5, "w1" => 12, "i2" =>  5}

  Enemy_Drops[2] = {"i3" => 22.5, "w2" => 0.5}

 

end

 

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

# Game_Enemy

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

class Game_Enemy < Game_Battler

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

  include Atoa

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

  def multi_drops

    drop_items = []

    return drop_items if Enemy_Drops[@enemy_id] == nil

    Enemy_Drops[@enemy_id].each do |item, drop_rate|

      item = item.split('')

      if item[0] == "i"

        item = item.join

        item.slice!("i")

        drop_items.push($data_items[item.to_i]) if rand(1000) < (drop_rate * 10).to_i

      elsif item[0] == "a"

        item = item.join

        item.slice!("a")

        drop_items.push($data_armors[item.to_i]) if rand(1000) < (drop_rate * 10).to_i

      elsif item[0] == "w"

        item = item.join

        item.slice!("w")

        drop_items.push($data_weapons[item.to_i]) if rand(1000) < (drop_rate * 10).to_i

      end

    end

    return drop_items

  end

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

  def multi_drop_items

    multi_items = []

    multi_items.push(multi_drops)

    for item in multi_items

      case item

      when RPG::Item

        $game_party.gain_item(item.id, 1)

      when RPG::Weapon

        $game_party.gain_weapon(item.id, 1)

      when RPG::Armor

        $game_party.gain_armor(item.id, 1)

      end

    end

    return multi_items

  end

end

 

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

# Window_BattleResult

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

class Window_BattleResult < Window_Base

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

  def add_multi_drops

    for enemy in $game_troop.enemies

      @treasures.push(enemy.multi_drop_items)

    end

    @treasures.flatten!

    @treasures.sort! {|a, b| a.id <=> b.id}

    @treasures.sort! do |a, b|

      a_class = a.is_a?(RPG::Item) ? 0 : a.is_a?(RPG::Weapon) ? 1 : 2

      b_class = b.is_a?(RPG::Item) ? 0 : b.is_a?(RPG::Weapon) ? 1 : 2

      a_class <=> b_class

    end

    self.height = [@treasures.size * 32 + 64, 288].min

    self.contents = Bitmap.new(width - 32, @treasures.size * 32 + 32)

    self.y = 160 - height / 2

    refresh

  end

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

  def update

    super

    if @treasures.size * 32 + 64 > 288

      if Input.press?(Input::UP)

        self.oy -= 4 if self.oy > 0

      elsif Input.press?(Input::DOWN)

        self.oy += 4 if self.oy < @treasures.size * 32 + 64 - 288

      end

    end  

  end

end

 

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

# Scene_Battle

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

class Scene_Battle

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

  alias multi_drop_start_phase5 start_phase5

  alias multi_drop_update_phase5 update_phase5

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

  def start_phase5

    multi_drop_start_phase5

    @result_window.add_multi_drops

  end

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

  def update_phase5

    @result_window.update

    multi_drop_update_phase5

  end

end
 
Atoa":pdv25xru said:
Non SDK for XP
Code:
#==============================================================================

# Multi_Drop

# by Atoa

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

# This script allows to add more than one item for the enemies

#

# Enemy_Drops[ID] = {"ITEM" => RATE}

#

# ID = Enemy ID

# ITEM = Item Type and ID. Must be written line "xY"

#  where x =  item type e Y = item ID

# x must be "a" for armors, "w" for weapons, "i" for items

# RATE = Drop rate. An value from 0.0 and 100.0

#   ex.: 5.4  = 5,4% drop rate

#

# E.g.:

# Enemy_Drops[15] = {"w6" => 22.5, "a9" => 12}

# That means the enemy ID 15 (Enemy_Drops[15])

# has 22,5% of droping the weapon ID 6 ("w6" => 22.5)

# and also has 12% of droping the armor ID 9 ("a9" => 12)

#

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

 

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

# Module Atoa

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

module Atoa

  Enemy_Drops = [] # dont remove this line

 

  # Add here the new enemies drops

  Enemy_Drops[1] = {"a1" => 15.5, "w1" => 12, "i2" =>  5}

  Enemy_Drops[2] = {"i3" => 22.5, "w2" => 0.5}

 

end

 

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

# Game_Enemy

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

class Game_Enemy < Game_Battler

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

  include Atoa

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

  def multi_drops

    drop_items = []

    return drop_items if Enemy_Drops[@enemy_id] == nil

    Enemy_Drops[@enemy_id].each do |item, drop_rate|

      item = item.split('')

      if item[0] == "i"

        item = item.join

        item.slice!("i")

        drop_items.push($data_items[item.to_i]) if rand(1000) < (drop_rate * 10).to_i

      elsif item[0] == "a"

        item = item.join

        item.slice!("a")

        drop_items.push($data_armors[item.to_i]) if rand(1000) < (drop_rate * 10).to_i

      elsif item[0] == "w"

        item = item.join

        item.slice!("w")

        drop_items.push($data_weapons[item.to_i]) if rand(1000) < (drop_rate * 10).to_i

      end

    end

    return drop_items

  end

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

  def multi_drop_items

    multi_items = []

    multi_items.push(multi_drops)

    for item in multi_items

      case item

      when RPG::Item

        $game_party.gain_item(item.id, 1)

      when RPG::Weapon

        $game_party.gain_weapon(item.id, 1)

      when RPG::Armor

        $game_party.gain_armor(item.id, 1)

      end

    end

    return multi_items

  end

end

 

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

# Window_BattleResult

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

class Window_BattleResult < Window_Base

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

  def add_multi_drops

    for enemy in $game_troop.enemies

      @treasures.push(enemy.multi_drop_items)

    end

    @treasures.flatten!

    @treasures.sort! {|a, b| a.id <=> b.id}

    @treasures.sort! do |a, b|

      a_class = a.is_a?(RPG::Item) ? 0 : a.is_a?(RPG::Weapon) ? 1 : 2

      b_class = b.is_a?(RPG::Item) ? 0 : b.is_a?(RPG::Weapon) ? 1 : 2

      a_class <=> b_class

    end

    self.height = [@treasures.size * 32 + 64, 288].min

    self.contents = Bitmap.new(width - 32, @treasures.size * 32 + 32)

    self.y = 160 - height / 2

    refresh

  end

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

  def update

    super

    if @treasures.size * 32 + 64 > 288

      if Input.press?(Input::UP)

        self.oy -= 4 if self.oy > 0

      elsif Input.press?(Input::DOWN)

        self.oy += 4 if self.oy < @treasures.size * 32 + 64 - 288

      end

    end  

  end

end

 

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

# Scene_Battle

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

class Scene_Battle

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

  alias multi_drop_start_phase5 start_phase5

  alias multi_drop_update_phase5 update_phase5

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

  def start_phase5

    multi_drop_start_phase5

    @result_window.add_multi_drops

  end

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

  def update_phase5

    @result_window.update

    multi_drop_update_phase5

  end

end

When I try it out, I get a syntax error on line 2, which is really strange since that is a comment line.
 
Atoa":22ujtajh said:
did you turn off the Line Nuber before copying?

I feel stupid for for getting to do that lol

I'm not getting any error messages now. However, when I beat a monster, the items that drop show up in the battle result window, but they are not added to the player's inventory.
 

Atoa

Member

sorry i've posted the wrong version of the script.
Here's the right one
Code:
#==============================================================================

# Multi_Drop

# by Atoa

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

# This script allows to add more than one item for the enemies

#

# Enemy_Drops[ID] = {"ITEM" => RATE}

#

# ID = Enemy ID

# ITEM = Item Type and ID. Must be written line "xY"

#  where x =  item type e Y = item ID

# x must be "a" for armors, "w" for weapons, "i" for items

# RATE = Drop rate. An value from 0.0 and 100.0

#   ex.: 5.4  = 5,4% drop rate

#

# E.g.:

# Enemy_Drops[15] = {"w6" => 22.5, "a9" => 12}

# That means the enemy ID 15 (Enemy_Drops[15])

# has 22,5% of droping the weapon ID 6 ("w6" => 22.5)

# and also has 12% of droping the armor ID 9 ("a9" => 12)

#

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

 

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

# Module Atoa

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

module Atoa

  Enemy_Drops = [] # dont remove this line

 

  # Add here the new enemies drops

  Enemy_Drops[1] = {"a1" => 15.5, "w1" => 12, "i2" =>  5}

  Enemy_Drops[2] = {"i3" => 22.5, "w2" => 0.5}

 

end

 

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

# Game_Enemy

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

class Game_Enemy < Game_Battler

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

  include Atoa

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

  def multi_drops

    drop_items = []

    return drop_items if Enemy_Drops[@enemy_id] == nil

    Enemy_Drops[@enemy_id].each do |item, drop_rate|

      item = item.split('')

      if item[0] == "i"

        item = item.join

        item.slice!("i")

        drop_items.push($data_items[item.to_i]) if rand(1000) < (drop_rate * 10).to_i

      elsif item[0] == "a"

        item = item.join

        item.slice!("a")

        drop_items.push($data_armors[item.to_i]) if rand(1000) < (drop_rate * 10).to_i

      elsif item[0] == "w"

        item = item.join

        item.slice!("w")

        drop_items.push($data_weapons[item.to_i]) if rand(1000) < (drop_rate * 10).to_i

      end

    end

    return drop_items

  end

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

  def multi_drop_items

    multi_items = multi_drops

    for item in multi_items

      case item

      when RPG::Item

        $game_party.gain_item(item.id, 1)

      when RPG::Weapon

        $game_party.gain_weapon(item.id, 1)

      when RPG::Armor

        $game_party.gain_armor(item.id, 1)

      end

    end

    return multi_items

  end

end

 

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

# Window_BattleResult

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

class Window_BattleResult < Window_Base

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

  def add_multi_drops

    for enemy in $game_troop.enemies

      @treasures.push(enemy.multi_drop_items)

    end

    @treasures.flatten!

    @treasures.sort! {|a, b| a.id <=> b.id}

    @treasures.sort! do |a, b|

      a_class = a.is_a?(RPG::Item) ? 0 : a.is_a?(RPG::Weapon) ? 1 : 2

      b_class = b.is_a?(RPG::Item) ? 0 : b.is_a?(RPG::Weapon) ? 1 : 2

      a_class <=> b_class

    end

    self.height = [@treasures.size * 32 + 64, 288].min

    self.contents = Bitmap.new(width - 32, @treasures.size * 32 + 32)

    self.y = 160 - height / 2

    refresh

  end

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

  def update

    super

    if @treasures.size * 32 + 64 > 288

      if Input.press?(Input::UP)

        self.oy -= 4 if self.oy > 0

      elsif Input.press?(Input::DOWN)

        self.oy += 4 if self.oy < @treasures.size * 32 + 64 - 288

      end

    end  

  end

end

 

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

# Scene_Battle

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

class Scene_Battle

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

  alias multi_drop_start_phase5 start_phase5

  alias multi_drop_update_phase5 update_phase5

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

  def start_phase5

    multi_drop_start_phase5

    @result_window.add_multi_drops

  end

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

  def update_phase5

    @result_window.update

    multi_drop_update_phase5

  end

end
 

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