Monday, January 20, 2014

Designing farting norns (Tutorial)

Many colored alternative breeds exist for all of the creatures games.

In this tutorial I will show you how to design a new breed for C1.
But not one that involves making new sprites for new colored or punk Norns, but rather one that implements new Norn behaviours and possibilities.
Using those techniques one could add loads of interesting behaviours to Norns such as :
  • Adding a kicking stance and associated behaviours to fight off Grendel more efficiently
  • Making Norns that can reinvigorate and heal by resorting to meditation
  • Enabling actual telekinesis in Norns ( yes, this IS possible with some work )
  • Making jumping Norns
  • Mimicking more realistic life behaviour ( digestion, elimination ... )
  • ...
But this time we will be:

Making Farting Norns:

Why would anyone want to do that ? Well, I believe we should keep some humor while playing God if we want to be any successful at it.
Also it is an easy way to teach beginners the basis of new breed designs, without resorting to the most common and painful approach of defining a new breed by making new Norns appearances.

This tutorial will take you through all the necessary steps to give your Norns the ability to fart, not just as a game gimmick, but as the real simulation of a noisy digestive process.

Acquiring the material:

The first significant step in designing farting Norns is finding one (or more) suitable sound.
Find one that suits your needs, then rename it to a 4 character name (this is mandatory for all C1 files).I chose to name it "fart.wav"
Put it inside your game's "Sounds" folder.

You can now test it by running a game and executing the following CAOS command using your favorite tool. 

     snde fart

  Note that injecting the sound from the external tool will take focus away from the game and most likely mute it.You could also test the sound by looping it with the command:

    sndl fart

and then stopping it with the command:


This is just to make sure you picked a sound file in a format that the game can read and play.
Did it work ? Great, let's move on:

Writing a first farting script :

 As any other ingame action, our actual farting action will be a CAOS script that will be ran at the (un)appropriate occasions.
Let's begin with something simple for testing, we will be expanding it later.

    sndq fart 5,sndq gig2 10

This will make a Norn play a farting sound, followed by a giggle.
Keep in mind the two sndq functions will be executed nearly at the same time, the second one won't wait for the first to end. The delay values must be set accordingly if you want a slight delay between both sounds.

Defining a new "Involuntary Action" :

There's a couple free slots in the various games where one could implement "Involuntary actions".
These are actions that a Norn doesn't decide to trigger, but rather that fire off automatically given certain conditions ( Giving birth, sneezing or dieing are all involuntary actions ).

You can look for the existing involuntary actions using a CAOS console or  a scriptorium browser.
( An accurate reference of C1 involuntary actions is available in the C1 SDK pdf file. )

We will store our new script using the classifier : 4 0 0 71 ( Creatures -> All creatures -> All sexes -> Involuntary action 7 ) , this slot should be free both in C1 and C2.

You can retrieve a script from any slot by using :

    dde: scrp 4 0 0 71

To install our new script in the 4 0 0 71 slot , we can use :

    scrx 4 0 0 71,scrp 4 0 0 71,sndq fart 5,sndq gig2 10,endm

