Ok, this SHOULD work. Probably have a few bugs, but report them and I'll try my best to fix them!
#------------------------------------------------------------------
#------------------------------------------------------------------
# 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