Thursday, January 4, 2018

CAOS Notes: FACE, LIMB, and a little CHAR

Lately I've felt like I've wanted to write a little more in-depth about certain CAOS commands and techniques. I don't really have an order or priority for these things, so my plan is to just work on my stuff normally, and if in my CAOSing travels I come across something that might be of use to other people, I'll try to write about it in the clearest manner that I can.

The Conundrum 

Like a lot of things I look to develop, this one seeks to solve a specific problem. Take a look at little Miss Baker here, a survivor from my last batch of SERU creatures. She's got a lovely Dustdevil Grendel head and a fierce personality, but she's actually a norn, according to her genus. I decide to export her and bring her into a world with more of her kind, but what's this?

When I go to import her, I don't see the face I expected! Instead, there's a Harlequin face where a Grendel face should be! This seems to be an unfortunate bug in the creature import script. I could have sworn that there was a patch for this, somewhere, at some point, but I haven't for the life of me been able to find it. Maybe I imagined it, but if anyone can find the original fix for this and who did it first, I'd like to credit them. Update: This fix is among one of the many enhancements included in Apollo's GUI Update! But in the meantime I thought I'd write my own fix and document exactly why it works in the process.

About FACE

Before we get into the import code itself, let's take a quick look at the FACE command. There are a number of versions of FACE, but the one we're looking at here is the string version:

You really only need to worry about the highlighted bit here because the rest of the command was never implemented. This is pretty straightfoward-- you TARG a creature, and then FACE will equal the filename of the headsprite in its baby form.

As an example, this simple command prompts all creatures to proudly say their (baby) head sprite filenames. FACE is a unique command in that it's the only command (to my knowledge) that actually gets any information about an actual living creature's actual sprites at all. (It's a little frustrating because I personally would love to be able to get information about the rest of a creature's body parts, but sadly the head sprite information seems to be the only thing we can get). 

When a creature gets exported, a lot of information about it gets saved to its prayfile, including its FACE sprite filename (in "Head Gallery"), genus, gender, and life stage. This is the information that the import script looks for when it goes to import a creature. Before we get too deep into that though, let's look at another way to get a sprite filename.

Looking at LIMB

LIMB differs from FACE primarily in that it can return the filename of any body part, but it can only return them when it is given the exact parameters of what to return. It cannot return the filename of a part of an actual living creature.

You might be tempted to reference the Sprite file format to figure out which parameters to stick where to get want you want, but LIMB actually does things a little differently. All the parameters must be integers, so you can't rely on using 'a' for the head or 'c' for the breedslot. The conversion, thankfully, is just a matter of using integers 0-25 instead of a-z

Additionally, you'll notice that genus and gender are separate parameters, while the breed filenames combine the two into one. With all these differences, it might just be easier to reference a table like this to find the numbers you need when looking to define LIMB:

So for example, LIMB 1 1 3 4 1 would return the filename for the sprite containing the body of a norn who is female, of adult age, and in slot B. If you wanted the head sprite of an old male banshee grendel, you'd use LIMB 0 2 1 5 1. All in all, LIMB is pretty straightforward, but its star feature is its ability to approximate. If you enter a slot that a breed doesn't exist in, or look for baby sprites in a breed that has no baby sprites, LIMB will return the closest match, much like what happens when you send a treehugger norn to a friend who might not have treehuggers installed.

If' you're following closely, you might already be able to guess what the problem is with the import script. Let's take a look.

This looks pretty straightforward, right? In this script, ov99 refers to the exported creature, and you can see that the LIMB parameters are being pulled from the PRAY information. Genus, gender, and life stage are set in variables that are used to find the face sprite with LIMB in the very last line.

If you can already see the problem, be patient one moment while we talk about what's going on in the middle there, where va04, the breed slot, is being set. After all, we can get the breed slot letter from the head sprite filename, but remember that LIMB takes numbers, not letters. CHAR holds the solution to that conversion.

Cheers For CHAR

Before delving into this script, I don't think I had ever even used CHAR, not once! At a glance, it's a pretty straightforward.

Makes sense, right? So if you used CHAR "norn" 2 you'd get 'o', right? That was my first instinct, as someone with very little programming experience outside of CAOS. But actually, you get 111. CHAR does not return the actual character; instead, it returns the ASCII decimal code of that character.

