Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

> [SSS] Disassemble Shop, Salvage your items rather than selling them.
Shanghai
post Jun 12 2010, 07:32 PM
Post #1


Level 31
Group Icon

Group: Revolutionary
Posts: 747
Type: Developer
RM Skill: Skilled




Shanghai Simple Script - Disassemble Shop
made by Shanghai



Link/Script
Click here

Introduction
This script creates a new scene where players can disassemble their unwanted items or break them down into something more basic. That broadsword which has been replaced by a mightier broadsword can now be broken down into various components and aid the player one last time rather than just sitting there in the inventory to rust.

How to Use
To load the disassemble shop, use the following evented script call:
CODE
$scene = Scene_Disassemble.new


Inside the shop, it will only list items with the following tag set inside of their noteboxes.
CODE
<disassemble>
weapon 1
armor 2
item 3
</disassemble>

Place this in the notebox of either an item, weapon, or armor and that item can then be disassembled into the materials you've placed in between the disassemble tags.

Compatibility
This script is not compatible with people who don't care about database efficiency.

For more Shanghai Simple Scripts
Visit Here.


__________________________
Go to the top of the page
 
+Quote Post
   
 
Start new topic
Replies
Neosky5k
post Mar 23 2012, 06:09 PM
Post #2


Level 2
Group Icon

Group: Member
Posts: 18
Type: None
RM Skill: Undisclosed




Anyone have Shanghai Simple Script - Disassemble Shop? Since they like to place their scripts on sites that don't exsist anymore it's kind of hard to get the original. So can anyone hook me up?
Go to the top of the page
 
+Quote Post
   
Broxibear
post Apr 3 2012, 12:43 AM
Post #3



Group Icon

Group: Member
Posts: 1
Type: Developer
RM Skill: Beginner




QUOTE (Neosky5k @ Mar 23 2012, 06:09 PM) *
Anyone have Shanghai Simple Script - Disassemble Shop? Since they like to place their scripts on sites that don't exsist anymore it's kind of hard to get the original. So can anyone hook me up?

CODE
#===============================================================================
#
# Shanghai Simple Script - Disassemble Shop
# Last Date Updated: 2010.06.13
# Level: Normal
#
# This script creates a new scene where players can disassemble their unwanted
# items or break them down into something more basic. That broadsword which has
# been replaced by a mightier broadsword can now be broken down into various
# components and aid the player one last time rather than just sitting there in
# the inventory to rust.
#===============================================================================
# Instructions
# -----------------------------------------------------------------------------
# To install this script, open up your script editor and copy/paste this script
# to an open slot below â–¼ Materials but above â–¼ Main. Remember to save.
#
# To load the disassemble shop, use the following evented script call:
# $scene = Scene_Disassemble.new
#
# Inside the shop, it will only list items with the following tag set inside of
# their noteboxes.
#
# <disassemble>
# weapon 1
# armor 2
# item 3
# </disassemble>
# Place this in the notebox of either an item, weapon, or armor and that item
# can then be disassembled into the materials you've placed in between the
# disassemble tags.
#===============================================================================

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

module SSS
# This is the text that appears in the disassemble shop.
DISASSEMBLE_ITEM = "Items"
DISASSEMBLE_WEAPON = "Weapons"
DISASSEMBLE_ARMOR = "Armors"
DISASSEMBLE_EXIT = "Finish"
DISASSEMBLE_INTO = "Disassembles Into"
end

#==============================================================================
# RPG::BaseItem
#==============================================================================

class RPG::BaseItem
#--------------------------------------------------------------------------
# disassembled_items
#--------------------------------------------------------------------------
def disassembled_items
return @disassembled_items if @disassembled_items != nil
@disassembled_items = []
disassembled = false
self.note.split(/[\r\n]+/).each { |line|
case line
when /<(?:DISASSEMBLE|disassmbled)>/i
disassembled = true
when /<\/(?:DISASSEMBLE|disassmbled)>/i
disassembled = false
when /(.*)[ ](\d+)/i
next unless disassembled
case $1.upcase
when "WEAPON", "W", "WEP"
@disassembled_items.push($data_weapons[$2.to_i])
when "ARMOR", "ARMOUR", "A", "ARM"
@disassembled_items.push($data_armors[$2.to_i])
when "ITEM", "I"
@disassembled_items.push($data_items[$2.to_i])
end
end
}
return @disassembled_items
end
end

