class NPC include CoralMUD::FileIO # standard saving mechanisms. include CoralMUD::VirtualTags # vtags and indexing attr_reader :name, :flags def to_configure_properties ['@name', '@vtag'] end def initialize @name = DEFAULT_STRING end def to_s mxptag("send 'edit #{Tag.full_tag(self)}'") + "[NPC #{@vtag}]" + mxptag("/send") end def instance NpcFacade.new(self) end def data_transform_on_save map vtag = map['@vtag'] if vtag map['@vtag'] = vtag.to_s end return map end def data_transform_on_load version, map log :debug, "Transforming mobile." # transform the tag using the namespace vtag = map['@vtag'] if vtag assign_tag vtag, map['@namespace'] vtag = @vtag map['@vtag'] = vtag end return map end end module ScriptInterface # script methods unique to Npc instances. module NpcMethods def move arg # move the npc to a very specific room based on vtag. if arg.is_a? String elsif arg.is_a? Room # move them here if it's a room. end end end end class NpcFacade < Facade attr_facade :name include CoralMUD::HasStuff include CoralMUD::LivingEntity include ScriptInterface::NpcMethods def initialize thing super thing @in_room = nil end def short_desc return "#{self.name}" end # remove this specific NPC from the gamespace. # Any tidying up for when a NPC exits the game should be done here. def remove_from_gamespace # remove it from the room it's in. self.from_room # Possibly in the future return all switches. I.e. an admin taking over an NPC body. end @@corpse_proto = nil # make a corpse out of this npc. def make_corpse if @@corpse_proto == nil @@corpse_proto = Tag.find_any_obj("do.not.change::corpse.prototype")[0] # corpse prototype end # generate a new item based off of the corpse prototype. o = @@corpse_proto.instance # new corpse if ('A'..'Z') === short_desc[0] o.name = o.name % self.short_desc else o.name = o.name % self.short_desc.en.a end in_room.accept(o) # put the object in the same room. end end