You can find a nice ASCII chart and lookup tool here, but you don't necessarily need it to understand why this is useful. In the import script above, you can see that va04 is being set to the fourth character of the head sprite filename, which is the breed slot. Now that va04 contains the breed slot, or at least, the decimal code for the breed slot, the final line subv va04 'a' subtracts the decimal code for 'a' from the decimal code for the breed slot, leaving you with the number between 0 and 25 that LIMB is looking for!

If you're not quite getting this, it can help to know that the decimal code for 'a' is 97, the code for 'b' is 98, and so on. If you have the code for 'c' (99) and subtract the code for 'a' (97), you'll get 2, which translates to breed slot C as far as LIMB is concerned. You can use this same trick to convert the body part letters to numbers if you need to.

Thank you for holding out through that little detour. Now let's get back to the import script and finding our problem.

The Guilty Genus

Let's recap really quick. When we export a norn with a grendel head, the import dialogue shows her face as being that of a norn instead of a grendel. Have you glimpsed the bug?

That's right. The import script is getting the genus parameter for LIMB from the creature's genus instead of the genus the sprite is using. So in the case of our dustdevil-headed norn, the import dialogue is looking for slot X in the norn genus (which it approximates as the harlequin's O since I haven't added any other norn breeds to this install) instead of the grendel genus, where the dustdevils reside.

To fix this, we need to get the genus from the head sprite filename instead of the creature itself. According to the breed sprite naming convention, the second character of the filename holds information about both the genus and the gender of the creature. To find just the genus, all we need to do is subtract 4 from it if it's a girl, and then add 1 to it, to make up for the fact that LIMB requires genus indices to start at 1. The repaired script looks something like this:

And our beloved miss Baker can display her grendliness proudly:

If you're feeling audacious, try applying this fix to your own file yourself! Otherwise, you can just download the Import Faces Patch here. It's a cosfile meant to be dropped in the bootstrap folder.

Whew, I know that was a little long winded, but I hope this makes some things clearer regarding these CAOS commands. See if you can get creative with FACE and LIMB! Pilla's using them to make spooky ghosts of the dead!

If you have any questions, got confused at any point, or have any insights, corrections, or things that I missed, please leave a comment and let me know! Furthermore, if there's any CAOS commands or techniques in particular that you would like to see explained or clarified, let me know too. I can't make any promises that I'll get around to replying to them as I've got a lot on my plate already, but sometimes getting inquiries like that can help to inspire me out of a rut, so it never hurts to ask!

Wednesday, December 6, 2017

CCSF Hype Continues

 CCSF 2018 Survey

Since this blog probably isn't your only source of Creatures news, you're probably already aware that the CCSF 2018 Survey is already underway, courtesy of Pilla and Ylukyun. If you weren't aware, well, now you are! Go take it! Round One will "probably run for 2-ish months" so you likely have until the end of January to get your input in.

I'm pretty excited about this for a couple of reasons! For one, I feel like the timing makes a lot of sense. If you've attended other annual events, such as conferences, conventions, shows, or parties, you've probably noticed that closing ceremonies often include previews and plans of what the organizers hope to do to make the next year's event even better. Registrations/signups/tickets for the future event are often made available right away to take advantage of the hype that's already there (and to take the edge off the sadness of the event coming to a close). The CCSF generates a lot of activity and helps to bring community members out of lurkmode. It excites, motivates, and inspires us. To me, it just makes sense to ride that hype train into planning the next event while so many people are active and brimming with ideas!

My second reason for loving this early planning is a little bit more personal. To be blunt here, November and December are just horrible months for me to get involved in anything. I got lucky this year and was severely bitten by the coding bug back in August so by the time November rolled around I had a handful of things to share, but for the last several CCSFs I've just been way too busy to even consider developing anything. Unfortunately when we wait until nearly halfway through the year or even later to start the surveys, those two months tend to be the only options by the time the surveys wrap up. The fact that this survey is running so early means that there's a greater chance we might get an August, September, or October CCSF, which would just work out so much nicer for me personally. Of course, we'll see how the majority feels, but it's nice to have that hope.

I believe a well-planned CCSF is not only important for our community, but also for our future. A successful CCSF has the potential to show off the dedication and enthusiasm of our community to inactive community members, future creatures-players, and even game developers! 2018 will be our 15th CCSF, can you believe it? What a milestone!

Before I wrap this up, I would like to toss out a suggestion to anyone who might be interested in but intimidated by coordinating next year's festivities: you don't have to do it all alone! Taking charge of such an iconic event can be daunting, but once you're elected, there's no reason that you can't build a team or at least select a co-coordinator or two! Pick people whom you already know you work well with and can balance each other's strengths and weaknesses. Recruit people to help you publicize, handle submissions, run events, design the site, anything! There's a lot of talent to be found and there's no reason one person should have to do it all alone. It's a community spirit festival, after all!

Meanwhile, I'm going to be swamped with work and local holiday preparations until the new year, but I'm hoping after that I'll find the time to buckle down and work on some stuff I've been hoping to check off my endless projects list for years. Such an active presence of Creatures fans on Discord has done a lot to ignite my flame again! Hopefully it'll last long enough to see at least a couple things through to completion.

If you don't hear from me again, I wish you all a happy holidays and a fruitful new year!

Monday, November 27, 2017

The Biggest Waste of Time And How To Use It

Alright, so here is my uh .. I guess actual, kind of sort of fitting (in that it at least promotes collaboration in some form), CCSF release.

In truth it's not anything all that interesting or spectacular or game-changing, but I'm pretty sure I put more hours of solid work into this than I did in the Garden Box. Heck, after writing this I feel like re-writing the Garden Box would be a piece of cake, but that's another story.

Anyway, before I stray too far off topic, allow me to present to you Advanced Protective Tub, now with bonus control panel:

This post is gonna get long, so I'll spare you the scrolling and give you the download link here. The zipfile includes the agents' catalogue file, which you may not need but it will make your life easier if you have a split installation that prevents your catalogue files from unpacking into the folder that DS actually reads them from.

When I developed the original Protective Tub, I had hoped that people would enjoy making custom name lists, and they certainly did! But the more interesting lists people developed, the more I really wanted to be able to switch easily between them without having to swap catalogue files. I also wanted to mix and match different name lists and have a few extra features to boot, so this agent is the result of my attempts to do all of those things.

Anyway, here's how you use it:

The control panel appears upon injection and allows you to choose catalogue tags from which to randomly generate first and last names for your Creatures. You can select one or several tags, add custom tags, preview tags, and choose formatting and inheritance options. Each set of this settings can be saved in different profiles, shown in the top row of icons.

The first top-left button selects your settings profile for the current world you are in. This is the profile that actually affects the world you are in, right now! All autonaming that happens will draw from the settings in this profile, so if you feel like your settings aren't taking, make sure you've set things up under the right profile! This is the profile you will probably be using 99% of the time and it will be the profile that is already selected when you first inject the agent. Remember, if a button is grayed out, it's because you are already in that profile.

The second button is the default profile, which is what settings for new worlds will default to. If you change these settings, close the control panel, then save and load into a brand new world and inject Protective Tub, the settings for your new world will be the same as the settings you saved in the default profile. This is intended to prevent you from having to set up your ideal profile again every time you start a new world!

The last four buttons are custom profiles which you can set up to your liking, to suit specific themes, etc. Much like the default profile, these are saved across worlds, so once you set them up it should be easy to start up a new world and load settings from your favorite profile.

The last two top row buttons are Copy to World and Copy to Default. Clicking one of these buttons will apply your currently selected profile to your World or Default settings. This is the simplest way to make a custom profile active in your current world.

When you feel like you're done setting everything up, clicking the red X button will save your profile options to your Journal folder and hide the window. You can also use the Backspace button on your keyboard, if you are tired of clicking by now.

You can bring the panel back up at any time by clicking the small duck-shaped button above the selected Creature's name, or by re-injecting the agent.

If all this is information overload, rest assured that you can still enjoy Protective Tub completely from the World Profile alone. The other profiles are totally optional features and you can just ignore them if you like!

Now, the actual settings.

This panel uses two lists: one for the left side or first names and the other right side or last names. These lists are populated by the names of catalogue tags that contain potential creature names. You can use the up and down arrows on each side to view each list independently. If your game detects input from the scroll wheel on your mouse, you can hover over the side you which to browse and scroll up or down that way.

