# # file:: cmd_replicate.rb # This source code copyright (C) 2009 Craig Smith # All rights reserved. # # Released under the terms of the TeensyMUD Public License # See LICENSE file for additional information. # module Cmd bindtextdomain("cmd") # Replicates changes to a parent object to all clones def cmd_replicate(args) case args when /#(\d+)/ pid = $1.to_i parent = get_object(pid) if parent if parent.is_a? Account or (parent.is_a? Character and not parent.is_a? Mobile) sendto _("Invalid Object type") return end if not parent.isclone count =0 objs = world.find_objects(parent.name) objs.each do |o| if o.parentid == parent.id # Replicate some data o.name = parent.name.dup o.desc = parent.desc.dup o.aliases = parent.aliases.dup o.weight = parent.weight o.cost = parent.cost # These may have been altered from use o.attributes = o.attributes.concat(parent.attributes).uniq o.val.merge!(parent.val) o.modifier.merge!(parent.modifier) count += 1 if parent.is_a? Mobile o.skills = parent.skills.dup # Only replicate some stats o.set_stat(:exp, parent.get_stat(:exp)) o.set_stat(:intel, parent.get_stat(:intel)) o.set_stat(:strength, parent.get_stat(:strength)) o.set_stat(:endurance, parent.get_stat(:endurance)) o.set_stat(:maxhp, parent.get_stat(:maxhp)) o.set_stat(:maxmp, parent.get_stat(:maxmp)) o.set_stat(:level, parent.get_stat(:level)) o.set_stat(:cash, parent.get_stat(:cash)) end if parent.is_a? Merchant o.forsale = parent.forsale.dup o.buytype = parent.buytype.dup o.buyattribute = parent.buyattribute.dup o.buydtype = parent.buydtype.dup o.markup = parent.markup end end end sendto _("Replicated to %{count} objects." % {:count => count}) else sendto _("You must specify the original parent Oid.") end else sendto _("Invalid Oid.") end else sendto _("Usage: @replicate #oid - Replicates parent object changes to all clones") end end end