Monster drop more than one item. - Hima - 04-25-2007
Hima's Monster Drop Item
by Hima
v. 1.0
Apr 25 2007
This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.
The Script
Code: #==============================================================================
# * Hima's Monster Drop Item v. 1.0
#------------------------------------------------------------------------------
# This script will allow you to create a monster that drop various item with
# different rarity. You can do this by naming the monster with special pattern
# "Monstername-spdrop-r(type)(id)-u(type)(id)-c(type)(id)"
# (type) = Insert w,a or i in here. w = weapon, a = armor, i = item.
# (id) = Insert the id of item/weapon/armor that the monster will drop here.
# So if you want the rare item to be weapon id 1, uncommon item to be armor id 1
# and common item to be item id 1, this is how you name the monster
# (assuming the monster's name is Ghost)
#
# "Ghost-spdrop-rw1-ua1-ci1"
#
# If you want a monster to drop item like what RMXP default, then just don't name
# them in this special pattern :)
# contact : ninomiya_mako@hotmail.com
#==============================================================================
module HIMA_MONSTERDROP
#--------------------------------------------------------------------------
# - Customize Point -
# SPDROP_KEYWORD - This will be your keyword to tell the script that the monster will drop sp item
# RARE_RATE - The chance for dropping a rare item. Unit is in percentage.
# UNCOMMON_RATE - The chance for dropping an uncommon item. Unit is in percentage.
# *** The chance for dropping a common item will be equal to 100 subtract by the sum of the two above. ***
#--------------------------------------------------------------------------
SPDROP_KEYWORD = "-spdrop-"
RARE_RATE = 10
UNCOMMON_RATE = 30
end
class Scene_Battle
def monster_drop_item(monster)
text = monster.name
name = monster.name.clone
if name.include?(HIMA_MONSTERDROP::SPDROP_KEYWORD)
open = text.index('-')
close = text.size-1
name[open..close] = ""
end
if text =~ /^#{name}#{HIMA_MONSTERDROP::SPDROP_KEYWORD}r([a-z])([0-9]+)-u([a-z])([0-9]+)-c([a-z])([0-9]+)/
get = rand(100)
case get
when 0..HIMA_MONSTERDROP::RARE_RATE
type = $1.to_s
id = $2.to_i
when HIMA_MONSTERDROP::RARE_RATE..HIMA_MONSTERDROP::UNCOMMON_RATE
type = $3.to_s
id = $4.to_i
else
type = $5.to_s
id = $6.to_i
end #case
return get_item(type,id)
else
if monster.item_id > 0
return $data_items[monster.item_id]
end
if monster.weapon_id > 0
return $data_weapons[monster.weapon_id]
end
if monster.armor_id > 0
return $data_armors[monster.armor_id]
end
end
end #method
def get_item(type,id)
if id > 0
case type
when "w"
return $data_weapons[id]
when "a"
return $data_armors[id]
when "i"
return $data_items[id]
end #case
else
return nil
end
end
#--------------------------------------------------------------------------
# - After battle phase start
#--------------------------------------------------------------------------
def start_phase5
# It moves to phase 5
@phase = 5
# Performing battle end ME
$game_system.me_play($game_system.battle_end_me)
# You reset to BGM before the battle starting
$game_system.bgm_play($game_temp.map_bgm)
# Initializing EXP, the gold and the treasure
exp = 0
gold = 0
treasures = []
# Loop
for enemy in $game_troop.enemies
# When the enemy hides and it is not state
unless enemy.hidden
# Adding acquisition EXP and the gold
exp += enemy.exp
gold += enemy.gold
# Treasure appearance decision
if rand(100) < enemy.treasure_prob
item = monster_drop_item(enemy)
treasures.push(item) unless item == nil
end
end
end
# It limits the number of treasures up to 6
treasures = treasures[0..5]
# EXP acquisition
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
# Gold acquisition
$game_party.gain_gold(gold)
# Treasure acquisition
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
# Drawing up the battle result window
@result_window = Window_BattleResult.new(exp, gold, treasures)
# Setting weight count
@phase5_wait_count = 100
end
end #class
#==============================================================================
# * Window_Help
#------------------------------------------------------------------------------
# Well we need to do something with showing Enemy's name, don't we?
#==============================================================================
class Window_Help < Window_Base
#--------------------------------------------------------------------------
# - Enemy setting
# enemy : The enemy which indicates name and the state
#--------------------------------------------------------------------------
def set_enemy(enemy)
text = enemy.name.clone
if text.include?(HIMA_MONSTERDROP::SPDROP_KEYWORD)
open = text.index('-')
close = text.size-1
text[open..close] = ""
end
state_text = make_battler_state_text(enemy, 112, false)
if state_text != ""
text += " " + state_text
end
set_text(text, 1)
end
end
How To Use?
- Put this script above "Main", name it "Hima_Monster_SPDrop" (Actually it doesn't really matter :D)
- For a monster that you want it to drop more than one item, you have to name it according to this special pattern
Code: (Monster name)-spdrop-r(type)(id)-u(type)(id)-c(type)(id)
(Monster name) = a monster's name that will be shown in the game
(Type) = Type of item. You need to type in a character i, a or w which are item, armor and weapon, respectively.
(ID) = item's id number, according to the database
::Example::
A monster named "Ghost" will rarely drop "Weapon 001",sometimes drop "Armor 001" and usually drop "Item 001", you need to named it like this in the database
Code: Ghost-spdrop-rw1-ua1-ci1
Like in the picture
- Then, you give it a dropping rate, and any dropping item would be fine, since it won't drop the thing you choose here anyway :D
- And don't worry about the complicated name, it won't be shown :)
Cuztomize Point- The default dropping rate of this script is
Rare item : 10%
Uncommon item : 30%
Common item : 60%
However, these can be changed in the script. :)
- You can change the keyword "-spdrop-" into something else.
Acknowledgement
- A monster without this special naming pattern will drop an item just like default RMXP.
- The rate of rare, uncommon and common item are calculated AFTER calculate the dropping chance. Example, if you set the main dropping chance to be 50% , then the game calculate whether you get the item with 50% first, then it calculate according to the script which rarity of item will you get.
- The summation of all rarity chance are euqal to 100.
Credits
- Jabberwocky : Thanks you for helping me with the /^/ function. :D
- XRMS : My inspiration :)
|