More Carrot CAOS: Dropping the Vegetables

Finding Out the CAOS Behind a Dropped CarrotI learned a lot about CAOS by working on the Creatures 1 carrot updates. It wasn’t the easiest place to start, yet the beta testing has shown that I didn’t make any major mistakes… So far! Understanding the flaws in the original carrots might make the upcoming download all the more interesting to C1 players. Although knowing the Creatures Agent Object Script (CAOS) behind the updates isn’t absolutely necessary, I’ve found it to be an excellent learning opportunity! We’ve already seen what happens when a carrot is eaten or picked up. What’s next? A rather complicated script with a whole lot of unnecessary functions!

The CAOS And Science Behind C1 CarrotsDropping a carrot sounds like it should be a pretty simple matter, but it isn’t in the original carrot script. This is where a lot of the confusion comes from, in terms of how seedlings are handled. Time to dig into this CAOS! This is the first time that there is a code that I’m not entirely sure how to explain. Now is your opportunity to share some insights and make sure that this is an accurate reference! I’m finding that creating these CAOS annotations is rather fun, since it opens up the door to figuring out what goes on behind the scenes in Creatures. Feel free to take a look at a script yourself: You might be surprised by how much you can unravel from just a few lines of CAOS!

Annotating the Carrot’s Drop Script (2 6 3 5)

As before, I know this is the right script because it corresponds with the class number for the carrot (2 6 3), and is for the drop script (script number 5). Feel free to ask if you’d like more details about figuring this out!

CAOS Code Explanation
scrp 2 6 3 5 Some programs begin with this line, while others name the file by it. This simply creates a new script for 2 6 3 (carrot) for script number 5 (drop). Everything will happen only when a Creature or the hand drops a carrot.
doif pose gt 4 If the carrot’s pose is greater than 4, the following commands should be executed. You may need to use a program to open the sprite file for the carrot (pars.spr) to understand this better. However, poses for 5 and 6 are for the full grown carrot, while poses 0-4 are for seedlings. Hence, only full grown carrots will continue on with this set of doif (pronounced “do if”) instructions.
snde drop If the object is on the screen, the drop.wav sound will play. An easy one!
setv actv 0 This code will set the object’s active flag to 0, which corresponds with inactive. According to Grendel Man, this means that the object can be interacted with again. So when the carrot is pushed, this value is set to 1. If it is not reset back to 0, that carrot can no longer be pushed again. Recall that the carrots are actually recycled over and over, so this allows a mature carrot to be pushed again after it is dropped. In another sense, this code requires a Creature to drop a carrot before trying to eat it again if the initial attempt failed.
pose 6 The carrot will show up in pose 6, which is equivalent to a carrot laying on the ground. This should make sense: A dropped carrot looks like a dropped carrot lying on its side! Nothing too complex, thankfully.
else If the last doif statement was not met, then the following set of instructions should be followed. In this instance, it corresponds to all carrots in poses 0-4, otherwise known as carrot seedlings or immature carrots.
setv actv 0 We saw this code above, and Grendel Man provided a very helpful explanation. At this point in the script, this states that a carrot seedling can not be eaten until it is dropped and regrown in the garden.
wait 10 This line states to wait a total of 10 ticks before continuing on with the next set of instructions. A single tick is equivalent to approximately 1/10 of a second, so 10 ticks represents about one second in real time.
rndv var0 3400 3800 Here we go, getting ready to “plant” a dropped carrot seedling! In a nutshell, this code is simply setting a value for variable 0 (var0) by choosing a random variable between 3400 and 3800, inclusive. In just a moment, we’ll see how this is used to set the x coordinate of the object.
mcrt var0 902 Unknown: The unique thing about this code is that the mcrt portion is specifically used to move a carrot. Most objects use the mvto operation. In any event, this states that the carrot should be moved to the x, y coordinates defined by var0, 902. In other words, the x coordinate is the random variable assigned in the previous step, while the y coordinate is a static value of 902. This explains why carrots have different horizontal positions, but always appear in a straight row. The only oddity with this function is that it is supposed to move the camera to this x, y coordinate. In practice, I can only understand this to mean the Creature’s view, although I’m not entirely sure about that.
tick 200 Finally, a somewhat simple code! The tick function assigns the timer rate for the object to a certain value which, in this case, is 200. That means that each time 200 ticks pass (approximately 20 seconds) the timer script will be executed. We’ll examine that one soon enough, but this basically controls the rate that a carrot will go through its growth stages. Remember that this only applies to poses 0-4.
endi The end of the current doif (pronounced “do if”) statement. Remember that everything above is actually part of it, since the else condition is still associated with the doif statement. Since the two are related, though, only one endi code is needed to close out the statement.
endm We did it! This marks the close of the script, and must always be present.

Breaking Down the Script Even More

This script looks long and complicated… And it is, in a very unnecessary way! Only mature carrots will make the dropped sound and look like dropped carrots. Surprisingly, this also tells us that a carrot seedling must be dropped in order to correctly enter its growth stages in the garden. If you’ve been following along, you may notice the very big problem with the original C1 carrots: Each one is continuously recycled! So a Norn will pick one up from the garden, eat it, and that same carrot will turn into a seedling again. Not very realistic. I’ll be sharing the CAOS codes I used in the upcoming fixes, and this drop script is one that was vastly improved. This original one is 13 lines long: The update is 5 lines long, and even includes a new function! Check back soon, as the new carrots will be available very shortly!

2 Comments

Add a Comment

Feel free to join the discussion! E-mail addresses are not published, and required fields are marked.

« Previous Post | Next Post »