Welcome to the Creatures Wiki! Log in and join the community.

Food that turns into edible detritus when eaten

From Creatures Wiki
Revision as of 00:15, 27 June 2022 by ScoobyGambit (talk | contribs)
Jump to navigation Jump to search

This food tutorial uses the power of CATO to change creatures' perception of an object (and interactions with an object) without using another class number to create a detritus object. It is useful to use the CAOS Tool or another highlighting tool because they can make the CAOS syntax easier to read. Note that because of the use of DS CAOS Commands, this object will not be usable in C3-standalone.

CAOS2PRAY

Monk, ready to use CAOS2PRAY.

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 dependent 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 "tutorial_food_detritus.agents"
*# DS-Name "Tutorial Food Detritus"
*# attach tutorial_food_detritus.c16
*# desc = "A food that turns into edible detritus when eaten."
*# Agent Animation File = "tutorial_food_detritus.c16"
*# Agent Animation String = "0"
*# Agent Sprite First Image = 0
*# Agent Animation gallery = "tutorial_food_detritus"
*# Web URL = "creatures.wiki"
*# Web Label = "Creatures Wiki"

Installation script

Create a new simple agent, using the classifier numbers 2 11 5000 and using the sprite (image) file "tutorial_food_detritus.c16". Use two images from the tutorial_food_detritus file, located at position 0 in the file (because computers start counting at 0) and have it at image plane 560 in the world. A common error that can be introduced here is "Pose change failed", caused by miscounting the amount of images that are being used, by not including image #0.

new: simp 2 11 5000 "tutorial_food_detritus" 2 0 560

Various attributes - it is carryable, mouse-carryable, suffers collisions and suffers physics. Amaikokonut's CAOS APPS can be used to help choose new ATTR and BHVR values.

attr 195

It has a high friction

fric 100

It is moderately heavy

accg 1.8

It does not bounce

elas 0

It does not go through semipermeable platforms

perm 100

It takes pose 0.

pose 0

Now for the fun part: choosing where to install it. This looks like a long piece of code, but it is thorough at its job: installing an item by the C3 or DS creator machines safely.

Using the game variable GNAM, we can find out if the game calls itself 'Docking Station'.

doif gnam eq "Docking Station"

Double-checking that "CreatorX" and "CreatorY" have been set.

	setv va00 game "CreatorX"
	setv va01 game "CreatorY"
	doif va00 eq 0 and va01 eq 0

Adding DS safety, just in case.

 		setv va00 6110
		setv va01 9200
	endi

Doing a test move, then moving it and making it smell if the test move is successful.

	doif tmvt va00 va01 eq 1
		mvto va00 va01
		emit 8 .1
	else
		mvsf va00 va01
		emit 8 .1
	endi

If the game calls itself Creatures 3 instead:

elif gnam eq "Creatures 3"

Perform a test move to a C3 location and if it's successful, move the food there and make it smell.

	doif tmvt 5671 3599 eq 1
		mvto 5671 3599
		emit 8 .1
	else
		mvsf 5671 3599
		emit 8 .1
	endi

End the 'what does the game call itself' check.

endi

Set the BHVR to 48 - it can be picked up and eaten.

bhvr 48

Eat script

scrp 2 11 5000 12

Instantly

	inst

If the pose of the agent is 0 (the uneaten food)

	doif pose eq 0

Stimulate the creature with 'I have eaten food'

		stim writ from 79 1

Change the pose to the chewed food.

		pose 1

Use CATO to change the genus category to 10 - detritus.

		cato 10

Stop the agent from smelling like food.

		emit 8 0

Target the creature that just ate the item.

		targ from

Drop it like it's hot.

		drop

If the pose of the agent is not the uneaten food (must be the chewed food)

	else

Stimulate with 'I have eaten detritus'

		stim writ from 81 1

Destroy the agent

		kill ownr

end the pose check.

	endi

End the script.

endm

Remove script

rscr
enum 2 11 5000
	kill targ
next
scrx 2 11 5000 12

Whole script

**CAOS2PRAY
*# Pray-File "tutorial_food_detritus.agents"
*# DS-Name "Tutorial Food Detritus"
*# attach tutorial_food_detritus.c16
*# desc = "A food that turns into edible detritus when eaten."
*# Agent Animation File = "tutorial_food_detritus.c16"
*# Agent Animation String = "0"
*# Agent Sprite First Image = 0
*# Agent Animation gallery = "tutorial_food_detritus"
*# Web URL = "creatures.wiki"
*# Web Label = "Creatures Wiki"

new: simp 2 11 5000 "tutorial_food_detritus" 2 0 560
attr 195
fric 100
accg 1.8
elas 0
perm 100
pose 0
doif gnam eq "Docking Station"
	setv va00 game "CreatorX"
	setv va01 game "CreatorY"
	doif va00 eq 0 and va01 eq 0
		setv va00 6110
		setv va01 9200
	endi
	doif tmvt va00 va01 eq 1
		mvto va00 va01
		emit 8 .1
	else
		mvsf va00 va01
		emit 8 .1
	endi
elif gnam eq "Creatures 3"
	doif tmvt 5671 3599 eq 1
		mvto 5671 3599
		emit 8 .1
	else
		mvsf 5671 3599
		emit 8 .1
	endi
endi
bhvr 48

scrp 2 11 5000 12
	inst
	doif pose eq 0
		stim writ from 79 1
		pose 1
		cato 10
		emit 8 0
		targ from
		drop
	else
		stim writ from 81 1
		kill ownr
	endi
endm

rscr
enum 2 11 5000
	kill targ
next
scrx 2 11 5000 12

Moving On

Once you've mastered how to use CATO to change the genus of an object, the possibilities are only limited by your imagination and the numbers 1-25, which can be used to change the category of item to any item between 'hand' and 'potion' in the C3/DS genus numbers.

  • Make the food which turns into detritus come out of a vendor.