Back to the Index

Alexander Laemmle: The Hitchhiker's Guide To Albia

All cheese (we edit an existant COB to our needs)

What should the COB do?

It should import cheese into Albia
The new cheese should exactly apear on the places where cheese is when starting Creatures the first time
There should never be more cheese in the world than there is when starting Creatures the first time

So we should start by finding out where cheese is, when Creatures is startet for the first time. To find out the CLASS of cheese, you can go to the COB compiler and select new (the button over the source field) and look at the treeview under 2-simple objects 6-food 1-cheese. And that's it : 2 6 1 Now start a new world (make a backup first or let COE make a backup for you) Let's use COCI on the new world to get the x (left) and y (top) position of all cheese in the world: Go to the COCI write this:

enum 2 6 1,dde: putv posl,dde: putv post,next

and press 'SEND'

enum 2 6 1 ... next do everything between enum and next to all objects 2 6 1
dde: putv posl send the position (left edge) of the object to COE
dde: putv post send the position (top edge) of the object to COE

so 'enum 2 6 1,dde: putv posl,dde: putv post,next' will return all x,y positions of all objects 2 6 1 (cheese) we get something like this back:

2960|846|2652|903|2663|903|2602|714|784|410|1390|763|1673|1073|4698|502|5767|502|5789|502|5770|502

and this is nothing else then the x and y positions of all cheese in the world. Now let's extract them to coordinates:

Nr. X Position Y Position Nr. X Position Y Position
1 2960 846 2 2652 903
3 2663 903 4 2603 714
5 784 410 6 1390 763
7 1673 1073 8 4698 502
9 5767 502 10 5789 502
11 5770 502

Now we must make a COB out of this information. And we have luck. In the X-Mas pack there is a cheese COB that injects a single part of cheese. So we load it and edit it to our needs.

Go to the COB compiler load the cheese.cob press 'discompile we get this:

* Installation routine

inst new: simp food 3 3 3500 0
setv clas 33947904
setv attr 67
bhvr 0 1
setv obv0 1

edit

that means:

inst do everything after this as fast as possible
new: simp food 3 3 3500 0 install a new simple object using file food.spr
and import 3 sprites at position 3 in the file
set the object on z position 3500 (0= background, 9500=foreground)
dont clone sprites (0= dont clone, 1=clone)
setv class 33947904 class of the object (2 6 1 = 2*16777216 +6*65536+1*255)
setv attr 67 set the object attribute (64 + 2 + 1 = groundbounce + dragable + carryable)
bhvr 0 1 set behavior (mouse can do nothing, creatures can Activate(1))
setv obv0 1 Set variable OBV0 to 1
edit put object into the hand after injection

Why aren't there any scripts in this COB? The answer is easy: The scripts for cheese are in the world because there is (was) cheese in it. Even when all cheese would be talken out of the world, the scripts would still be in there. But when we would try to inject this into a world where never was any cheese, it wouldn't work.

That looks great, doesnt it? Ok, now let's change it to install our first cheese:

inst

new: simp food 3 3 35 0
setv clas 33947904
setv attr 67
bhvr 0 1
setv obv0 1
mvto 2960 846
pose 2

endm


mvto 2960 846 Move the object to 2960 846
pose 2 Set display to sprite 2
endm End of macro


What have we done? We set the Z level to 35 (was 3500) to bring the cheese more into the background (so it won't be before a Creature when it walks by). We changed edit to endm that indicates the end of the macro and we won't hold the cheese in the hand after injection. We added a macro mvto 2960 846 that tells Creatures to move the object (cheese) to X=2960 Y=846. Try to find this position on the map.pose 2 tells Creatures to show Nr. 2 of the importet sprites (sprites start at Nr. 0 so 2 is the third sprite) Now, to inject two of our cheese objects we change it (using copy and paste - right mousebutton on the source window) to:

inst
* Cheese 1

new: simp food 3 3 35 0
setv clas 33947904
setv attr 67
bhvr 0 1
setv obv0 1
mvto 2960 846
pose 2

*Cheese 2

new: simp food 3 3 35 0
setv clas 33947904
setv attr 67
bhvr 0 1
setv obv0 1
mvto 2652 903
pose 2

endm


Note that the second cheese has the coordinates of the second values taken from creatures (see the list above...) Now we can do this with all other x,y positions in the list until we have 11 entries in the COB source. Save the source now using the 'save' button over the source field. Now you can compile and inject the COB into Creatures to test it (remember : always use a new world for testing new COBs!) When you see a cheese drag it away and you'll see that a second cheese is behind it...

Last thing to do is to remove all cheese from the world before we inject it. we do this with inserting this lines after 'inst' and before the first new:

enum 2 6 1
kill targ
next

enum 2 6 1 ... next we know this one... do everything between enum and next to all 2 6 1 objects
kill targ remove the object (the value 'targ' is set to the object by the enum macro)

Finaly we'll add a header (in top of the source) :

*All Cheese
*Demo for
*Alexander Laemmle's hitchhikers guide to albia
name All Cheese
quantity 12
month 0
day 0
jear 0
used 0
sprite food 3

name Name of the COB
quantity How often it can be used
month,day,year From this date on the COB will be invalid
used 0 This COB was used 0 times
sprite food 3 Use sprite 3 from the file food.SPR for injectorgraphic

That's all for now... the final source should look like this