Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> [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
   
Kread-EX
post Jun 13 2010, 12:47 AM
Post #2


(=___=)/
Group Icon

Group: +Gold Member
Posts: 4,136
Type: Scripter
RM Skill: Undisclosed




This, madam, is something I'm going to steal for my game.


__________________________
FRACTURE - a SMT inspired game (demo) made by Rhyme, Karsuman and me. Weep and ragequit.

My blog.

Click here for my e-peen


Go to the top of the page
 
+Quote Post
   
leongon
post Jun 13 2010, 10:41 AM
Post #3


Leongon of the Village of Awesome
Group Icon

Group: Revolutionary
Posts: 1,006
Type: Developer
RM Skill: Skilled




I know you don't take ideas, but I lose nothing else than a few seconds trying to help.

A good addition could be a second value being chance, and if ommited is 100%, like:

<disassemble>
weapon 1
armor 2
item 3 70
</disassemble>


__________________________
Leon's Basic VX Scripts of Awesome:
Step 1. Passive Skills - Create skills that add passive bonuses. (shitty)
Step
2. Learning from Everyone - Learn skills from enemies, or allies, without being the target of the skill. (nice)
Step 3. Dual Battle Landscapes - Set background and foreground image for your battles. (nice)
Step 4. State Details - Add description to states, and allow viewing them on menu, and in battle. (nice)
Step 5. Item Quality Colors - Colourize item, weapon, armor and skill's name according their quality or affinity. (very nice)
Step 6. Skill Trees - Your actors can have talent trees now, like in the MMORPGs. (extremely nice)
Step 7. Main Menu Manager - Easy, straight, and intuitive total control of commands for the main menu. (very nice)

Drawing commissions are open. Facesets... monsters... anything: click here.


---------------------------------------------------------------------------------------------------------------------------------
Second place again xD
Deadly Christmas setup. 8.04 score... this one was not so fail. Yay!
Twist of Fate. Worst game in the competition... Yay!
Tie with two more guys out of 6 participants, so fail... Yay!
Go to the top of the page
 
+Quote Post
   
new
post Jun 17 2010, 07:02 PM
Post #4


Level 4
Group Icon

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




what crafting system would be best here? YERD item synthesis?
Go to the top of the page
 
+Quote Post
   
Shanghai
post Jun 17 2010, 07:13 PM
Post #5


Level 31
Group Icon

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




Anything but cmpsr's.


__________________________
Go to the top of the page
 
+Quote Post
   
Talos15
post Aug 4 2010, 11:36 AM
Post #6


Level 2
Group Icon

Group: Member
Posts: 24
Type: Developer
RM Skill: Skilled




I love it! Similar to FFXIII's system which I need for my game. biggrin.gif Thanks!
(Come to think about it... I going to have a lot of notetags in my note box)

Does that affect anything? Like if too much notes, some notes don't work or all...?

I'm thinking no, but it's worth asking.
Go to the top of the page
 
+Quote Post
   
Destinynite1
post Aug 5 2010, 03:22 PM
Post #7


Level 11
Group Icon

Group: Revolutionary
Posts: 193
Type: Developer
RM Skill: Masterful




Very nicely done. Works like it says =) Now is there a way to make the disassemble more then one of the same item without having to put in 2, 3 or 4 separate tags? Such as

<disassemble>
weapon 1
armor 2
item 3, 3
</disassemble>

instead of

<disassemble>
weapon 1
armor 2
item 3
item 3
item 3
</disassemble>


__________________________
Current Project


1. Legends of the Four

Database - 75%
Scripting -55%
Storyline - SCRAPED (OPEN WORLD)
Character Skills - 100%
Monster Skills - 60%
Item Creation Skills- 45%
Everything else - No idea xD

Go to the top of the page
 
+Quote Post
   
Talos15
post Aug 11 2010, 10:39 AM
Post #8


Level 2
Group Icon

Group: Member
Posts: 24
Type: Developer
RM Skill: Skilled




QUOTE (Destinynite1 @ Aug 5 2010, 04:22 PM) *
Very nicely done. Works like it says =) Now is there a way to make the disassemble more then one of the same item without having to put in 2, 3 or 4 separate tags? Such as

<disassemble>
weapon 1
armor 2
item 3, 3
</disassemble>

instead of

<disassemble>
weapon 1
armor 2
item 3
item 3
item 3
</disassemble>

Yeah that's true! I know for example in my game some items i want to disassemble does item 5 like 10 times... it'll make the note tag for the items less "crowded".
Go to the top of the page
 
+Quote Post
   
Zeriab
post Aug 11 2010, 12:17 PM
Post #9


Level 12
Group Icon

Group: Revolutionary
Posts: 196
Type: Event Designer
RM Skill: Skilled




Nice script happy.gif

Do only this part deal with finding disassembled items in the note?
CODE
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


In that case the following edit should hopefully do it: (I haven't tested it)
CODE
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 /([^\s\d]*)\s*\d/
        next unless disassembled
        case $1.upcase
        when "WEAPON", "W", "WEP"
          item_ids = line.scan(/\d+/)
          items = item_ids.map {|id| $data_weapons[id.to_i]}
          @disassembled_items.push(*items)
        when "ARMOR", "ARMOUR", "A", "ARM"
          item_ids = line.scan(/\d+/)
          items = item_ids.map {|id| $data_armors[id.to_i]}
          @disassembled_items.push(*items)
        when "ITEM", "I"
          item_ids = line.scan(/\d+/)
          items = item_ids.map {|id| $data_items[id.to_i]}
          @disassembled_items.push(*items)
        end
      end
    }
    return @disassembled_items
  end
end


I changed the /(.*)[ ](\d+)/i regular expression to /([^\s\d]*)\s*\d+/. There was no reason to test for case insensitivity so I removed that.
I changed the space requirement to allow for any amount of whitespace before the first digit to reduce potential frustration. I also made it optionally. Discarding whitespace if you are pressured on room in the note is a bonus.
The grouping captures the text until a whitespace character or a digit is met and stores this in $1 which you use to determine type of item. Note that it only checks for the existence of a single digit so the regular expression probably won't check the entire string of a valid match. (Why should it)

In each item type I scan for groups of digits to retrieve an array of numbers. (Remember that they are still strings)
I then map them to their respective objects and use the * operator to expand the array into a list of arguments.

Note that one can add a, say weapon, multiple times. I did not alter this functionality since it may have been intentional. I am just pointing it out in case you hadn't considered it.

*hugs*


__________________________
Go to the top of the page
 
+Quote Post
   
Neosky5k
post Mar 23 2012, 06:09 PM
Post #10


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 #11



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: 25th May 2013 - 10:42 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker