Basic doll script

Introduction
This bunny doll is a type of toy that is popular for beginners to create, and there have been several Norn Dolls created over the years with the help of Nornpose or the Nornimator. It can be pushed, pulled, or hit, and when creatures interact with the toy they become less bored and a special effect is added: the bunny will inject them with a healing chemical and make them less lonely. It plays a sound (dr64.wav) when it collides with the ground. This is a default DS sound, but needs to be in the folder with the image file (File:SCay_Bunny.c16) when the agent is compiled. It's useful to use the CAOS Tool or another highlighting tool to read the code because they can make the CAOS syntax easier to read.

CAOS2PRAY
CAOS2PRAY is a feature included with RProgrammer's Jagent which allows the coder to not have to code a separate PRAY file in their agents. This chunk of code goes at the top of the COS file, and when it is dragged and dropped onto Monk (also part of the Jagent suite), compiles the cos file, with its dependant sprite file, into an agent that will be easy for everyone to install and play with. For more details on CAOS2PRAY, see CAOS2PRAY: An Easier Way by Amaikokonut.

**CAOS2PRAY *# Pray-File "SCay Bunny.agents" *# C3-Name "SCay Bunny C3" *# DS-Name "SCay Bunny DS" *# attach SCay_Bunny.c16 *# attach dr64.wav *# desc = "A bunny doll for your creatures, for C3 or DS." *# Agent Animation File = "SCay_Bunny.c16" *# Agent Animation String = "0" *# Agent Sprite First Image = 0 *# Agent Animation Gallery = "SCay_Bunny" *# Web URL = "creatures.wiki" *# Web Label = "Creatures Wiki"

Installation script
inst

SIMP line, installing a toy with the class number 2 21 2000, using the first image in the sprite named File:SCay_Bunny.c16, and installing it the plane 1000 (fairly far forward). A common error that can be introduced here is "Pose change failed", caused by miscounting the amount of images that are being used, by not including image #0.

simp 2 21 2000 "SCay_Bunny" 1 0 1000

Various attributes. Carryable, carryable by the player, suffers collisions, and suffers physics. Amaikokonut's CAOS APPS can be used to help choose new ATTR and BHVR values.

attr 195

BHVR is 11, meaning it can be pushed, pulled and hit, aspiring to AquaShee's Creatures Development Standards project.

bhvr 11

The toy does not bounce.

elas 0

The doll is heavy..

accg 3

And not that aerodynamic if it is dropped.

aero 2

It does not slide...

fric 100

Or fall through elevator shafts.

perm 100

Now for the fun part: choosing where to install it. This looks like a long piece of code, but it is thorough at its job: installing an item by the C3 or DS creator machines safely.

Using the game variable GNAM, we can find out if the game calls itself 'Docking Station'.

doif gnam eq "Docking Station"

Double-checking that "CreatorX" and "CreatorY" have been set.

setv va00 game "CreatorX" setv va01 game "CreatorY" doif va00 eq 0 and va01 eq 0

Adding DS safety, just in case.

setv va00 6110 setv va01 9200 endi

Doing a test move, then moving it if the test move is successful.

doif tmvt va00 va01 eq 1 mvto va00 va01 else mvsf va00 va01 endi

If the game calls itself Creatures 3 instead:

elif gnam eq "Creatures 3"

Perform a test move to a C3 location and if it's successful, move the toy there.

doif tmvt 5671 3599 eq 1 mvto 5671 3599 else mvsf 5671 3599 endi

End the 'what does the game call itself' check.

endi

Push script
This doll will feel like a toy when it is played with. It will also use the CHEM command to add prostaglandin, a healing chemical, and reduce loneliness. The C3 Chemical List can be consulted for chemical numbers. Note that the targ is explicitly returned to the ownr at the end of the chemical injection.

scrp 2 21 2000 1

Uses a stimulus to feel like a toy to the creature.

stim writ from 97 1

"targ from" causes the TARGet object to be "from" - the creature who activated the dolly. This means the chemicals will go to the right place.

targ from

Half-fills the creature's blood with prostaglandin, a healing chemical

chem 94 0.5

Quarter-empties the creature's blood of loneliness: note that using CHEM means creatures will not learn that 'toys reduce loneliness'. chem 156 -0.25