#==============================================================================
# ** Window_Disassemble
#==============================================================================

class Window_Disassemble < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(help_window)
yy = help_window.height + help_window.y + 56
hh = Graphics.height - yy
super(0, yy, Graphics.width-240, hh)
self.active = false
self.index = -1
@help_window = help_window
self.item_type = 0
end
#--------------------------------------------------------------------------
# * Get Item
#--------------------------------------------------------------------------
def item
return @data[[self.index, 0].max]
end
#--------------------------------------------------------------------------
# * Item Type Change
#--------------------------------------------------------------------------
def item_type=(new_type)
if [0, 1, 2].include?(new_type)
@item_type = new_type
refresh
update_help
end
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
@data = []
for item in $game_party.items
next if item.nil?
case @item_type
when 0
next unless item.is_a?(RPG::Item)
when 1
next unless item.is_a?(RPG::Weapon)
when 2
next unless item.is_a?(RPG::Armor)
else
break
end
next if item.disassembled_items.empty?
@data.push(item)
end
self.index = -1 unless self.active
@item_max = @data.size
create_contents
for i in 0...@item_max
draw_item(i)
end
end
#--------------------------------------------------------------------------
# * Draw Item
#--------------------------------------------------------------------------
def draw_item(index)
rect = item_rect(index)
self.contents.clear_rect(rect)
item = @data[index]
if item != nil
number = $game_party.item_number(item)
enabled = true
draw_obj_name(item, rect.clone, enabled)
if $imported["BattleEngineMelody"]
draw_obj_total(item, rect.clone, enabled)
else
self.contents.draw_text(rect, sprintf(":%2d", number), 2)
end
end
end
#--------------------------------------------------------------------------
# * Draw Object Name
#--------------------------------------------------------------------------
def draw_obj_name(obj, rect, enabled)
draw_icon(obj.icon_index, rect.x, rect.y, enabled)
self.contents.font.size = Font.default_size
self.contents.font.color = normal_color
self.contents.font.color.alpha = enabled ? 255 : 128
rect.width -= 48
self.contents.draw_text(rect.x+24, rect.y, rect.width-24, WLH, obj.name)
end
#--------------------------------------------------------------------------
# * Draw Object Total
#--------------------------------------------------------------------------
def draw_obj_total(obj, rect, enabled)
hash = YEM::BATTLE_ENGINE::ITEM_SETTINGS
number = $game_party.item_number(obj)
dx = rect.x + rect.width - 36; dy = rect.y; dw = 32
text = sprintf(hash[:text], number)
self.contents.font.size = hash[:size]
self.contents.font.color = text_color(hash[:color])
self.contents.font.color.alpha = enabled ? 255 : 128
self.contents.draw_text(dx, dy, dw, WLH, text, 2)
end
#--------------------------------------------------------------------------
# * Update Help Text
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(item == nil ? "" : item.description)
end
end

#==============================================================================
# ** Window_DisassembleContents
#==============================================================================