Tag names colored in green are active and will be used to generate names (if/when those settings are applied to the current world). You can activate or deactivate a tag by selecting it and either clicking the checkmark on its respective side, or by selecting it and clicking it again.  If no tags are active on the right or left side, the autonamer will be disabled until one or more tags are made active on each side. (If you wanted, you actually could deactivate all tags on your active world profile to prevent autonaming and as new creatures hatched you could switch to a custom profile and use the Test Name feature we'll explain later to generate names until you find one you'd like to apply to your hatchlings.)
There are two more buttons on each the right and left side between the select and page down buttons. The first of these is the Import button. Upon selecting this you will go into Import Mode, in which you can enter the name of a catalogue tag that you would like to add to the list.

This could be from a file you downloaded or a custom list that you made, though you can technically add any tag from the games catalogue that you like ('Moniker Friendly Names 1' is a fun one).

It's important to make sure you click the correct button-- the left import button will add the tag to the left side/first name list, and the right button will add the tag to the right side/last name list.

If you are having trouble adding your tag, make sure that the catalogue file is in the directory and check that you have entered the name of the TAG, not the file itself. You can find the tag names by opening the .catalogue file and looking for the name in quotes after the word TAG. Check the file carefully, as one catalogue file can contain multiple tags!

Please keep in mind when making your own name lists or downloading others that two of the same TAG names cannot exist, even in different files, or the game will not load! If you have downloaded or are editing an old 'random_name_bits.catalogue' file, you will need to rename both the file and the tags inside it to ensure they don't clash with other tags.



Personally I have been using < and > to denote tags that are specifically made with for the left or right side in mind, but ultimately you can add tags you whichever side you want. I would also suggest sticking your name or initials somewhere in the tag name if you plan on releasing it to the public, just to make sure it doesn't clash with anyone else's tag names!

 The second button on each side is the Preview button. Selecting this will take you into Preview Mode for the tag you have selected. This way you can see exactly what sorts of names are available in that tag. You can also enter Preview Mode by right-clicking on a selected tag. You can scroll with the arrow buttons or using the scroll wheel on your mouse (if your game supports it). Clicking the X in either Import or Preview modes will return you to the main menu. You can also use the Backspace key on your keyboard to return from Preview Mode.

On the bottom left side are buttons for two options panels. The first is Inheritance Options which allows you to enable the passing down of name portions from parent to child. You can select for children to inherit their first, last, or a random part from their mother, father, or random parent. Selecting 'nothing' will disable inheritance altogether. You can use this to track creature families in your world, or all sorts of other interesting scenarios!

Please note, however, that manually renaming a creature through the creature profile/history panel will not update the name that it passes down to its children; it will pass down the name it was given. If you really need to rename a creature, I would suggest setting its name back to a blank one and letting the autonamer name it something else, or generate a new Test Name that you like and apply it to the creature (explained later)

The second option is one of my personal favorites: Formatting Options, which allows you to choose whether or not there is a space between first and last names and whether or not you prefer the name parts capitalized or not. Choosing 'unaltered' will use the capitalization format already present in the catalogue files. Clicking the X button or pressing the Backspace key on your keyboard in either settings mode will return you to the main menu. Settings are saved in your currently selected profile along with your active tags.

This opens some fun and ridiculous new possibilities for naming schemes!

The final button on the bottom right is Refresh Test Name. This button will take your current settings into account, including active tags and formatting options, to generate an example name for a Creature! If you get a name you really like, you can apply it to your currently selected creature by clicking the name itself.

Again, when you are happy with all your configurations, you can click the X to save your options and hide the window. The Protective Tub Autonamer will continue to run in the background and assign absurd names to your unnamed creatures. Remember, you can bring the settings window back up at any time by clicking the duck-shaped button above the selected Creature's name in the upper left of your window, or by re-injecting the agent.

I really hope you all get some amusement out of this! It turned out to be a much larger project than I originally intended, but in the process I generated a fairly large amount of reusable code that should help future projects come together a little more easily. If nothing else, it was quite the wild development ride!

