Alissa Item Requirements System
Version: 1.0
Type: Item System Add-on
PengenalanThis script adds item requirements criteria to item usages (like recipes). Each required items can be set whether it will be used up on item consumption.
NB: Script ini termasuk yang digunakan dalam game
The Mystery House
Petunjuk & PemasanganCukup pasang di atas slot 'Main'.
Untuk menambah list requirement, tambahkan pada module ItemReqs dgn code seperti contoh ini:
- Code:
-
ItemID[0] = 2
ItemReqsID[0] = [2]
ItemReqsQTY[0] = [1]
ItemReqsIsUsedUp[0] = [true]
CustomCriteria[0] = "true"
Screenshot- Spoiler:
https://i.imgur.com/x2rXF.png
DemoLink: http://www.media*fire.com/?ym2r0bzyfd741hq
Script - Code:
-
#==============================================================================
# Alissa Item Requirements System
#==============================================================================
# Information:
# This script adds item requirements criteria to item usages (like recipes).
# Each required items can be set whether it will be used up on item
# consumption.
#
# Installation:
# Just place above Main.
#
# Credits
# Alissa Liu
#
#==============================================================================
#---------------------------------------------------------------------------
# ** ItemReqs Module
#---------------------------------------------------------------------------
module ItemReqs
ItemID = [] # Requiring item ID
ItemReqsID = [] # Array of required items ID
ItemReqsQTY = [] # Array of number of required items
ItemReqsIsUsedUp = [] # Required items used up?
CustomCriteria = [] # Script code strings for condition evaluation
# (returns boolean value)
# Add as many as you want (this list is just for sample)
ItemID[0] = 22
ItemReqsID[0] = [21]
ItemReqsQTY[0] = [1]
ItemReqsIsUsedUp[0] = [true]
CustomCriteria[0] = "true"
ItemID[1] = 23
ItemReqsID[1] = [21]
ItemReqsQTY[1] = [1]
ItemReqsIsUsedUp[1] = [true]
CustomCriteria[1] = "true"
end
#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
# This class handles the party. It includes information on amount of gold
# and items. The instance of this class is referenced by $game_party.
#==============================================================================
class Game_Party < Game_Unit
#--------------------------------------------------------------------------
# * Consume Items
# item : item
# If the specified object is a consumable item, the number in investory
# will be reduced by 1.
#--------------------------------------------------------------------------
def consume_item(item)
if item.is_a?(RPG::Item) and item.consumable
lose_item(item, 1)
end
i=0
while i<ItemReqs::ItemID.length
case item
when RPG::Item
if ItemReqs::ItemID[i]==item.id
break
end
end
i+=1
end
if i<ItemReqs::ItemID.length && ItemReqs::ItemReqsID[i].length>0
for j in 0..ItemReqs::ItemReqsID[i].length-1
if ItemReqs::ItemReqsIsUsedUp[i][j]
lose_item($data_items[ItemReqs::ItemReqsID[i][j]], ItemReqs::ItemReqsQTY[i][j])
end
end
end
end
#--------------------------------------------------------------------------
# * Determine if Item is Usable
# item : item
#--------------------------------------------------------------------------
def item_can_use?(item)
return false unless item.is_a?(RPG::Item)
return false if item_number(item) == 0
fulfilled = true
i=0
while i<ItemReqs::ItemID.length
if item.is_a?(RPG::Item)
if ItemReqs::ItemID[i]==item.id
break
end
end
i+=1
end
if i<ItemReqs::ItemID.length
if ItemReqs::ItemReqsID[i].length>0
for j in 0..ItemReqs::ItemReqsID[i].length-1
fulfilled = (fulfilled && $game_party.item_number($data_items[ItemReqs::ItemReqsID[i][j]])>=ItemReqs::ItemReqsQTY[i][j])
end
end
fulfilled = (fulfilled && eval(ItemReqs::CustomCriteria[i]))
end
return false if not fulfilled
if $game_temp.in_battle
return item.battle_ok?
else
return item.menu_ok?
end
end
end
#==============================================================================
# ** Window_Item
#------------------------------------------------------------------------------
# This window displays a list of inventory items for the item screen, etc.
#==============================================================================
class Window_Item < Window_Selectable
#--------------------------------------------------------------------------
# * Update Help Text
#--------------------------------------------------------------------------
def update_help
extra_text = ""
i=0
while i<ItemReqs::ItemID.length
case item
when RPG::Item
if ItemReqs::ItemID[i]==item.id
break
end
end
i+=1
end
if i<ItemReqs::ItemID.length && ItemReqs::ItemReqsID[i].length>0
extra_text = " Requires "+sprintf("%d ",ItemReqs::ItemReqsQTY[i][0])+$data_items[ItemReqs::ItemReqsID[i][0]].name
if ItemReqs::ItemReqsID[i].length>1
for j in 1..ItemReqs::ItemReqsID[i].length-1
extra_text = extra_text+", "+sprintf("%d ",ItemReqs::ItemReqsQTY[i][j])+$data_items[ItemReqs::ItemReqsID[i][j]].name
end
end
end
@help_window.set_text(item == nil ? "" : item.description+extra_text)
end
end
#==============================================================================
# ** Scene_Item
#------------------------------------------------------------------------------
# This class performs the item screen processing.
#==============================================================================
class Scene_Item < Scene_Base
#--------------------------------------------------------------------------
# * Use Item (apply effects to non-ally targets)
#--------------------------------------------------------------------------
alias use_item_nontarget_ir use_item_nontarget unless method_defined?('use_item_nontarget_ir')
def use_item_nontarget
use_item_nontarget_ir
@item_window.refresh
end
end
Credit