class Window_DisassembleContents < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(body_window)
@body_window = body_window
super(@body_window.width, @body_window.y, 240, @body_window.height)
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item = @body_window.item
draw_disassembled_contents unless @item.nil?
end
#--------------------------------------------------------------------------
# * Draw Disassembled Contents
#--------------------------------------------------------------------------
def draw_disassembled_contents
self.contents.font.size = Font.default_size
self.contents.font.color = system_color
text = SSS::DISASSEMBLE_INTO
self.contents.draw_text(0, WLH/2, contents.width, WLH, text, 1)
self.contents.font.color = normal_color
yy = WLH*2
@item_amount = {}
for item in @item.disassembled_items
next if item.nil?
@item_amount[item] = 0 if @item_amount[item].nil?
@item_amount[item] += 1
end
for item in @item.disassembled_items.uniq
next if item.nil?
draw_item(item, 0, yy)
yy += WLH
end
end
#--------------------------------------------------------------------------
# * Draw Item
#--------------------------------------------------------------------------
def draw_item(item, xx, yy)
draw_icon(item.icon_index, xx, yy)
name = item.name
self.contents.font.size = Font.default_size
self.contents.draw_text(xx + 24, yy, contents.width - xx - 56, WLH, name)
amount = @item_amount[item]
if $imported["BattleEngineMelody"]
hash = YEM::BATTLE_ENGINE::ITEM_SETTINGS
text = sprintf(hash[:text], amount)
self.contents.font.size = hash[:size]
self.contents.font.color = text_color(hash[:color])
else
text = sprintf(":%2d", amount)
end
self.contents.draw_text(xx, yy, contents.width-4, WLH, text, 2)
end
end

#==============================================================================
# ** Scene_Disassemble
#==============================================================================

class Scene_Disassemble < Scene_Base
#--------------------------------------------------------------------------
# * Start processing
#--------------------------------------------------------------------------
def start
super
create_menu_background
@help_window = Window_Help.new
@item_window = Window_Disassemble.new(@help_window)
@contents_window = Window_DisassembleContents.new(@item_window)
create_command_window
end
#--------------------------------------------------------------------------
# * Termination Processing
#--------------------------------------------------------------------------
def terminate
super
dispose_menu_background
@command_window.dispose
@help_window.dispose
@item_window.dispose
@contents_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
update_menu_background
if @command_window.active
update_command_selection
elsif @item_window.active
update_item_selection
end
end
#--------------------------------------------------------------------------
# * Create Command Window
#--------------------------------------------------------------------------
def create_command_window
array = []
array.push(SSS::DISASSEMBLE_ITEM)
array.push(SSS::DISASSEMBLE_WEAPON)
array.push(SSS::DISASSEMBLE_ARMOR)
array.push(SSS::DISASSEMBLE_EXIT)
width = Graphics.width
@command_window = Window_Command.new(width, array, array.size, 1, 8)
@command_window.y = @help_window.y + @help_window.height
@last_command_index = 0
end
#--------------------------------------------------------------------------
# * Update Command Selection
#--------------------------------------------------------------------------
def update_command_selection
@command_window.update
if @last_command_index != @command_window.index
@last_command_index = @command_window.index
@item_window.item_type = @last_command_index
@contents_window.refresh
end
if Input.trigger?(Input::
Sound.play_cancel
$scene = Scene_Map.new
elsif Input.trigger?(Input::C)
Sound.play_decision
case @command_window.index
when 3
$scene = Scene_Map.new
else
@command_window.active = false
@item_window.active = true
@item_window.index = 0 if @item_window.index == -1
end
end
end
#--------------------------------------------------------------------------
# * Update Item Selection
#--------------------------------------------------------------------------
def update_item_selection
@item_window.update
if @last_item_index != @item_window.index
@last_item_index = @item_window.index
@contents_window.refresh
end
if Input.trigger?(Input::
Sound.play_cancel
@command_window.active = true
@item_window.active = false
elsif Input.repeat?(Input::C)
disassemble_item = @item_window.item
if disassemble_item.nil?
Sound.play_buzzer
else
Sound.play_shop
$game_party.lose_item(disassemble_item, 1)
for item in disassemble_item.disassembled_items
next if item.nil?
$game_party.gain_item(item, 1)
end
@item_window.refresh
@item_window.index = [@item_window.item_max, @item_window.index].min
@contents_window.refresh
end
end
end
end

#===============================================================================
#
# END OF FILE
#
#===============================================================================


This post has been edited by Night_Runner: Apr 3 2012, 05:18 AM
Reason for edit: Please put large sections of code in a codebox
Go to the top of the page
 
+Quote Post
   



Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 19th June 2013 - 10:38 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker