Chaos Project

RPG Maker => RPG Maker Scripts => Script Requests => Topic started by: hyakkivn on September 06, 2011, 06:39:43 am

Title: [XP]Monster drop more than 1 item with percent of drop
Post by: hyakkivn on September 06, 2011, 06:39:43 am
Well,
Currently, I'm trying to make a game with ForeverZero's Forging System . So, the point here is we use several material to create an item.
The materials can be obtained from monster after dead. But the problem is RMXP can allow monster drop exactly 1 item with the amount of 1 unit each time it dead.
Do we have any Script that allow monster drop more than one item (with % drop) in different number (ex: 1 - 3 units each time)
I need it badly  :'(
Thanks!
P/S:
And here is my Demo game
http://www.mediafire.com/?r7zphd8ri9qh0ca (http://www.mediafire.com/?r7zphd8ri9qh0ca)
Title: Re: [XP]Monster drop more than 1 item with percent of drop
Post by: Twb6543 on September 06, 2011, 07:42:39 am
try this

Spoiler: ShowHide


#===============================================================================
# More Treasures Ver 0.9 Modified for CBS
# By Twb6543
# Will conflict with anything modifing start_phase5
#===============================================================================
# To do make it so that if the item is more than 1 then don't limmit it
# - Basically stop 20xPotions from taking up the space in the treasures array
#===============================================================================
# Setup on lines 16 to 29
#===============================================================================
class Scene_Battle
 
  alias initialize_old_More_treasures initialize
  def initialize
   
    @stoplimit_tre = false # turn to true to stop the limmiting of treasures
    # If unlimmited it may make a mess of your victory scene
    @maxtreasures = 6 # The maxium number of treasures GAME DEFAULT IS 6
    # This also includes the number of them so
    # if an item adds 20 of it self it will be limited to 6
    @treasuresextra = {
    # [EnemyID,TreasureNo] => [Id,Type,Numberof,Probabilty]
    # Please also note that the highest treasureNo takes priority
    [1,1] => [1,1,20,100], # Please clear these two examples and add your own
    # Enemy Ghost drops item potion in the quantity of 20 100% of the time
    [1,2] => [2,1,1,60]
    # Enemy Ghost drops item high_potion in the quantity of 1 60% of the time
    }
    @treasuresmaxtoadd = 2 # The maximum number of treasures to add
    # set this to the highest treasureno in the @treasuresextra hach
    initialize_old_More_treasures
  end
 
  alias start_phase5_old_More_treasures start_phase5
  def start_phase5
    for actor in $game_party.actors
      actor.set_pose($VICTORY)
    end
    # Shift to phase 5
    @phase = 5
    # Play battle end ME
    $game_system.me_play($game_system.battle_end_me)
    # Return to BGM before battle started
    $game_system.bgm_play($game_temp.map_bgm)
    # Initialize EXP, amount of gold, and treasure
    exp = 0
    gold = 0
    treasures = []
    #===========================================================================
    # More Drops from Here
    #===========================================================================
    # for each enemy
    for enemy in $game_troop.enemies
      # If enemy is not hidden
      unless enemy.hidden
        # Add EXP and amount of gold obtained
        exp += enemy.exp
        gold += enemy.gold
        # Add the defualt treasures
        if rand(100) < enemy.treasure_prob
          if enemy.item_id > 0
            treasures.push($data_items[enemy.item_id])
          end
          if enemy.weapon_id > 0
            treasures.push($data_weapons[enemy.weapon_id])
          end
          if enemy.armor_id > 0
            treasures.push($data_armors[enemy.armor_id])
          end
        end
       
        # Add additional treasures
        treasuretoadd = []
        @treasuresextra.each_pair {|key, value|
        a = 0
        while a != @treasuresmaxtoadd
          a+=1
          if key == [enemy.id,a]
            treasuretoadd.push value
          end
        end
        }
       
        # For each additional treasure
        treasuretoadd.each {|i|
        # if type is equal to 1 or "Item" then the treasure is an item
        if i[1] == 1 || i[1] == "Item" # Item
          # if x < prob
          # 0..99 < 100 so 100% chance of recieving item
          if rand(100) < i[3]
            # for the numberof items
            b = 0
            while b != i[2]
              # add it
              b += 1
              treasures.push($data_items[i[0]])
            end
          end
        # if type is equal to 2 or "Weapon" then the treasure is a weapon
        elsif i[1] == 2 || i[1] == "Weapon" # Weapon
          if rand(100) < i[3]
            b = 0
            while b != i[2]
              # add it
              b += 1
              treasures.push($data_weapons[i[0]])
            end
          end
        # if type is equal to 3 or "Armor" then the treasure is an Armor
        elsif i[1] == 3 || i[1] == "Armor" # Armor
          if rand(100) < i[3]
            b = 0
            while b != i[2]
              # add it
              b += 1
              treasures.push($data_armors[i[0]])
            end
          end
        end
        }
       
      end
    end
    # Treasure is limited to a maximum of 6 items by defualt
    maxtreasures = (@maxtreasures - 1)
    treasures = treasures[0..maxtreasures] unless @stoplimit_tre
    #===========================================================================
    # End
    #===========================================================================
    # Obtaining EXP
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      if actor.cant_get_exp? == false
        last_level = actor.level
        actor.exp += exp
        if actor.level > last_level
          @status_window.level_up(i)
        end
      end
    end
    # Obtaining gold
    $game_party.gain_gold(gold)
    # Obtaining treasure
    for item in treasures
      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
    # Make battle result window
    @result_window = Window_BattleResult.new(exp, gold, treasures)
    # Set wait count
    @phase5_wait_count = 100
  end