To avoid a common CAOS error, we change the targ back to the dolly itself.

targ ownr

End the script

endm

Pull script
As above for the push script.

scrp 2 21 2000 2 stim writ from 97 1 targ from chem 94 0.5 chem 156 -0.25 targ ownr endm

Hit script
As above for the push and pull scripts. scrp 2 21 2000 3 stim writ from 97 1 targ from chem 94 0.5 chem 156 -0.25 targ ownr endm

The Collision Script
The collision script simply checks if there's an obstacle in the downwards direction (that is, the floor). If so, it plays a gentle patting sound, as if the doll is falling to the floor.

scrp 2 21 2000 6 doif wall eq down snde "dr64" endi endm

The Removal Script
This simply counts through all the objects in the world with that class number, removes them, and then removes the scripts that belong to that class number. It's important to double-check that the class numbers here match the class numbers you've been using all along, and make sure that all SCRPs in the object have a corresponding scrx. If the class numbers here do not match the ones you've been using, you might accidentally delete some other object in the player's world, or silently delete another object's scripts, which would be hard for someone to fix!

rscr enum 2 21 2000 kill targ next scrx 2 21 2000 1 scrx 2 21 2000 2 scrx 2 21 2000 3 scrx 2 21 2000 6 endm

Whole script

 * CAOS2PRAY
 * Pray-File "SCay Bunny.agents"
 * C3-Name "SCay Bunny C3"
 * DS-Name "SCay Bunny DS"
 * attach SCay_Bunny.c16
 * attach dr64.wav
 * desc = "A bunny doll for your creatures, for C3 or DS."
 * Agent Animation File = "SCay_Bunny.c16"
 * Agent Animation String = "0"
 * Agent Sprite First Image = 0
 * Agent Animation Gallery = "SCay_Bunny"
 * Web URL = "creatures.wiki"
 * Web Label = "Creatures Wiki"

inst new: simp 2 21 2000 "SCay_Bunny" 10 0 1000 attr 199 bhvr 11 elas 0 accg 3 aero 2 fric 100 perm 100 doif gnam eq "Docking Station" setv va00 game "CreatorX" setv va01 game "CreatorY" doif va00 eq 0 and va01 eq 0 setv va00 6110 setv va01 9200 endi doif tmvt va00 va01 eq 1 mvto va00 va01 else mvsf va00 va01 endi elif gnam eq "Creatures 3" doif tmvt 5671 3599 eq 1 mvto 5671 3599 else mvsf 5671 3599 endi endi

scrp 2 21 2000 1 stim writ from 97 1 targ from chem 94 0.5 chem 156 -0.25 targ ownr endm
 * PUSH
 * feels like a toy
 * Half-fills the creature's blood with prostaglandin, a healing chemical
 * Quarter-empties the creature's blood of loneliness

scrp 2 21 2000 2 stim writ from 97 1 targ from chem 94 0.5 chem 156 -0.25 targ ownr endm
 * PULL

scrp 2 21 2000 3 stim writ from 97 1 targ from chem 94 0.5 chem 156 -0.25 targ ownr endm
 * HIT

scrp 2 21 2000 6 doif wall eq down snde "dr64" endi endm
 * COLLISION

rscr enum 2 21 2000 kill targ next scrx 2 21 2000 1 scrx 2 21 2000 2 scrx 2 21 2000 3 scrx 2 21 2000 6 endm

Moving on

 * Reserve and use your own class numbers at Creatures Caves.


 * Search on OpenGameArt.org or take inspiration from the Creating Agent Art tutorial to make a new sprite for your doll. Alternatively, Norn Doll images can be created from breed sprites using NornPose and Nornimator.


 * Make the doll appear in a different metaroom. Use the keyboard shortcut CTRL + SHIFT + X to explore different coordinates.


 * Try using the Constructor Script (10) to hold various values for the doll.


 * Use the CHEM command in the play scripts with the C3 Chemical List to inject different chemicals as your creature plays.


 * Use the SNDE command and browse your Sounds folder to make the toy play different noises for different actions. (For example, an "ow!" sound for being hit, as the head ball does.)


 * Use the RAND command to set a random dosage of a chemical: either -1.0 or 1.0.


 * See also Musicola (teardown) and Substitute Doll (teardown) for more worked examples of toy agents.