[Script] มอนสเตอร์ให้ไอเทมมากกว่า 1 อย่าง
หน้า 1 จาก 1
[Script] มอนสเตอร์ให้ไอเทมมากกว่า 1 อย่าง
- Spoiler:
- 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
วิธีการใช้งาน
ซ่อน
เครดิต ninomiya_mako@hotmail.com
Similar topics
» [Script] มอนสเตอร์ให้ไอเทมมากกว่า 1 อย่าง
» [Script] ติดตั้งสกิลเป็นสล็อท
» [Script] Element Reflector สะท้อนการโจมตีของธาตุต่างๆได้ทั้งฝ่ายเราและศัตรู
» [Script] Skill Sorting เรียงสกิลตามใจฉัน
» [Script]Passive skill vol.1 มาบูสต์พลังให้สกิลต่างๆกันเถอะ
» [Script] ติดตั้งสกิลเป็นสล็อท
» [Script] Element Reflector สะท้อนการโจมตีของธาตุต่างๆได้ทั้งฝ่ายเราและศัตรู
» [Script] Skill Sorting เรียงสกิลตามใจฉัน
» [Script]Passive skill vol.1 มาบูสต์พลังให้สกิลต่างๆกันเถอะ
หน้า 1 จาก 1
Permissions in this forum:
คุณไม่สามารถพิมพ์ตอบ