( Be careful as this also removes any script precedently available in this slot, don't overwrite any default game script!Well...should you want to mess around, 4 0 0 72 is the death script, see what you can make with that ;)

You can then test that your script is correctly installed by running :

    dde: scrp 4 0 0 71

From on now, your world has a new involuntary action available for all creatures.
( Keep in mind this script will disappear should you reset to a virgin world.We will later see how to install it in the default "Eden.sfc" world that is used as a template for resets so you'll never have to worry about that again.)


Making a new farting Norn genome :

Now the involuntary action has been installed in the world, we still need Norns designed to actually use it.
I chose to base my Farting Norn breed on the Purple mountain Norns race as they offer some interesting characteristics.

Fire up the C1 genetics kit, and navigate to the Biochemistry tab.

Pick a free slot for a new chemical ( I chose 73, but don't know if this conflicts with any known other creatures breed )
Name the New chemical "Gas (Fart)".
This will be the chemical accumulating inside the Norn's body, and triggering the involuntary action when a given threshold is reached.

You will now need to Install the Chemical list in game ( so the new chemical shows in monitoring and injection applets with the new name )

You can now run the game, and find the new chemical available:

Close the game for now, and return to the Genetics Kit.
Open your base Genome, I will be using 0XER ( Aaron, the Purple mountain Norn )

Click on add a new gene, and create a new receptor gene.
Configure it as such:

This means that whenever the chemical 73 ( Gas ) level in the Norn will get over the Threshold value, the involuntary action 7 will be triggered.

Save your genome as Fart.gen, and inject a New Norn with this genome inside the game.
( Use the "Export" Tab in the Genetics Kit )

Testing things so far:

Hatch the newly imported Norn, and go to the science kit.
Set a graph to Monitor Gas which should be 0 for now.
Using a Caos injection tool ( such as the one available on the "Export" tab in the genetics kit ), you can use the following commands to monitor the Gas chemical level or to inject some inside the Norn:

dde: putv chem 73 # Get a Norn's Gas level
chem 73 30        # Add 30 Gas to the Norns body

You can notice that whenever you inject Gas inside the Norn, the monitoring graph shows it.
When the concentration of the 73 chemical reaches the threshold configured inside the genome, the Norn should start farting uncontrollably.Proving the script works as intended.

Adding the natural processes:

For now our Norn only farts when manually injected with the chemical, which has no natural occurrence in the game yet.
Also more problematic, the gas levels never decrease, meaning that once the farting threshold is reached, your Norn won't ever stop farting.Not exactly what we want.

In the Creatures series, you can add all sorts of chemicals to your Norn's blood stream ( via cobs or CAOS commands ), but the chosen model doesn't give you any way of directly REMOVING one from your creatures.This makes sense regarding the overall cohesion of the simulation.
After all, things are similar in real life aren't they ?
To destroy the Gas chemical, we will need to add a second chemical.

Let's make it Number 74, and call it "Fardecrase".Do so in the genetics kit:

Don't forget to reinstall the new chemicals list.

We will now need to add a new gene inside the Norn, defining the chemical reaction by which Fardecrase will destroy the Gas chemical.
Make it a Chemical reaction gene and configure it as follows:

This reaction basically means that 2 units of Fardecrase combine with as much Gas units in a pretty fast reaction, and that both chemicals are destroyed in the process.
If injected with Fardecrase, the Norns Gas levels will now quickly drop.
We will use this as a means to simulate err...pressure relief.
For this to work we will tune our farting script, so farting now generates Fardecrase, effectively eliminating gas from the Norn's system.
Install the new version of the script :
     scrx 4 0 0 71,scrp 4 0 0 71,sndq fart 5,sndq gig2 10,chem 74 250,endm

If you now hatch a Norn with the new genome, you can monitor it's gas and fardecrase levels while injecting him with the Gas chemical.
When the Gas level reaches the threshold, the fart script is executed, fardecrase is injected, and promptly eliminates Gas from the Norn's body:

After a Gas injection, the Norn Farts, getting a Fardecrase spike, which effectively destroys most of the Gas chemical in the Norn's bloodstream. Note that the elimination reaction is so fast, the fardecrase spike does'nt always have the time to fully show as in this example.

We now need to make gas production a digestive byproduct.
Fortunately, in C1 the digestive model is relatively simple, as the only digested nutrient is starch.
Once again, in the edited genome, go to the genes section, order by type, and find the "Reactions" section.
Gene 142 is labelled as "Digestion" and mimics the process of converting ingested starch into usable body chemicals.
Luckily for us, the initial reaction only produces glucose, leaving a free slot.
Let's add gas generation as a byproduct of digestion :

Now gas production inside your Norn truly is the product of the digestive process.

Further tuning:

At this point we have a working farting Norn breed.
Let's just tune it a bit to make it worthwhile.

For now production of gas happens with each meal intake, meaning that our Norn is bound to fart regularly for a given food consumption.
Let's make the behaviour slightly less systematic, and more realistic.
We will add a natural decay for the Gas Chemical.That way a single meal won't be enough to trigger a fart, and the accumulated gas will naturally decay.

Select the 001 Gene ( the half lives gene ), and set the Gas Half life around 96:

Tuning this value is a delicate balance.
Set it anywhere too fast ( low values ) for example less than 72, and even eating won't be able to raise the gas value as it will decay quicker than it is created.
Set in anywhere too slow, and you won't even notice it decaying.

An appropriate decay value eliminates Gas naturally, yet not keeping it from rising after a good meal.

Now it will really take a fest to make a Norn fart, making the behaviour more anecdotal, realistic and less boring.

Let's also add a small animation to our fart.
You could design this at will, so your ingame fart seem either fun, embarrassing or rude.
As we've already done much, I'm personally opting for a sober animation, barely being a visual clue of which Norn just farted, so the whole thing is not overdone.
Install the following script as the new fart script to mimic that :
    scrx 4 0 0 71,scrp 4 0 0 71,anim [0404080812],sndq fart 5,sndq gig2 10,chem 74 250,endm

This is a basic chaining of the 04 08 and 12 positions ( you can match those numbers to the actual positions by looking for  the pose genes in the genetics kit.
Basically it will make the Creature lean forward a little.

 You can design and test your animations by directly running the corresponding commands ( just don't forget each pose is 2 digit long, even when the first one is 0 )
    anim [0404080812]


Other ideas:

At this point you could further tune the script to make it more interesting.
Any further ideas are only showed here as an exercise for the reader, but will probably be integrated in an official Farting Norns breed release.

- You could add better animations, by creating new pose genes.
- You could include various reactions to farting, for example making it seem fun for boys, or embarrassing for girls.
- You could make the laughing sound less systematic, by generating a random number at fart time, and only playing a laughing sound 1 in 4 times.This will make the laughing sound less likely to happen, and might keep people interested longer in your mod as it will provide some unsuspected behaviour even after some time of use.
- You could randomize the sounds and animations between a couple variants.

Just make sure you don't associate any punishment or reward with the Farting process.
As it is an involuntary action upon which your Norn can't act, this would totally mess up it's learning process.

Permanent integration in the game

At this point you have a fully working farting mechanism, and a genome from which to span new creatures with the ability to fart.
We set all of the new genes as non mutable, so the behaviour isn't as likely to disappear a couple generations down.
Keep in mind though that by breeding non farting with farting Norns, there's always a chance the kid won't inherit all the required genes from the Farting parent and that some kids might loose this ability.

There's one last thing we need to do.
We manually installed our script in the world, but if we ever choose to restore it from a new one, our behaviour will be lost, even for the Norns that have the correct genome ( the inner reaction will still occur, but no sound or animation will ever be produced )

To install our script in the game in a more permanent fashion, we will need to install it in the "Eden.sfc" world , that is used as a template for generating new worlds.
To do so:

1) save your current world ( by using any tool, or cheat that allows it, or by running the "sys: cmnd 57604" CAOS command )
2) Backup your Eden.sfc file to a safe place should you need vanilla virgin worlds later on.
3) Open the Eden.sfc world ( once again using any tool,cheat or by manually running "sys: cmnd 57601"
3) Install your farting script with the appropriate "scrp 4 0 0 71" command
4) Save the world again to Eden.sfc template ( cheat menus or "sys: cmnd 57604" )
5) Return to your traditional world with "sys: cmnd 57601" again.

