RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[Request] Force Drop Item

0 Members and 1 Guest are viewing this topic.

**
Rep: +0/-0Level 78
RMRK Junior
Force Drop Item
September 15th, 2010



Summary
It's sort of rather easy, I think. I just want a script that force enemy to drop an item, like in ff10. Apply to weapon and items and skills.

Features Desired
  • Apply to weapons, items and skills.
  • Notes like <fdrop x:y:z> in which x is the kind of item to drop, y is the id of the item and z is the chance.
  • create more as needed

Mockups
None yet.

Games its been in
  • FF 10



Did you search?
Yes

Where did you search?
  • Google and many websites

What did you search for?
  • force drop item script rpg maker vx
  • force drop item script rmvx
  • drop item rmvx

**
Rep:
Level 75
RMRK Junior
Hmmm... so something to make an enemy drop an item if you have a certain armor or weapon equipped?

**
Rep: +0/-0Level 78
RMRK Junior
Not that. I want the item to be used, or the person equip the weapon has to attack to make it drop. And i don't want it to be applied with armors. Also, i want the force drop items and weapons when are used, they delete all of the target's drop items of the current battle.

**
Rep:
Level 75
RMRK Junior
One more thing, then I can start to work on it. Do you want the item to drop instantly or wait until you defeat the enemy and gather its drops?

**
Rep: +0/-0Level 78
RMRK Junior
It would be better to customize this option and can change it in game.

**
Rep:
Level 75
RMRK Junior
Ok, I will start working today. Since I still haven't got my PC back, you will probably have to wait a bit... I hope to be able to finish it before sunday, otherwise you can ask somebody else, since I will go to LHD ad then Paris for a week...

**
Rep: +0/-0Level 78
RMRK Junior
Well, i need to add this to the features: it should be compatible with YEM battle engine.

**
Rep:
Level 75
RMRK Junior
I won't be able to finish this before tomorrow. That means that I can't do this unless you wait for Armageddon (or at least two weeks, your choice).

**
Rep: +0/-0Level 78
RMRK Junior
Well, i will wait.

**
Rep:
Level 75
RMRK Junior
Ok, all right. I have returned, but I still haven't got a PC... Just to let you know I haven't forgotten this.

**
Rep:
Level 75
RMRK Junior
Ok, this SHOULD work. Probably have a few bugs, but report them and I'll try my best to fix them!
Code: [Select]
#------------------------------------------------------------------
#------------------------------------------------------------------
#                  The Mormegil's Force Drops
#                             v 1.0
#------------------------------------------------------------------
#------------------------------------------------------------------
#
# This script allows you to set some skills, weapons or items that can make an enemy
# drop an object when used (or you attack with it).
# There are two possible options: the enemy drops the item instantly and no changes
# to enemy loot is done, or the enemy changes his own drops to a new loot.
#
# NOTETAGS:
#   Skills:
#   <force drop type: x>
#   <force instant drop type: x>
#
#   Items:
#   <force drop type: x>
#   <force instant drop type: x>
#
#   Weapons:
#   <force drop type: x>
#   <force instant drop type: x>
#
# where type is "armor", "item", or "weapon", and x is the drop's id.
#
# Some notes: if you use the first option (instant drop), you can still
# nullify the final drops: just set a second option tag with 0 as the id.
# If you use the second option (change drops), you can obtain up to 2
# new objects as a loot; they will be the last two to be set up with skills
# or items. For example, skill1 can make an enemy drop an omelette, while
# item1 makes it drop eggs. If you use skill1 twice on enemyA, it will drop
# two omelettes. If you use it again, nothing will change. Say you use skill1
# three times, then item1 once: the enemy will drop an omelette and an egg.
# If you use skill1 again after that, nothing will change, but if you use it twice
# you will get two omelettes again. Savvy?
#
# Another note: the script is written for the standard battle system.
# If you are using a different battle system, turn the option below to true
# unless this battle system still uses battle messages.
# The instant drop feature calls a battle message to inform the player he has
# gained an item, so if you turn it to true it will just be added to the inventory,
# which isn't nice. You can ask a modification to the script to change this - if you do,
# just rewrite the "show_text_item_instant_drop" method.
#
#------------------------------------------------------------------
#
#     $$$$$$$$$$$$$$$ CUSTOMIZATION OPTIONS $$$$$$$$$$$$$$$$$$$$
#
# Read above for this option:

FORCE_DROPS_DIFFERENT_BATTLE_SYSTEM = false

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

#                   STOP EDITING PAST THIS POINT!
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#


$imported = {} if $imported == nil
$imported["TM_ForceDrops"] = true


class Game_Enemy < Game_Battler
 
  attr_accessor    :forced_drops
  attr_accessor    :force_drop_flag

  alias force_drop_initialize initialize
  def initialize(a, b)
    @force_drop_flag = false
    @forced_drops = []
    force_drop_initialize(a, b)
  end

  alias force_di1 drop_item1
  alias force_di2 drop_item2

  def drop_item1
    force = @forced_drops[0]
    drop = force_di1
    if @force_drop_flag
      return make_a_forced_drop(force)
    else
      return drop
    end
  end

  def drop_item2
    force = @forced_drops[1]
    drop = force_di2
    if @force_drop_flag
      return make_a_forced_drop(force)
    else
      return drop
    end
  end

  def make_a_forced_drop(item)
    item.kind = 1 if item.is_a?(Item)
    item.kind = 2 if item.is_a?(Weapon)
    item.kind = 3 if item.is_a?(Armor)
    case item.kind
    when 1
      item.item_id = item.id
    when 2
      item.weapon_id = item.id
    when 3
      item.armor_id = item.id
    end
  end