end



If used in your game credit would be nice but not necessary.
PLACE IT BELOW YOU CBS
The one above was slightly edited to make it work with you CBS but the victory scene is slightly messed up if you recieve to many items.

Normal version:

Spoiler: ShowHide

#===============================================================================
# More Treasures Ver 0.9
# By Twb6543
# Will conflict with anything modifing start_phase5
#===============================================================================
# To do make it so that if the item is more than 1 then don't limmit it
# - Basically stop 20xPotions from taking up the space in the treasures array
#===============================================================================
# Setup on lines 16 to 29
#===============================================================================
class Scene_Battle
 
  alias initialize_old_More_treasures initialize
  def initialize
   
    @stoplimit_tre = false # turn to true to stop the limmiting of treasures
    # If unlimmited it may make a mess of your victory scene
    @maxtreasures = 6 # The maxium number of treasures GAME DEFAULT IS 6
    # This also includes the number of them so
    # if an item adds 20 of it self it will be limited to 6
    @treasuresextra = {
    # [EnemyID,TreasureNo] => [Id,Type,Numberof,Probabilty]
    # Please also note that the highest treasureNo takes priority
    [1,1] => [1,1,20,100], # Please clear these two examples and add your own
    # Enemy Ghost drops item potion in the quantity of 20 100% of the time
    [1,2] => [2,1,1,60]
    # Enemy Ghost drops item high_potion in the quantity of 1 60% of the time
    }
    @treasuresmaxtoadd = 2 # The maximum number of treasures to add
    # set this to the highest treasureno in the @treasuresextra hach
    initialize_old_More_treasures
  end
 
  alias start_phase5_old_More_treasures start_phase5
  def start_phase5
    # Shift to phase 5
    @phase = 5
    # Play battle end ME
    $game_system.me_play($game_system.battle_end_me)
    # Return to BGM before battle started
    $game_system.bgm_play($game_temp.map_bgm)
    # Initialize EXP, amount of gold, and treasure
    exp = 0
    gold = 0
    treasures = []
    #===========================================================================
    # More Drops from Here
    #===========================================================================
    # for each enemy
    for enemy in $game_troop.enemies
      # If enemy is not hidden
      unless enemy.hidden
        # Add EXP and amount of gold obtained
        exp += enemy.exp
        gold += enemy.gold
        # Add the defualt treasures
        if rand(100) < enemy.treasure_prob
          if enemy.item_id > 0
            treasures.push($data_items[enemy.item_id])
          end
          if enemy.weapon_id > 0
            treasures.push($data_weapons[enemy.weapon_id])
          end
          if enemy.armor_id > 0
            treasures.push($data_armors[enemy.armor_id])
          end
        end
       
        # Add additional treasures
        treasuretoadd = []
        @treasuresextra.each_pair {|key, value|
        a = 0
        while a != @treasuresmaxtoadd
          a+=1
          if key == [enemy.id,a]
            treasuretoadd.push value
          end
        end
        }
       
        # For each additional treasure
        treasuretoadd.each {|i|
        # if type is equal to 1 or "Item" then the treasure is an item
        if i[1] == 1 || i[1] == "Item" # Item
          # if x < prob
          # 0..99 < 100 so 100% chance of recieving item
          if rand(100) < i[3]
            # for the numberof items
            b = 0
            while b != i[2]
              # add it
              b += 1
              treasures.push($data_items[i[0]])
            end
          end
        # if type is equal to 2 or "Weapon" then the treasure is a weapon
        elsif i[1] == 2 || i[1] == "Weapon" # Weapon
          if rand(100) < i[3]
            b = 0
            while b != i[2]
              # add it
              b += 1
              treasures.push($data_weapons[i[0]])
            end
          end
        # if type is equal to 3 or "Armor" then the treasure is an Armor
        elsif i[1] == 3 || i[1] == "Armor" # Armor
          if rand(100) < i[3]
            b = 0
            while b != i[2]
              # add it
              b += 1
              treasures.push($data_armors[i[0]])
            end
          end
        end
        }
       
      end
    end
    # Treasure is limited to a maximum of 6 items by defualt
    maxtreasures = (@maxtreasures - 1)
    treasures = treasures[0..maxtreasures] unless @stoplimit_tre
    #===========================================================================
    # End
    #===========================================================================
    # Obtaining EXP
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      if actor.cant_get_exp? == false
        last_level = actor.level
        actor.exp += exp
        if actor.level > last_level
          @status_window.level_up(i)
        end
      end
    end
    # Obtaining gold
    $game_party.gain_gold(gold)
    # Obtaining treasure
    for item in treasures
      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
    # Make battle result window
    @result_window = Window_BattleResult.new(exp, gold, treasures)
    # Set wait count
    @phase5_wait_count = 100
  end
end


Title: Re: [XP]Monster drop more than 1 item with percent of drop
Post by: G_G on September 06, 2011, 08:24:21 am
You can modify the percentage already in the database. There is also a multi-drops add-on on Tons of Add-ons.
http://forum.chaos-project.com/index.php/topic,105.0.html
Title: Re: [XP]Monster drop more than 1 item with percent of drop
Post by: hyakkivn on September 06, 2011, 09:22:06 am
Thank you guys for fast reply.
I try to find the Thanks Button but can not see it anywhere.
So thank you very much  :haha: