Thursday, 14 January 2016

More Plants in C3 and DS

So we're going to look at creating more Pinky Plants to decorate our worlds.

First things first, open the starplant.cos file in your Creatures 3 bootstrap.

As you can see, it's a fairly simple plant.  Five of them (reps 5) get moved to random locations in the Norn Terrarium, (mvto rand 1740 2740 674) and then if they're not fully grown (scrp 2 4 5 9), they grow one step, at a rate of between 1 growth step per second and 1 growth step every 4 seconds.  (tick rand 20 80) If they're pushed, they give the stimulus 62, which is... reached peak of starch smell.  Perhaps this should be changed to 84, which is played with a friendly plant.  

But, moving on, we're only going to concentrate on the installation script.  We will assume that our players will not have a modified starplant.cos file, and thus all the other scripts can be found in our players' games already.  The first thing we're going to do is get rid of the reps 5 .. repe loop.  It is essential that we have the ATTR and the BHVR the same as the original starplants.

inst
reps 5
    new: simp 2 4 5 "starplant" 10 0 100
    attr 192
*act1
    bhvr 1
    tick rand 20 80
    mvto rand 1740 2740 674
    elas 0
repe

Now for the MVTO and RAND sections, (mvto rand 1740 2740 674) which govern where the starplants grow.  In a normal MVTO command, the first number is the X-dimension, lengthways across the floor, and the second is how high.  This has three numbers because of the RAND command.  In this case, it should be read as 'move to a random x-location between 1740 and 2740, and always at the 674 y-location'.  The Ctrl-Shift-X keyboard shortcut in Docking Station can be used to make the fingertip of the hand point at what XY location it's at.  MVTO moves the top left corner of the agent to that position, even if the player can't see it.  You can see that my hand is in line with the beehives, etc. to give the rest of the pinky plant space to exist if the top leftmost part of the pinky plant is created there.  If you take the time to put the attr value through Amaikokonut's ATTR Calculator, you'll notice that it collides with floors and suffers physics, so the plant will simply fall to the ground, in a lot of locations that should all be valid.


When choosing where to put your new starplants, it's a good idea to have a notion of how big the starplant is going to grow.  Open starplant.c16 in SpriteBuilder or similar and check the dimensions of the image.  The starplant will grow to a maximum size of 64 pixels wide and 80 pixels high.


If you want precision placement as opposed to letting it fall to the floor, then it will be harder. In the grendel jungle's lift shaft, there is less space to fall about aimlessly, but it still can be done.
So, from the above, we can create a new cos file and have it contain the following:
 
inst
    new: simp 2 4 5 "starplant" 10 0 100
    attr 192
*act1
    bhvr 1
    tick rand 20 80
    mvto 1336 2457
    elas 0

Installation scripts, unlike other scripts, don't necessarily have to end with endm.

Save it into your C3 bootstrap (I called mine extrastarplant.cos) and then use the caos command line to inject it into your world.

You can keep adding different starplants at different locations in the same cos file - it has distinct possibilities for enhancing your worlds through plants.

No comments:

Post a Comment