Basic interactive land critter script
This is a basic interactive land critter which comes from an invisible nest - it is polite in that it's got some features that make it friendly to creatures and friendly to your poor, overheated computer. It crawls around, collides into walls, and dies, and creatures can push, pull, hit, eat, and pick up the critter, most with its own script and stimulus attached, aiming towards the Creatures Development Standards. This uses Christian's snke.s16 from Helen's Cob Tutorial 9. This tutorial is for intermediate coders: the nest acts as a smart vendor. It's useful to use the CAOS Tool or another highlighting tool because they can make the CAOS syntax easier to read.
Contents
CAOS2PRAY[edit]
CAOS2PRAY is a feature included with RProgrammer's Jagent which allows the coder to not have to code a separate PRAY file in their agents. This chunk of code goes at the top of the COS file, and when it is dragged and dropped onto Monk (also part of the Jagent suite), compiles the cos file, with its dependant sprite file, into an agent that will be easy for everyone to install and play with. For more details on CAOS2PRAY, see CAOS2PRAY: An Easier Way by Amaikokonut.
**CAOS2PRAY *# Pray-File "Snakey.agents" *# C3-Name "Snakey C3" *# DS-Name "Snakey DS" *# attach snke.s16 *# desc = "A polite critter" *# Agent Animation File = "snke.s16" *# Agent Animation String = "0" *# Agent Sprite First Image = 0 *# Agent Animation Gallery = "snke" *# Web URL = "creatures.wiki" *# Web Label = "Creatures Wiki"
Nest install[edit]
Instantaneously:
inst
create a new simple agent that's a nest with the species ID number 1000 - use 2 images from the 'blnk' sprite and set it at image plane 0.
new: simp 2 17 1000 "blnk" 2 0 0
It's not heavy - it will stay put in midair.
accg 0
Does not go through room boundaries
perm 0
Runs a timer script every 20 seconds
tick 400
Has no attributes
attr 0 anim [0]
mvto 1164 9435
Critter install[edit]
reps 8 inst new: simp 2 15 1000 "snke" 16 0 3500 attr 194 bhvr 59 elas 99 accg 3 aero 10 fric 70 perm 60 tick 16 *die of old age setv ov69 rand 500 1500 doif tmvt 1164 9435 eq 1 mvto 1164 9435 endi repe
Nest timer[edit]
This nest acts as a smart vendor every 20 seconds.
scrp 2 17 1000 9 inst rnge 800 *NB this is the class number of the critter. esee 2 15 1000 addv va00 1 next *if less than or equal to 5, make one more. doif va00 <= 5 new: simp 2 15 1000 "snke" 16 0 3500 attr 194 bhvr 59 elas 99 accg 3 aero 10 fric 70 perm 60 setv ov69 rand 500 1500 tick 16 doif tmvt 1164 9435 eq 1 mvto 1164 9435 endi endi endm
Critter timer[edit]
This script uses ov99 to add up the amount of times this critter has tried to run its timer script. If the 'life lived' (ov99) is greater than their time to die (ov69, chosen at birth), the critter will die. If this does not occur, the critter will go on to set a direction to walk in, repeat a walking animation (anim and over) while moving in that direction (velo).
scrp 2 15 1000 9 *Count up the sands of time addv ov99 1 *if the life lived is equal to a random number between 500 and 1500 (chosen at birth), die. doif ov99 gt ov69 kill ownr endi *Set direction to walk in setv ov00 rand 0 1 doif ov00 eq 0 *repeat this reps rand 5 17 *walk right anim [0 1 2 3 4 5 6 7] over velo 6 -2 repe else reps rand 5 17 *Walk left anim [8 9 10 11 12 13 14 15] over velo -6 -2 repe *end direction-choosing doif endi endm
Collision Script[edit]
If the wall is to the right, set the velocity to go to the left and set the object variable 00 to 0 (which makes the critter animate going left)
scrp 2 15 1000 6 doif wall eq rght velo -6 -2 setv ov00 0
Else, if the wall is to the left, set the velocity to go to the right and set the object variable 00 to 1 (which makes the critter animate going right)
elif wall eq left velo 6 -2 setv ov00 1 endi endm
Push Script[edit]
This is the simplest a push script can get while still being useful - it simply stimulates the creature that pushed it. There are many other things that can be done with push scripts to make them more interesting to the player.
scrp 2 15 1000 1 targ from stim writ targ 86 1 endm
Pull Script[edit]
Just the same as the push script.
scrp 2 15 1000 2 targ from stim writ targ 86 1 endm
Hit Script[edit]
scrp 2 15 1000 3 targ from stim writ targ 87 1 kill ownr endm
Eat Script[edit]
You might recognize the bulk of this script from Making food objects for C3 - however the stimulus is different, as there is an 'eaten animal' stimulus.
scrp 2 15 1000 12 targ from stim writ targ 80 1 kill ownr endm
Remove script[edit]
rscr *count all critters and remove them enum 2 15 1000 kill targ next *count all nests and remove them enum 2 17 1000 kill targ next *remove all scripts scrx 2 17 1000 9 scrx 2 15 1000 9 scrx 2 15 1000 6 scrx 2 15 1000 1 scrx 2 15 1000 2 scrx 2 15 1000 3 scrx 2 15 1000 12
Whole script[edit]
**CAOS2PRAY *# Pray-File "Snakey.agents" *# C3-Name "Snakey C3" *# DS-Name "Snakey DS" *# attach snke.s16 *# desc = "A polite critter" *# Agent Animation File = "snke.s16" *# Agent Animation String = "0" *# Agent Sprite First Image = 0 *# Agent Animation Gallery = "snke" *# Web URL = "creatures.wiki" *# Web Label = "Creatures Wiki" *** Nest install inst new: simp 2 17 1000 "blnk" 2 0 0 accg 0 perm 0 tick 400 attr 0 anim [0] mvto 1164 9435 *** Critter install reps 8 inst new: simp 2 15 1000 "snke" 16 0 3500 attr 194 bhvr 59 elas 99 accg 3 aero 10 fric 70 perm 60 tick 16 *die of old age setv ov69 rand 500 1500 doif tmvt 1164 9435 eq 1 mvto 1164 9435 endi repe *** Nest timer scrp 2 17 1000 9 inst rnge 800 *NB this is the critter's class number esee 2 15 1000 addv va00 1 next *if less than or equal to 5, make one more. doif va00 <= 5 new: simp 2 15 1000 "snke" 16 0 3500 attr 194 bhvr 59 elas 99 accg 3 aero 10 fric 70 perm 60 setv ov69 rand 500 1500 tick 16 doif tmvt 1164 9435 eq 1 mvto 1164 9435 endi endi endm *** Critter timer scrp 2 15 1000 9 *Count up the sands of time addv ov99 1 *if the life lived is equal to a random number between 500 and 1500, die. doif ov99 gt ov69 kill ownr endi *Set direction to walk in setv ov00 rand 0 1 doif ov00 eq 0 *repeat this reps rand 5 17 *walk right anim [0 1 2 3 4 5 6 7] over velo 6 -2 repe else reps rand 5 17 *Walk left anim [8 9 10 11 12 13 14 15] over velo -6 -2 repe *end direction-choosing doif endi endm ***Collision Script scrp 2 15 1000 6 doif wall eq rght velo -6 -2 setv ov00 0 elif wall eq left velo 6 -2 setv ov00 1 endi endm *** Push Script scrp 2 15 1000 1 targ from stim writ targ 86 1 endm *** Pull Script scrp 2 15 1000 2 targ from stim writ targ 86 1 endm *** Hit Script scrp 2 15 1000 3 targ from stim writ targ 87 1 kill ownr endm *** Eat Script scrp 2 15 1000 12 targ from stim writ targ 80 1 kill ownr endm rscr enum 2 15 1000 kill targ next enum 2 17 1000 kill targ next scrx 2 17 1000 9 scrx 2 15 1000 9 scrx 2 15 1000 6 scrx 2 15 1000 1 scrx 2 15 1000 2 scrx 2 15 1000 3 scrx 2 15 1000 12
Moving On[edit]
- Change the genus to be a beast (2 16 1000 instead of 2 15 1000) and change the played with stimuli to 88, "Play danger animal", instead of 86, "Play critter". Similar changes can be used to make it a bug or pest.
- Make the nest visible and give it a push script.
- Experiment with the physics attributes (ELAS, ACCG, AERO and FRIC) and VELO to produce differences in the motion of the critter.
- Reserve and use your own class numbers at Creatures Caves.
- Search on OpenGameArt.org or take inspiration from the Creating Agent Art tutorial to make a new sprite for your critter.
- Make the nest and critter appear in a different metaroom. Use the keyboard shortcut CTRL + SHIFT + X to explore different coordinates.
- Try using the Constructor Script (10) to hold various values for the critter.
- Compare this script to the Basic Land Critter in Creating a Metaroom.