Basic doll script
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 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"
NEW: 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.
new: simp 2 21 2000 "SCay_Bunny" 1 0 1000
The toy does not bounce.
The doll is heavy..
And not that aerodynamic if it is dropped.
It does not slide...
Or fall through elevator shafts.
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.
If the game calls itself Creatures 3 instead:
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.
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.
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.
End the 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
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.
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
**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 *PUSH scrp 2 21 2000 1 *feels like a toy stim writ from 97 1 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 chem 156 -0.25 targ ownr endm *PULL scrp 2 21 2000 2 stim writ from 97 1 targ from chem 94 0.5 chem 156 -0.25 targ ownr endm *HIT scrp 2 21 2000 3 stim writ from 97 1 targ from chem 94 0.5 chem 156 -0.25 targ ownr endm *COLLISION scrp 2 21 2000 6 doif wall eq down snde "dr64" endi endm 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
- 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.
- Read through Ghosthande's Basic Tutorial to learn about a doll that changes images when it's picked up and activated.