Finally, I got permission from Jessica of Discover Albia to convert her Star Wars, Robots, and Underwater PT name lists to the aPT format! You can download the conversions here, and then get a little more practice using the Import function:

After dropping those catalogue files into your Catalogue Folder, you'll be able to import these tags to the left side:

< Star Wars (DA)
< Robots (DA)
< Underwater (DA)

And these tags to the Right Side:

Star Wars (DA) >
Robots (DA) >
Underwater (DA) >

Of course, you can import them to both sides if you want-- nothing's stopping you! Since these tags are saved to a list in the game's journal folder, they'll be saved across worlds, so you should only ever have to import a tag once.

I hope you guys all had a wild and wonderful week. Now go forth and make all sorts of absurd names!

Sunday, November 26, 2017

How to Test CAs

Something like five and a half years ago I wrote up a post called 'CAs And You!' Since then, it's become one of the most visited and linked-to pages on this blog (that isn't an agent release, at least). But it was only a short while ago that I realized that although I had written up all this nice information about CAs, I hadn't really given you an effective way of testing them yourself. Even after releasing the Magic Words Room Edits, which at least provided visual indicators of CA links, there remained no simple way to make sure that your CAs were actually traveling properly.

It was actually Pilla (whom I consider to be one of the most wonderfully fearless developers in recent times) who expressed an interest in the code that I used to display CA values in the original post. The code I actually had was incredibly user un-friendly, so I fleshed it out a little bit. I hope it's something the average person can use now.

The command is simple "CA Tag #" (IE 'CA Tag 6') will create a little black tag under the hand (though you can move it if you wish) that will display the amount of that particular CA within the room. You can find a list of CA numbers on the Creatures Wiki page. I would recommend using this with the debug map turned on (either with the command in Magic Words Room Edits 'dmap' or by simply opening your CAOS command line and typing 'dmap 1') so that you can see the room boundaries. When you don't need the tag anymore, you can click it to remove it, or enter 'CA Tag Clear' to remove all tags.

There's a lot of amazing third-party stuff available these days, but a lot of metarooms, especially older ones, lack the proper links for CAs to properly flow. If you want to make your metarooms as creature-friendly as possible, it's important to make sure creatures can follow CAs to find food! 

Lift shafts tend to be what you want to check. In these images you can see that the more modern Chione (on the left) had properly set up CA links between the lifts, so the protein CA from the food trickles down to where creatures on the other levels can smell it. The much older Terra Reborn (on the right) was developed before the importance of CAs was widely known. As you can see, the protein CA is very high in the room where the food is, but doesn't exist at all in the room below it!

Thankfully, this is a fairly easy fix with the Magic Words Room Edits 'make ca link' command. Now you can see that the smell is travelling properly down the elevator shaft!

If you want your creatures to travel between metarooms, you may wish to also check that your doors between rooms are CA linked up too. 

While this agent should hopefully aid both developers and anyone looking to set up a proper world, it's important to remember that there are several other factors involved in proper creature navigation than just CAs. The foods in the world need to do their part and emit CAs to begin with. Your lifts need to take creatures up when they Push them and down when they Pull them. (If you mix these up as often as I do, it helps if I think of the two 'l's in 'pull' as a making a slide to go down. Sounds totally absurd, but it works) Your doors also need to properly stim for 95/Exit if they connect different metarooms or 96/Enter if they connect areas within the same metaroom. Do doors within the same metaroom sound ridiculous? Actually, there are certain circumstances in which they should be used instead of lifts, as this post by Grendel Man explains.

There sure are a lot of factors to consider in making a room navigable! Of course you could easily use these tags for other purposes, like to monitor the amount of water or nutrient in the soil. Whatever you do with them, I hope you find them useful!

Saturday, November 25, 2017

The Simple Things

I guess I've just been on an updating kick lately. This is something I meant to do a long time ago. Like probably six years ago.

The updated Creature Nametags fix a handful of things. First, the plane isn't so obtrusively high. You can now view your Creature History without a having to scroll to a room where there aren't a million nametags in your way. Secondly, it doesn't put out a bunch of trash debug info anymore, which should make things less annoying if you're a developer who uses the CAOS Debugger. And thirdly, the nametags now attempt to move around each other instead of overlapping.

You can download the updated nametags here, and I'll be amending the original release post shortly too.