Welcome to the Creatures Wiki! Log in and join the community.

Cob tutorial Two

From Creatures Wiki
Jump to navigation Jump to search

Introduction[edit]

Here we will make a drink cob. This one will be a bit more interesting than a cheese clone. This one will have it’s own picture *crowd gasps* and an extra-activate script. For this project I’ll use my red cordial cob. I’ll stick all the files you need for this tutorial (ie. the picture file) into the zip that this tutorial comes in. BTW, with these tutorials I always assume you’ve read the ones before.

Installation[edit]

inst
new: simp hcrd 1 0 3500 0
setv cls2 2 7 31501
setv attr 195
bhvr 0 64
slim
edit
endm
inst

Our good friend this inst command from the last tutorial. From now on, lines I leave will be the ones with nothing I’ve not explained before.

new: simp hcrd 1 0 3500 0

Ah! Here’s how this one is different from the last thing we made. It’s got a sprite file (picture) that we made ourselves. Before you go about making new pictures for your cob files, there are a few things you need to know. Firstly, the sprite files need to be in 16 bit colour. Secondly, the sprite file must be in bitmap format (.bmp) and converted to sprite format (.s16) using the sprite editor in BoBCoB. The sprite file must be named something original (or it’ll overwrite and sprite files of the same name already in the Creatures 2 directory) and distinctive (to stop someone else accidentally naming their sprite file the same name. An example of this is I always begin my sprite filenames with a h (for Helen) and make it as cryptic as possible. The sprite file for this cob is named hcrd which is my shortening of Helen’s CoRDial.

Hmmm I think that’s all you need. Before going any further embed this sprite file into the cob by clicking on the embedded files button in BoBCoB, clicking add file and selecting the hcrd file. You need to always remember to do this before testing your cob or Albia is likely to crash when you install the object.

Now lets look at the numbers in this command: new: simp hcrd 1 0 3500 0. The 1 after the hcrd means there is one picture in this sprite file. This is important because you can have as many bitmap pictures as you like in an individual sprite file and Creatures needs to know how many are in this particular file. The 0 in this command means the first picture we want to use in this sprite file is picture zero. This is the first picture in the file. It’s picture zero because creatures counts from zero instead of one because it’s a computer game, not a human. If you had 20 sprites in the file and wanted to start at sprite 19 you’d write new: simp hcrd 20 19 3500 0 instead. The 3500 is just how far into Albia the object lies (or the plane). This number can be anywhere between zero and 9000. Zero is behind the backdrop of Albia (the hand won’t be able to see it) and 9000 is in front of all objects in Albia. 3500 is usually a good number for most objects.

setv cls2 2 7 31501

Same as before, only with a different genus number (it’s a drink, not a food) and a different species number.

setv attr 195
bhvr 0 64

If your wondering why the behaviour is still 64 even though this is a drink, not a food, it’s because the Norns use the “eat” command to drink the drinks in Albia.

slim
edit
endm

Well that sprite thing is the hardest thing you’ll learn in this tutorial. It’s the only thing that’ll take up that much writing, and the only really new thing. You can now inject your object and have a pretty red bottle appear in Albia. It doesn’t do anything yet though because we’ve not written the eat script

Removal script[edit]

This is the same as in the last object except the object number has changed.

inst
enum 2 7 31501
kill targ
next
scrx 2 7 31501 12
scrx 2 7 31501 6
endm

Eat script (script number 12)[edit]

This is pretty much like the last eat script you did. This time the Norn will eat the food, have it’s hunger decreased and it’s coldness increased and the object will disappear. Simple or what?

scrp 2 7 31501 12
stim writ from 0 255 0 0 4 75 73 75 37 150 70 75
snde drnk
kill targ
endm
scrp 2 7 31501 12
stim writ from 0 255 0 0 4 75 73 75 37 150 70 75
snde drnk

The snde is drnk rather than chwp this time as it is a slurping sound rather than a chewing sound we are looking for in this cob.

kill targ
endm

There you go! I told you it wouldn’t be half as bad as last time. This is the body of the cob done, now we’ll just add a few finishing touches.

Collision script[edit]

This is a script that all the fancier objects people make use so the objects make a dropping sound when they are dropped. It doesn’t really do much, except add a bit more realism into the cob. It’s very simple though, so well worth the extra trouble of writing it.


scrp 2 7 31501 6
snde drop
endm
scrp 2 7 31501 6

Tells creatures that this will be the collision script (one called when the object knocks into walls or is dropped) for object 2 7 31501 (our red cordial)

snde drop

Tells creatures to play the sound in the creatures/sounds directory called drop (which surprisingly enough is a drop sound). Notice how all the sounds and all the sprites filenames are only four letters long? This is the convention of CAOS. No command or filename is more than four letters long, unless it is a number. You’ll need to remember this when you’re naming new image files or new sound files for your cobs.

endm

Tidying up[edit]

There are a few things you should do with your cob before you share it with others. Firstly, you should give it a name. You’ve probably already done this, but if you haven’t, type in “Red cordial” in the agent name space in the top of BoBCoB Next you should give a description of your cob to be displayed in the object injector. This can be very simple, but it’s usually a good idea to list your name and website (if you have one) as maker of this cob. I wrote for this cob: “A yummy drink for your baby Norns. It's red coloured water that tastes like strawberries. Made by Helen http://www.frimlin.co.nz/helen/frame.html” Now you need to set a picture for your cob to be displayed in the object injector. Click on the picture tab in BoBCoB, click on the insert button and find the sprite file that we used for this cob (hcrd). This will bring in the pretty picture of the red cordial. Now the cob is ready to be packaged. You need to write a text file to go with your cob. Here’s a sample one:

“************ C2 Red cordial *************

Yes! Another revamp of a previous C1 cob. :) The red cordial is yummy drink for your baby Norns. It's red coloured water that tastes like strawberries. The Norns love it! It cools them down and reduces their hunger.

Object Numbers: 2 7 31501

Files included

red cordial.cob

To Extract: Extract the cheese wheel.cob file to the /Creatures 2/objects/ directory

-------------------------- This cob is made by Helen please do not distribute it in ANY form (web page, cd-ROM, etc) unless you have permission. email: helen@frimlin.co.nz ICQ: 3378233 URL: http://www.frimlin.co.nz/helen/ --------------------------”

Now, using either WinZip or the cob extractor program with BoBCoB make a zip file or an executable containing both the cob file and the text file.

Conclusion[edit]

Congratulations! You made your first presentable cob! Now it’s ready to be shared with the world. It’s probably best just to share this one with friends to show them what you’ve learnt (it is pretty much my cob after all) but now you know the basics to make your own simple food and drink cobs.