Up to Main Index                           Up to Journal for October, 2020

                   JOURNAL FOR WEDNESDAY 14TH OCTOBER, 2020

SUBJECT: Updates for holding, wearing and wielding
   DATE: Wed 14 Oct 19:06:56 BST 2020

Another busy week working on WolfMUD and this time I have a public dev branch
update available. The update saves and loads the state of held, worn and/or
wielded items for players. It also enables mobiles to hold, wear and/or wield
items when they are loaded. However, mobiles won’t necessarily respawn using
their items — an issue I’m currently working on.

Am I happy with my solution? Not really, but it works. I’ve added three new
attributes, and updated the docs/zone-files.txt documentation. The attributes
are Holding, Wearing and Wielding. Each attribute takes a list of references
similar to the Inventory attribute. For example, a mobile might be defined
with the following:

   Holding: O1 O2
   Wearing: O3 O4
  Wielding: O5 O6

Assuming the mobile has the items in its inventory, has a Body defined — and
the Body slots required by the items are available — then: The mobile will
hold items O1 and O2, wear items O3 and O4 and wield items O5 and O6. Pretty
simple stuff.

When a player is saved the player file is written using the same attributes to
record how items are being used so that their state is restored when the
player file is loaded again.

I’ve added Load and Save methods to Thing. Calling these methods will call any
load or save methods (non-exported) found on any attributes for the Thing. The
Load method runs post-unmarshaling and Save runs pre-marshaling. Both methods
are recursive into inventories, depth first. This means that if an item, such
as the doll wearing a dress[1], is in a player’s inventory it will still be
wearing the dress if the player file is reloaded. This also means you can
define items that are being used within inventories in zone files.

I’m now thinking that the Load and Save methods calling load and save might be
a little too ‘magical’ and might be implemented better as a callback, for now
it is what it is.

Thing has a new Ref method which returns the reference (from the Ref field in
the record jar) found when unmarshaling the Thing. Inventory has a new method
SearchByRef which will find the first Thing in an Inventory with the given
reference. The EXAMINE/EXAM command has been updated so that examining a Thing
with a Body will describe what items are being used.

The Zinara zone file contains a number of changes. The city guards now have
and use some equipment — helmet, cuirass, boots and shortsword. The flower
girl now has a dress and bunch of flowers. Players can find the helmet and
cuirass the guards use at the armoury.

I’ve also left in the child’s doll which can be found in the pawn shop. It
currently suffers the same issue as mobiles — the original state of the dress
will not be restored on a reset — I’m working on it…


  [1] See: Hello dolly, you’re giving me problems… 4.html

  Up to Main Index                           Up to Journal for October, 2020