From on now, whenever you restore or start a new world, the used Eden.sfc template will be your fart-enabled world.



You've made quite a few modifications to your game to enable the farting behaviour.
Here's a summary of what files to include if you ever wanted to distribute such a breed:
  • A couple of female and male creatures in the .exp format, freshly hatched from your new genome.You could include more than one couple to allow for more diversity and longer lasting changes when breeding with vanilla breeds.Alternatively you could provide only your .gen file and a way for users to generate new Norns based on that genome.This is a slightly more risky approach as if users choose to generate genomes from both farting and non farting Norns , some of the offspring might not be fully functional.
  • If designing a C2 breed, distributing them as .egg files will be a better option.
  • The fart.wav file to be put in the sound folder.
  • A way to install the farting script, either via a dedicated COB, or better yet by an automated installation via a custom tool.
  • Your new chemicals.str file containing your new chemicals definitions.Since other breeds might be conflicting with your changes, adding an installer that first reads the original file and then patches it is a more robust way to proceed.If you just overwrite any existing chemicals.str file, you risk destroying someone else's custom chemicals.
  • Your new Eden.sfc file for persistent installation of your mod.Leave this a choice to the end user though, as some might expect their "restore" option to restore a fully virgin standard C1 world.
  • An accurate documentation of what your modifications precisely do, just so users could solve any conflict with existing breeds or scripts.
That's a lot of work !  But it's necessary to make your work enjoyable by others.

I hope you had fun and/or learnt things while designing this custom behaviour.
Let me know if this helped you getting in the obscure and small community of Norn breed makers !
More tutorials will follow later, covering the more conventional but way more involved process of designing purely aesthetic Norn breeds.

Stay tuned !


  1. Really interested in this stuff. I tried making a new species a while back similar to how the Ettins and Shee were made. Didn't go anywhere, but the work was fun. Anyway, this is making me think about trying again. :)

  2. It's nice to see you found that usefull :)
    After a couple more posts on technical stuff I will be posting another Norn breed tutorial ( Jedi teleporting Norns, yay ^^ ) .
    Did you have plans for what your breed should look like/do ?