end

module RPG
  class BaseItem
    alias force_drops_in initialize
    def initialize
      force_drops_in
      @kind = 0
      @item_id = 1
      @weapon_id = 1
      @armor_id = 1
      @denominator = 1
    end
    attr_accessor   :kind
    attr_accessor   :item_id
    attr_accessor   :weapon_id
    attr_accessor   :armor_id
    attr_accessor   :denominator
  end
end

class Game_Battler

  alias force_drops_se skill_effect
  def skill_effect(user, skill)
    force_drops_se(user, skill)
    lines = skill.note.split(/[\r\n]+/)
    for line in lines
      if line =~ TheMormegil::ForceItems::Regexp::FORCE_A_DROP
        case $1.upcase
        when "ARMOR"
          drop_item = $data_armors[$2.to_i]
        when "ITEM"
          drop_item = $data_items[$2.to_i]
        when "WEAPON"
          drop_item = $data_weapons[$2.to_i]
        end
      end
      self.forced_drops.unshift(drop_item) if drop_item != nil
      self.force_drop_flag = true if drop_item != nil
    end
    for line in lines
      if line =~ TheMormegil::ForceItems::Regexp::FORCE_INSTANT_DROP
        case $1.upcase
        when "ARMOR"
          instant_drop_item = $data_armors[$2.to_i]
        when "ITEM"
          instant_drop_item = $data_items[$2.to_i]
        when "WEAPON"
          instant_drop_item = $data_weapons[$2.to_i]
        end
        $scene.fi_get_item(instant_drop_item) if $scene.is_a?(Scene_Battle)
        $scene.show_text_item_instant_drop(instant_drop_item) if $scene.is_a?(Scene_Battle)
      end
    end
  end

  alias force_drops_ie item_effect
  def item_effect(user, item)
    force_drops_ie(user, item)
    lines = item.note.split(/[\r\n]+/)
    for line in lines
      if line =~ TheMormegil::ForceItems::Regexp::FORCE_A_DROP
        case $1.upcase
        when "ARMOR"
          drop_item = $data_armors[$2.to_i]
        when "ITEM"
          drop_item = $data_items[$2.to_i]
        when "WEAPON"
          drop_item = $data_weapons[$2.to_i]
        end
      end
      self.forced_drops.unshift(drop_item) if drop_item != nil
      self.force_drop_flag = true if drop_item != nil
    end
    for line in lines
      if line =~ TheMormegil::ForceItems::Regexp::FORCE_INSTANT_DROP
        case $1.upcase
        when "ARMOR"
          instant_drop_item = $data_armors[$2.to_i]
        when "ITEM"
          instant_drop_item = $data_items[$2.to_i]
        when "WEAPON"
          instant_drop_item = $data_weapons[$2.to_i]
        end
        $scene.fi_get_item(instant_drop_item) if $scene.is_a?(Scene_Battle)
        $scene.show_text_item_instant_drop(instant_drop_item) if $scene.is_a?(Scene_Battle)
      end
    end
  end

end

class Scene_Battle < Scene_Base
  alias force_drops_eacatt execute_action_attack
  def execute_action_attack
    force_drops_eacatt
    weapons = @active_battler.weapons
    lines = []
    for weapon in weapons
      weapon_lines = weapon.note.split(/[\r\n]+/)
      lines += weapon_lines
    end
    for line in lines
      if line =~ TheMormegil::ForceItems::Regexp::FORCE_A_DROP
        case $1.upcase
        when "ARMOR"
          drop_item = $data_armors[$2.to_i]
        when "ITEM"
          drop_item = $data_items[$2.to_i]
        when "WEAPON"
          drop_item = $data_weapons[$2.to_i]
        end
      end
      for target in targets
        target.forced_drops.unshift(drop_item) if drop_item != nil
        target.force_drop_flag = true if drop_item != nil
      end
    end
    for line in lines
      if line =~ TheMormegil::ForceItems::Regexp::FORCE_INSTANT_DROP
        case $1.upcase
        when "ARMOR"
          instant_drop_item = $data_armors[$2.to_i]
        when "ITEM"
          instant_drop_item = $data_items[$2.to_i]
        when "WEAPON"
          instant_drop_item = $data_weapons[$2.to_i]
        end
        fi_get_item(instant_drop_item)
        show_text_item_instant_drop(instant_drop_item)
      end
    end
  end

  def fi_get_item(item)
    $game_party.gain_item(item, 1)
  end

  def show_text_item_instant_drop(item)
    unless FORCE_DROPS_DIFFERENT_BATTLE_SYSTEM
      text = sprintf(Vocab::ObtainItem, item.name)
      $game_message.texts.push(text)
      wait_for_message
    end
  end

end

module TheMormegil
  module ForceItems
    module Regexp
      FORCE_A_DROP = /<(?:FORCE_DROP|force\sdrop)\s*?(\w+?)\:\s*?(\d+?)>/
      FORCE_INSTANT_DROP = /<(?:FORCE_INSTANT_DROP|force\sinstant\sdrop)\s*?(\w+?)\:\s*?(\d+?)>/
    end
  end
end

**
Rep: +0/-0Level 78
RMRK Junior
A bug found. When a character attacks, it comes up with this error:
Code: [Select]
Script "Force Drop Item" line 235 NameError occurred.

undefined local variables or method 'targets' for
#<Scene_Battle:0xc0c6520>
I place the script under the Yanfly Engine Melody.

**
Rep:
Level 75
RMRK Junior
Add this line between line 218 and 219.
Code: [Select]
    targets = @active_battler.action.make_targets