Fixing the Wearing Mechanics #18
Replies: 6 comments 23 replies
On Using Sets for Worn ItemsIn alan-if/alan#35#issuecomment-886834334 you mentioned that using Sets could be a viable alternative to having a
I vaguely remember considering this approach when I was testing various alternatives for the StdLib, although I don't recall the implementation details I've actually tried and why Sets were discarded (it might just be that I didn't investigate them well). Considering that any actor (not only the Hero) could be wearing items (clothes, glasses, helmets, ecc.), we need to figure out a method that is simple to handle for authors, especially if they add their own verbs to an adventure. The reason I went for a simple IMO, Sets complicate things because Set attributes are implemented on the Actors, not the object, so author creating new VERBs that relocate object would have to first check if the item is worn, and (if it is) find out who's wearing it in order to remove it from the wearer's Set of I remember that during my experiments I was really pleased when I came up with those three rules about what a Item don't accidentally end up being worn in an adventure, they are either:
So, ultimately authors have full control over VERBs (and their commands) and SCRIPTs that make change a wearable item's status from worn/unworn. The only dangers lie in VERBs and SCRIPTs which might be moving around worn items without setting them to Of course, whether a game should allow relocating worn items ultimately depends on the author's choices and rules — Should the player be allow to simply TAKE an item worn by an NPC? or THROW it, ecc.? Should such commands work for items worn by the Hero? or should the player first REMOVE an item before being able to DROP it, THROW it, GIVE it, ecc.? — these are all personal choices, so there's no standard or golden rule for these; and I believe that a Starter Library should not enforce opinionated choices in this respect. Going back to using Sets instead ... I'd love to read about your idea on how to use them, because I'm quite sure I haven't explored their potential deep enough when searching for alternative "wearing" implementations. |
|
Remember that I'm not a "real" Alan author, just the implementor ;-) So I don't have much experience to throw into this discussion, just ideas. Having a So I totally ok with you proceeding with this approach. We can probably try it out later, and as we go along, we learn what problems it may bring. Just to make this clear:
If the answer to my question is yes in the middle there, then the action of removing a worn object is probably also just The "ad hoc" inventory verb (and description of actors, if they can wear things too) need only to distinguish worn object by them being wearable and has the |
Lib v0.2.0 Draft AvailableOK @thoni56, I've implemented the new wear mechanics, which you can preview in the dev_alan-en branch already. I still need to fix all the verbs that move around objects, to ensure they are set to unworn status — but we'll also need to discuss whether an item worn by an NPCs should be allow to be moved around by the Hero or not, e.g. via verbs like 'throw', 'put in', etc., or if these attempts should result in an error message saying that the wearer would object to this. Deciding the default course of action is always a difficult task. Anyhow, in the end I had to implement two attributes, not just one:
So, we now have to always manipulate two attributes. But I think it's still worth it, for You'll find all the details in the CHANGELOG document. Now I need to add a testsuite and start checking that everything works as expected, so it's going to take some time before these changes are squashed into Please, let me know what you think of the new system. PS: I think that the |
English Test Suite@thoni56, I've now added a basic test suite to English dev branch, which currently covers only wearables. The reason it took me so long was partly due to my need to get off the PC for a couple of days, but also because I took a whole day digging into Ruby and Rake to come up with a good solution to handle transcripts generation (I've found an excellent solution, only need to implement it now). As you can see from the generated test transcripts, there are still many verbs which execute an implicit taking which should probably be prevented when dealing with worn items: So, should I block these actions on all actors, or just on Since it's all about VERB CHECKs, it's easier for author to add those checks on their custom classes, whereas removing them implies altering the library sources. I think that enforcing them only on Then, of course, we'll have to look into the error messages of these verbs, which need to be precise. I've found some rather strange library bugs during this work, e.g. with the As a final note: Rake is making life so much easier! Just having to type |
On Handling Worn Items@thoni56, I've been doing some tests regard restricting handling worn items. My idea was to prevent implicit taking an item only if it's worn by a The problem here is that it's not possible to handle this via (tried other variations too, but there seems no way of negating the Which means that the restriction has to be done in the verb body, like: Of course, this approach is much more limiting, for authors won't be able to handle custom classes by simply adding an extra CHECK, but will have to either edit the original library verbs or re-implement them on each class, if they want to also restrict the action on custom Currently, the only library verb doing an implicit take action is the Obviously, some actions are made simpler by having their VERB do an implicit taking, but the downside is that it's not easy to predict whether the taking attempt will fail (abruptly) or not, since there's no way of trying the action. So, what are you suggestions in regarding to the above point? |
Ready to Polish and Merge?@thoni56, now that the whole issue of how to prevent handling worn items has been resolved by leaving it to end authors, and having removed implicit taking from the library, I would then probably say that the wearing mechanics are now fixed and probably read to be merged into a new library update ( But before that, I'd like to make sure we're not forgetting anything (in any case I'll need some time to break the branch changes into multiple commits, because it contains too many changes — new Rake feature, the test suite, the new docs, etc.). All Library changes have been annotated in the CHANGELOG of the dev branch, and all the tests in the new test suite seem to indicate that feature is working correctly. I could possibly add some extra testing, e.g. by adding an event that runs at every turn to see if it can find an object which is lying around and is set as In any case, even if there's a bug we'll probably catch it later on, as the test suite grows, and surely before v1.0.0 is out.
E.g., we've focused mainly on clothing when thinking of wearables, but are there some other types of wearables which we didn't consider and which might deserve some extra features or considerations? |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I noticed that the current libraries (EN/ES) adopt a similar approach to clothing items as the StdLib used to, i.e. via the
wornentity as a separate Container for the Hero's worn items.We've already seen the potential problems with this approach, as discussed in AnssiR66/AlanStdLib#57, and the new StdLib now uses a different approach where basically
wornis just an attribute, and every VERB that moves around objects has to take care of setting them asNOT wornto ensure that there are no objects marked aswornwhile not being IN a character and/or being effectively worn.The implementation details of the new approach I've enforced are described in detail in the
CLOTHING_NEW.mddocument.The core definition if the new system id described in the following section (from the above mentioned document):
I believe that the current libraries in this repo suffer from the same limitations and potential problems as the previous StdLib did, and that we should get rid of the
wornentity.New System Pros
The proposed solution turned out to work very well, and was thoroughly tested. The new system is much simpler, since worn items are still IN the Hero actor. Furthermore, the same criteria is now used for handling items worn by NPCs (e.g. when listing carried and worn items). As and added bonus, wearable items are not restricted to clothing only, but can also be applied to any object or class (e.g. wearable devices, etc.).
I never quite understood why the
wornentity system was implemented in the first place, it seems to me overtly complicated and error prone, but then I might ignore the constraints of the ALAN language during those years. I guess that it just carried on being inherited (and expanded upon) by further incarnations of the libraries, until new ALAN features come into being, ultimately leading to conflicts between them and the old system.New System Cons
The downside is that authors need to ensure that any custom VERB that they add to their games, which might result in transferring objects from actors, needs to ensure that the moved object is always marked as
NOT worn(in case it was). This is something that new authors might overlook, and which could lead to adventures breaking-up badly due to bad objects states.Final Thoughts
As a final consideration, the libraries in this project don't have a dedicated clothing class, so any object marked as
wearablecan be worn. This is probably good for us, since we don't need to make any distinction between clothes and other wearables (glasses, helmets, etc.).The StdLib offers a rather sophisticated system to handle clothing layers, and how each clothing item maps to various body regions and wearing-layers, which prevents players to wear/disrobe clothes in the wrong order (e.g. wearing boxers while wearing trousers) or wearing two items belonging to the same body region and layer (e.g. two shirts). I believe that this level of sophistication is well beyond the needs of a Starter Library, and might actually stand in the way of its openness to customization; but we should nonetheless give some thought on how end users might implement such constraints — e.g. how hard would it be to prevent players to wear two clothing items at once?
I guess that subclassing would be the way to go. Since the wearing mechanism would be class-agnostic, any items that shouldn't be worn together could be rendered as a custom class, and CHECKs added to ensure the actor is not wearing (i.e. containing as
IS worn) items from the same class.What are your thoughts about the potential problems of the current wearing mechanism, and whether we should fix it?
Consistently Enforce Changes across Libraries
If we decide to embrace this change, it should be applied to all existing libraries (EN, ES) as well as those in the making (IT, SV) so that it becomes a commonly shared feature in v1.0.0 — then any new ports would just follow the example.
Creating a Test-Suite before Proceeding
Of course, we'd also should set up a test-suite to cover the current wearing system (and its bugs) and any changes to it, in order to ensure that the transition goes smooth. We could probably reuse some of the tests found the StdLib to do this, with some minor code tweak:
https://github.com/AnssiR66/AlanStdLib/tree/dev-2.2.0/tests/clothing
All reactions