Cacbana (teardown)

''This is a teardown page explaining the details and inner workings of this agent. For general information, see Cacbana''

The Cacbana is a simple plant agent found in C3. There are three distinct agents that make up the cacbana plant: the seeds, the plant itself and the flowers.

Object Variables
The seeds use the Object Variables OV00 to mean state - if it is dormant or not, OV80 to mean bounce count for the seeds, OV82 for the dormancy counter.

The plants use the Object Variables OV00 to indicate what state the plant is in, (growing, adult, fruit exposed, withdrawing fruit,dying); OV30 is the adult pose number, OV31 is a wilt modifier, OV32 is the fully open pose, OV33 is the first exposed frame, OV34 is the last dying pose, OV66 to mean time before the plant's maturity, OV16 and OV17 to identify their flowers, OV55 for the initial food store of the plants, OV56 for the food uptake of the plants, OV57 for the max food. The plants use OV69 as a truth check (0 or 1) for if it's ok to flower.

Inject seeds

 * 10 seeds initially injected.
 * Sets the BHVR to 16 (Creatures can eat this agent)
 * Moves the agent to a random spot in the desert 5200 5500 400
 * tick is 15 - roughly every second and a half.

Eat seeds (12)

 * Script is locked
 * Stims the creature with eaten seed (77) at three times the intensity
 * waits 1
 * kills ownr

Collision - seed (6)

 * Note: this script is glitched - see Minor Fixes.
 * If the seed is not dormant, it checks to see if the wall is not up, with a nested DOIF. Then it adds 1 to the 'bounces made' OV and then checks to see if 'bounces made' is greater than max bounces allowed.  If the seed is all bounced out, it checks to see if the room is hot enough and, if so, if there are fewer than 5 plants nearby and prepares to grow, using the subroutine grow.  If there are more than 5 plants nearby, the seed becomes dormant, using the subroutine dorm.  If the room is not hot enough, the seed also becomes dormant.  If the 'bounces made' is less than the max bounces allowed, the seed bounces on.
 * If the seed is already dormant, it takes pose 0.
 * The subroutine grow instantly creates a plant agent near to the point where the seed was. If a test move fails, the plant is killed, and the seed does another bounce, after which the script is stopped.  After this, the plant is moved to the location that was tested, and various attributes are set, including a tick of 100.  The seed is killed.
 * The subroutine dorm sets ov82 to a random number between 10 and 100, sets the tick to 200, and sets ov00 to 1 (making the seed dormant)

Timer - seeds (9)

 * If the seed isn't dormant, and it still has bounces left, and it isn't falling or being carried, become dormant and stop the script.
 * If the seed is dormant, count down its dormancy timer.
 * If its time runs out, ALTR some smells in the room, and then kill the seed.
 * If the room is hot enough, count the number of plants nearby. If there are less than 5, go to the subroutine grow.  If there are more than 5, perform a bounce.
 * The subroutine grow instantly creates a plant agent near to the point where the seed was. If a test move fails, the plant is killed, and the seed does another bounce, after which the script is stopped. After this, the plant is moved to the location that was tested, and various attributes are set, including a tick of 100. The seed is killed.

Timer - plant (9)

 * object variables are set - OV30 is the adult pose number (sprite #4), OV31 is a wilt modifier which is unused, ov32 is the adult pose (sprite #16). OV33 is the first growth picture for the cactus (sprite #23).  OV34 is the last dying pose. (sprite #22).  OV70 is the growth cost.


 * The first thing after setting the ovs is that the plant subtracts energy from ov55 and sets the death flag.


 * Then the subroutine uptk is run to work out the uptake of nutrients.


 * Then the plant dies - first by checking to remove the flowers, and then sending them the death message.
 * If both the flowers are gone, it sets ov69 to 0, and then checks to see if the pose number is between the adult pose and the first growing pose. If so, it triggers the rmve subroutine, and then sets a death flag.
 * If the pose is instead less than the dying pose of the seed (sprite #10), it forces the object to step up a pose.
 * If nothing else, the plant checks to see if it's in a valid room and releases some CA to the environment before it KILLs OWNR.
 * After the flower check doif closes, the script stops - then the plant death doif closes.


 * It checks to see if it's still growing (OV00 = 0)
 * It uses OV30 (the mature plant's pose) in a doif to see if the POSE is less than the mature plant's pose, with enough nutrients around to grow (uses PROP to check the room's CA levels and ALTR to subtract CA from the room) step up a pose.
 * If the POSE is not less than the mature plant's pose, it sets OV00 to 1, signifying a mature plant state.


 * If OV00 = 1,
 * subtract 1 from OV66 (time before plant's maturity).
 * If the room is dark enough, the cacbana will open and reveal its core. It will take the pose specified in OV33 (sprite #23) and it will set OV00 to two.
 * It will then check OV69 to see if flowers are needed - if so, it will then go to the subroutine flwr and then move the flowers to the appropriate place. After checking the flowers and closing the 'adulthood' checker (OV00 =1), the script TARGs the OWNR (because the TARG became the flower when the flower was created).


 * If OV00 = 2
 * subtract 1 from OV66 (time before plant's maturity).
 * Use OV32 (the fully opened cacbana) to check (with a doif) the pose - if it is less than the fully opened pose, the pose is stepped up one. If the room becomes light, OV00 is set to 3.
 * It will then check OV69 to see if flowers are needed - if so, it will then go to the subroutine flwr and then move the flowers to the appropriate place. After checking the flowers and closing the 'fully opened mature plant' checker (OV00 =2), the script TARGs the OWNR (because the TARG became the flower when the flower was created).


 * If OV00 = 3
 * subtract from ov66 (time before the plant's maturity)
 * go to the subroutine rmve and end the check.

Set targ to be to the ownr of the script (the plant)
 * If the plant is mature with no flowers,
 * check if the room is moist enough (water smell) to flower,
 * if so, set ov69 to 1
 * go to the flwr subroutine
 * set va03 to the current plane of the cactus plant, and add 1 to that. This will ensure that the flowers appear to be in front of the plant.
 * set va99 to be a random number between 0 and 1
 * multiply va99 by 9
 * add 58 to va99 - this corresponds with the two different flowers in the cacbana.c16 file.

Timer - flower (9)

 * if the pose is less than 4, advance the pose.
 * if ov70 is 1 (the flower is fertilised), it uses a nested doif to check if the pose is less than 8. if so, it advances the pose.  If not, it checks where it is, and then creates a seed.  It then checks to see if the flower exists - if so, the OV (16 or 17) is set to null.  If both flowers are set to null, ov80 and ov69 are set to 0, and ov66 is set to 100.  The flower is then killed.

Pollination - flower (303)

 * sets OV70 to 1.

Death - flower (301)

 * targets ov16, if ov16 is the ownr, it uses SETA to make ov16 null and then kills the ownr. If ov17 is the ownr, it uses SETA to make ov17 null and then kills the ownr.

Remove

 * Removes all instances of the cacbana plant, seeds, and flowers. Also removes the plant's timer script.